Language detection code will not work for all languages

Bug #1065422 reported by David Planella
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu Translations
Fix Released
High
Unassigned
WebApps: Applications Data
Fix Released
Undecided
Unassigned
webapps-applications (Ubuntu)
Fix Released
Undecided
Unassigned
Quantal
Fix Released
Undecided
Unassigned

Bug Description

[IMPACT]
Language detection code will not work for some languages, impeding their translations from being loaded and thus displaying English prompts to non-English speakers who have an otherwise localized desktop.

[TESTCASE]
1. LC_ALL=zn_CN.UTF8 firefox
2. open gmail
action's name in launcher should be localized

[Regression Potential]
 none

Currently the code to detect the user's language preference to load the translations for webapps is the following (in common/utils.js):

    var lang = unsafeWindow.navigator.language; //TODO: came up with a better approach

    if (dict.hasOwnProperty(lang) && dict[lang].hasOwnProperty(strid)) {
        return dict[lang][strid];
    } else {
        return strid;
    }

'dict' is a variable containing a JSON string that is populated at build time with the contents of the translations in .po files in the source tree. It includes the locale code as read from the .po (or LINGUAS) files, which is a gettext-style locale code.

The problem is that the 'lang' variable as returned from the browser in some cases won't match the user's locale. This is mainly due to the fact that Firefox uses IETF-style language codes, whereas the system uses gettext-style language codes. That means for some languages there won't be a match, and thus translations won't be loaded. Here's an example for Simplified Chinese:

- Gettext locale code: zh_CN
- Firefox locale code: zh-cn

So there must be a translation gettext -> Firefox (and Chromium, if it returns locales in a different format) at build time, so that locale names from the system and from the browser can match and translations can be loaded.

Also notice that in some cases either the country code in the locale code might be present in the system locale but not in the browser, and viceversa, so it might be an idea to ignore the country code apart from some exceptions (e.g. zh_CN and zh_TW, pt_BR, etc., to name a few)

David Planella (dpm)
visibility: private → public
Changed in ubuntu-translations:
status: New → Triaged
importance: Undecided → High
Maxim Ermilov (zaspire)
Changed in webapps-applications:
status: New → Fix Committed
David Planella (dpm)
Changed in ubuntu-translations:
status: Triaged → Fix Committed
Revision history for this message
Maxim Ermilov (zaspire) wrote :

[IMPACT]
Language detection code will not work for some languages
[TESTCASE]
1. LC_ALL=zn_CN.UTF8 firefox
2. open gmail
action's name in launcher should be localized
[Regression Potential]
 none

Steve Langasek (vorlon)
description: updated
Revision history for this message
Steve Langasek (vorlon) wrote : Please test proposed package

Hello David, or anyone else affected,

Accepted webapps-applications into quantal-proposed. The package will build now and be available at http://launchpad.net/ubuntu/+source/webapps-applications/2.4.10-0ubuntu1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please change the bug tag from verification-needed to verification-done. If it does not, change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in webapps-applications (Ubuntu Quantal):
status: New → Fix Committed
tags: added: verification-needed
David Planella (dpm)
description: updated
Revision history for this message
Olivier Febwin (febcrash) wrote :

French OK

tags: added: verification-done
removed: verification-needed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package webapps-applications - 2.4.10-0ubuntu2

---------------
webapps-applications (2.4.10-0ubuntu2) raring; urgency=low

  * Upload for raring
 -- Ken VanDine <email address hidden> Fri, 09 Nov 2012 14:59:57 -0500

Changed in webapps-applications (Ubuntu):
status: New → Fix Released
Revision history for this message
Colin Watson (cjwatson) wrote : Update Released

The verification of this Stable Release Update has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regresssions.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package webapps-applications - 2.4.10-0ubuntu1

---------------
webapps-applications (2.4.10-0ubuntu1) quantal-proposed; urgency=low

  * New upstream release.
    - Fixed: Language detection code will not work for all
      languages (LP: #1065422)
    - new translations
  * -debian/patches/lp_1064260.patch, upstream
  * -debian/patches/bzr_extract_strings.patch, upstream
  * -debian/patches/dont-add-launchers-on-edubuntu, upstream
  * debian/patches/lp_1068207.patch
    - Don't install all the webapps icons, they are in the individual
      packages (LP: #1068207)
 -- Ken VanDine <email address hidden> Wed, 24 Oct 2012 08:50:15 +0200

Changed in webapps-applications (Ubuntu Quantal):
status: Fix Committed → Fix Released
Maxim Ermilov (zaspire)
Changed in webapps-applications:
status: Fix Committed → Fix Released
Changed in ubuntu-translations:
status: Fix Committed → Fix Released
no longer affects: webapps-applications (Ubuntu Raring)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.