bharathi91 / NextLevelLocalization

Implementing Localization in iOS app,by downloading language files from server.
14 stars 3 forks source link

Language strings not updating unless we do a relaunch #2

Open er-aman-gupta opened 3 years ago

er-aman-gupta commented 3 years ago

I'm facing one issue where if i update the value of some key, it gets downloaded and stored properly but is not updated on screen unless i relaunch the app.

How to reproduce: -

What is expected: The new string should be shown, without relaunching the app.

bharathi91 commented 3 years ago

Hi, i jus have gone through the app code. The UI update is actually done through notification observer. Jus try to post the"BKConstants.Notifications.LanguageChangeNotification" notification in this file. https://github.com/bharathi91/NextLevelLocalization/blob/master/NextLevelLocalization/NextLevelLocalization/BKLocalization.swift

line number 58. It will update your viewcontroller.

bharathi91 commented 3 years ago

I'm facing one issue where if i update the value of some key, it gets downloaded and stored properly but is not updated on screen unless i relaunch the app.

How to reproduce: -

  • i hosted another file of similar json format at https://jsonkeeper.com/b/25EL
  • updated the url in code
  • pressed the toggle button to fetch the data again.
  • the previous string was being shown not the updated one.

What is expected: The new string should be shown, without relaunching the app.

Please check an update me.

er-aman-gupta commented 3 years ago

Hey, the ui refresh is triggered correctly,

https://github.com/bharathi91/NextLevelLocalization/blob/b863d4f1fd2789e0386b26e6032c1eaa2a3cb616/NextLevelLocalization/NextLevelLocalization/HomeViewController.swift#L39. This here returns the old values.

ghost commented 1 year ago

Any updates ? I find myself with the same problem, after having deepened the problem, it seems that after an update, the new .strings file held in a fileUrl of a new bundle is correct, the keys are well updated. But when we call the bundle with this same filePath, the key is not up to date. It is to nothing to understand it I am confused.

To reproduce easily, just create an ibaction that changes the key values randomly (as if it came from an api), and update more than once on the same session without restarting the application.

The new Localizable.strings contains the new updater keys values (we can check the values via NSDictionary(contentsOfFile: path) that's correct) However if we call after the key through NSLocalizedString with the bundle associated, the key will remain the old one. (I specify once again, at the restart there are no problems, the first one will be updated, the second ones and so on not. ) I tried to create other tableName to understand if they were not issues of file duplications, without success. From your app, I export the command getLanguagesFromServer in an ibaction, and I generate the values of the translations randomly at each call to simulate (without touching the keys). I don't change the language (you'll see by yourself that there is only one update)

Thanks in advance for your help