Closed
Bug 1096120
Opened 9 years ago
Closed 9 years ago
Context menu labels aren't invalidated after switching locales
Categories
(Firefox for Android Graveyard :: Locale switching and selection, defect)
Firefox for Android Graveyard
Locale switching and selection
All
Android
Tracking
(firefox34 wontfix, firefox35+ verified, firefox36 verified, fennec35+)
VERIFIED
FIXED
Firefox 36
People
(Reporter: rnewman, Assigned: rnewman, Mentored)
References
Details
Attachments
(1 file)
17.47 KB,
patch
|
Margaret
:
review+
lsblakk
:
approval-mozilla-aurora+
|
Details | Diff | Splinter Review |
* Set browser to Spanish. * Relaunch. * Set browser to system locale. * Observe that context menu still shows "Abrir en una pestaña nueva".
Updated•9 years ago
|
tracking-fennec: --- → ?
Assignee | ||
Comment 1•9 years ago
|
||
This might be a regression, by the way -- I seem to recall some work being done on context menus in the past few releases, and I'm pretty sure we would have noticed during initial testing. Unlikely to affect the outcome, but worth knowing if/how far we should uplift.
Assignee | ||
Comment 2•9 years ago
|
||
I have what *should* be a fix for this: whenever we add a menu item, do it dynamically. E.g., - NativeWindow.contextmenus.add(Strings.browser.GetStringFromName("contextmenu.openInPrivateTab"), + NativeWindow.contextmenus.add(stringGetter("contextmenu.openInPrivateTab"), where stringGetter is: + function stringGetter (name) { + return function () { + console.log("XXX calling stringGetter: " + name + " = " + + Strings.browser.GetStringFromName(name)); + return Strings.browser.GetStringFromName(name); + }; + } However, this alone doesn't work, because the StringBundle (Strings.browser) is returning stale values *even after the bundles have been flushed*: I/GeckoConsole(23399): Locale:Changed: fr I/GeckoConsole(23399): XXX flushing strings I/GeckoConsole(23399): Default intl.accept_languages = fr, fr-fr, en-us, en I/GeckoConsole(23399): Setting intl.accept_languages to fr,en-us,fr-fr,en ... I/GeckoConsole(23399): XXX calling stringGetter: contextmenu.openInNewTab = Abrir en una pestaña nueva I/GeckoConsole(23399): XXX reformatMenuItems. (e.g., Abrir en una pestaña nueva) I/GeckoConsole(23399): XXX calling stringGetter: contextmenu.openInNewTab = Abrir en una pestaña nueva
Assignee | ||
Comment 3•9 years ago
|
||
Thanks to Axel for pointing out a flawed assumption in Bug 1020502.
Assignee | ||
Comment 4•9 years ago
|
||
The fix in Bug 1020502 was incomplete; flushing the bundle service does not (always?) invalidate existing bundles. This patch makes `Strings` re-initializable, and does so when the locale changes. Margaret gets review, 'cos she reviewed that fix.
Attachment #8521113 -
Flags: review?(margaret.leibovic)
Comment 5•9 years ago
|
||
Comment on attachment 8521113 [details] [diff] [review] Invalidate context menu on locale change. v1 Review of attachment 8521113 [details] [diff] [review]: ----------------------------------------------------------------- ::: mobile/android/base/GeckoApp.java @@ +391,4 @@ > onPreparePanel(featureId, mMenuPanel, mMenu); > } > > return mMenuPanel; While you're removing trailing whitespace, there's also some here. ::: mobile/android/chrome/content/browser.js @@ +554,5 @@ > WebappRT.init(status, url, callback); > }, > > + initContextMenu: function () { > + let stringGetter = name => () => Strings.browser.GetStringFromName(name); o_O Why do you need two arrows here? @@ +1831,5 @@ > Services.prefs.savePrefFile(null); > > // Blow away the string cache so that future lookups get the > // correct locale. > + Strings.flush(); Will this do the job? initContextMenu is called in BrowserApp.startup, so all these menu items will have already been added. Or is this just a "part 1" patch, and there will be more?
Assignee | ||
Comment 6•9 years ago
|
||
(In reply to :Margaret Leibovic from comment #5) > > + let stringGetter = name => () => Strings.browser.GetStringFromName(name); > > o_O Why do you need two arrows here? That's half of the fix. We already allow our menu components to be functions as well as simple values. If they're functions, they'll be evaluated each time they're used, not only once. That line is "let stringGetter be a function that takes a name, returning a function that looks up the string when called". It returns a thunk rather than a string. > Will this do the job? initContextMenu is called in BrowserApp.startup, so > all these menu items will have already been added. This is the other half of the fix. By making the labels dynamic, we don't need to reconstruct the context menu; we just need to ensure that Strings.browser is invalidated, so the next time we build the UI from the ContextMenuItems, we'll get the right strings. Strings.flush takes care of that by throwing away the StringBundles and flushing the StringBundleService.
Comment 7•9 years ago
|
||
Comment on attachment 8521113 [details] [diff] [review] Invalidate context menu on locale change. v1 Review of attachment 8521113 [details] [diff] [review]: ----------------------------------------------------------------- Okay, that makes sense. I didn't realized you could pass a function to contextmenus.add. I think you should add a comment above that!
Attachment #8521113 -
Flags: review?(margaret.leibovic) → review+
Assignee | ||
Comment 8•9 years ago
|
||
https://hg.mozilla.org/integration/fx-team/rev/7a6800ce9153
Assignee | ||
Comment 9•9 years ago
|
||
I'd like to uplift this to Aurora.
status-firefox34:
--- → affected
status-firefox35:
--- → affected
status-firefox36:
--- → fixed
Flags: qe-verify?
Assignee | ||
Comment 10•9 years ago
|
||
Comment on attachment 8521113 [details] [diff] [review] Invalidate context menu on locale change. v1 Approval Request Comment [Feature/regressing bug #]: Locale switching edge case. Not a regression. [User impact if declined]: Context menus will show the incorrect language after switching locales. [Describe test coverage new/current, TBPL]: Test coverage not possible. Manually tested. [Risks and why]: Quite a simple patch; low risk. [String/UUID change made/needed]: None.
Attachment #8521113 -
Flags: approval-mozilla-aurora?
Comment 11•9 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/7a6800ce9153
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 36
Comment 12•9 years ago
|
||
[Tracking Requested - why for this release]:
Updated•9 years ago
|
Attachment #8521113 -
Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Updated•9 years ago
|
Comment 14•8 years ago
|
||
After performing steps from comment 0, context menu options are displayed in system default language. Verified as fixed in builds: Firefox for Android 36.0a2 (2014-12-04); Firefox for Android 35 Beta 2; Device: Asus Transformer TF101 (Android 4.0.3)
Comment 15•8 years ago
|
||
(In reply to Cristina Madaras, QA [:CristinaM] from comment #14) > After performing steps from comment 0, context menu options are displayed in > system default language. > Verified as fixed in builds: > Firefox for Android 36.0a2 (2014-12-04); > Firefox for Android 35 Beta 2; > > Device: > Asus Transformer TF101 (Android 4.0.3) Firefox for Android 35 Beta 1 build 2; Sorry for that!
Assignee | ||
Updated•8 years ago
|
Flags: qe-verify?
Updated•2 years ago
|
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•