Page MenuHomePhabricator

Android app doesn't update locale when system locale changes
Closed, ResolvedPublic

Description

If the user changes the system locale while the app is running, the app stays on whatever language it was on previously.

We should instead switch locales and eg start drawing the menus in the new language. May need to check with PhoneGap if we get an event when this happens.


Version: 1.0.0 (Android)
Severity: normal

Details

Reference
bz32897

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 12:07 AM
bzimport set Reference to bz32897.

I don't see a specific 'settings changed' sort of event in PhoneGap docs, but 'resume' should do the job:

http://docs.phonegap.com/en/1.0.0/phonegap_events_events.md.html#resume

we should check a few things including whether the locale changed, and if so then reinitialize and, if necessary, reapply the current page's localized text replacements.

In some initial testing, I'm not actually getting the 'pause' or 'resume' events fired... :( I'm not sure whether they're not working, or if they actually only fire when the app gets more solidly shut down than is happening during regular app switching...

pause/resume events work currently (since the PhoneGap 1.3.0 update, may or may not be related) however the user-agent string doesn't update, so i'll have to get the locale by other means.

Having trouble with the Globalization plugin to get locale info: PhoneGap.exec returns a 'class not found' error.

Work in progress: https://github.com/brion/Wikipedia/tree/locale

philinje wrote:

Still seeing language in menu change partially after changing phone language. Usually the More button is in the new language, while the rest of the menu is in the old language. Then closing the app and opening it again shows all the menu items in the new language.

Fixed in commit f53b6ba239b48e0aedd769ba82feb3daf59d6d98.

Using Globalization plugin we can get the locale correctly, and this seems to update properly unlike the prior tricks. No need to check the 'resume' event here, since the activity appears to be getting restarted entirely after a locale change -- just have to get it right the first time.