Closed Bug 1288263 Opened 8 years ago Closed 8 years ago

If chrome.tabs.detectLanguage can't detect the language, Firefox reports "un" while Chrome reports "und"

Categories

(WebExtensions :: General, defect, P2)

defect

Tracking

(firefox51 fixed)

RESOLVED FIXED
mozilla51
Tracking Status
firefox51 --- fixed

People

(Reporter: wbamberg, Assigned: zombie)

Details

(Whiteboard: compat, triaged)

Attachments

(2 files)

Attached file detect-lang-zip.zip
chrome.tabs.detectLanguage is supposed to detect the language of the content in a tab, and pass the language code into a callback.

According to the docs[1], if the language can't be detected, "und" should be passed to the callback (it seems that "und" is actually a special value for "Undetermined"[2]).

Firefox passes "un" in this situation.

I've attached a WebExtension you can use to verify this.

[1] https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/tabs/detectLanguage
[2] https://www.loc.gov/standards/iso639-2/php/code_list.php
Summary: If chrome.tabs.detectLanguage can't detect the language, Firefox reports "un" while Chrome passes "und" → If chrome.tabs.detectLanguage can't detect the language, Firefox reports "un" while Chrome reports "und"
Priority: -- → P2
Whiteboard: compat, triaged
It looks this is just a simple nomenclature mismatch: "un" was an non-official two-letter language code, that only later got standardized as "und" three-letter ISO 639-2 [1] code, which Chrome responds with, even if they use "un" internally [2], just like we do [3].

A simple replace seems enough for compatibility.


[1] https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes
[2] https://src.chromium.org/viewvc/chrome/trunk/src/third_party/cld/languages/internal/languages.cc
[3] http://searchfox.org/mozilla-central/source/browser/components/translation/LanguageDetector.jsm#134
Assignee: nobody → tomica
Status: NEW → ASSIGNED
Comment on attachment 8790044 [details]
bug 1288263 - tabs.detectLanguage() returns "und" for undetermined,

https://reviewboard.mozilla.org/r/78034/#review76482

This looks good, but we should probably do the same thing for i18n.detectLanguage.
Attachment #8790044 - Flags: review?(kmaglione+bmo)
Comment on attachment 8790044 [details]
bug 1288263 - tabs.detectLanguage() returns "und" for undetermined,

https://reviewboard.mozilla.org/r/78034/#review76482

`i18n.detectLanguage` never returns "un".  it indicates weather the detection `isReliable`, and the array of `languages` found, which is simply empty in the case where `tabs.detectLanguage` would return "und".
Attachment #8790044 - Flags: review?(kmaglione+bmo)
Comment on attachment 8790044 [details]
bug 1288263 - tabs.detectLanguage() returns "und" for undetermined,

https://reviewboard.mozilla.org/r/78034/#review76680
Attachment #8790044 - Flags: review?(kmaglione+bmo) → review+
Keywords: checkin-needed
Pushed by kwierso@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/e4e5156020e8
tabs.detectLanguage() returns "und" for undetermined, r=kmag
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/e4e5156020e8
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla51
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: