Hi,
here is a curious behavior hapening to my app.
Here is the use case.
Use case on a freshly opened or built app:
This happens only one one view controller, and 3 texts. This doesn't happen on some text on the same VC.
Why this strange behavior? Why does it localize only on first presentation of the view controller, and not on subsequent opening unless I close app in between?
(i tried to reinstall app, clean build folder)
Here are the string extensions used to localize:
here is a curious behavior hapening to my app.
Here is the use case.
App base lang is english.
Other translation is french
On a view controller, I have this: self.introTextView.text = "DogProfileEditionVC-IntroTextView".localize()
On corresponding language files I have these:
Code Block "DogProfileEditionVC-IntroTextView" = "french text"; "DogProfileEditionVC-IntroTextView" = "english text";
Use case on a freshly opened or built app:
Load viewcontroller. Text is correctly displayed in language.
dismiss view controller.
Open view controller again: text loaded is neither from the translation file, but from the storyboard.
This happens only one one view controller, and 3 texts. This doesn't happen on some text on the same VC.
Why this strange behavior? Why does it localize only on first presentation of the view controller, and not on subsequent opening unless I close app in between?
(i tried to reinstall app, clean build folder)
Here are the string extensions used to localize:
Code Block // Add method to Strings for easily triggering the localization process. extension String { func localize() -> String { return NSLocalizedString( self, tableName: "Localizable", bundle: .main, value: self, comment: self) } public func localize(with arguments: [CVarArg]) -> String { return String(format: self.localize(), locale: nil, arguments: arguments) } }
You could put it in viewWillAppear, to be sure it's done before any display.
Is it a UITextView you localise ?
If so, there is an old bug: UITextView text are not localized from Localizable.Strings with the text as key.
Need to call with the item ID as (table is Main.strings):
helpTextView.text = NSLocalizedString("8Py-Vn-Jax.text", tableName: "Main", comment: "")
https://stackoverflow.com/questions/28596877/localization-of-ios-storyboard-uitextview-texts-are-not-localized
Is it a UITextView you localise ?
If so, there is an old bug: UITextView text are not localized from Localizable.Strings with the text as key.
Need to call with the item ID as (table is Main.strings):
helpTextView.text = NSLocalizedString("8Py-Vn-Jax.text", tableName: "Main", comment: "")
https://stackoverflow.com/questions/28596877/localization-of-ios-storyboard-uitextview-texts-are-not-localized