1
votes

I try to localize my project. I have clicked "Use Base Internalization" and added 2 languages: English and French. The English is marked as "Development language" - not sure, maybe I set it, but in the storyboard I use another language (not English). And second difference between these 2 localizations is that English (Development language) has 2 files localized while French has only 1 file localized (screenshot) I checked the app's folder. In the en.lproj there is only 1 file Main.strings with all my english translations. In the fr.lproj the same thing - only Main.strings but with french translations.

So in the folders everything is correct, but:

1) When I run app with English language - everything works correct. But when I set French language to simulator (or my real device, after deleting the app) nothing works - it shows me my standard storyboard (not English).

2) English localization has 2 localized and I can't understand what is the second file.

The second point is not crucial for me now. I just need to make French localization work

2

2 Answers

1
votes

When you add Localization than these file will show

 Localizable.strings (English).  “Hello ”   = “Hello”; (Ex you can write hello )
 Localizable.strings (Frech).    “Hello ”   = “Bonjour”;

Or main string you can change object into freach

 Main.strings(English).   3ZR-e4-Gil.text" = "Hello";
 Main.strings(Frech).     3ZR-e4-Gil.text" = "Bonjour";

swift

  import Foundation
  extension String {
  func localized(lang:String) -> String {

    let path = Bundle.main.path(forResource: lang, ofType: "lproj")
    let bundle = Bundle(path: path!)

    return NSLocalizedString(self, tableName: nil, bundle: bundle!, value: "", comment: "")

 }
 }

let str = "Hello".localized(lang: self.language! )

change language via simulator

Or Programmatically change language via app

    UserDefaults.standard.set(["en","fr"], forKey: "AppleLanguages")
    UserDefaults.standard.synchronize()
0
votes

SOLVED IT!!! The French localization wasn't used because there was a mistake in the Main.strings (for French) - I missed only one ("). But as in the Main.strings there is no catcher for such a mistakes I didn't get it.

So, it was: "XXX-6r-aEC.text" = "Confirmer;

and I changed it to:"XXX-6r-aEC.text" = "Confirmer**"**;