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

RESOLVED FIXED in Firefox 51

Status

defect
P2
normal
RESOLVED FIXED
3 years ago
11 months ago

People

(Reporter: wbamberg, Assigned: zombie)

Tracking

unspecified
mozilla51

Firefox Tracking Flags

(firefox51 fixed)

Details

(Whiteboard: compat, triaged)

Attachments

(2 attachments)

Reporter

Description

3 years ago
Posted 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
Reporter

Updated

3 years ago
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"

Updated

3 years ago
Priority: -- → P2
Whiteboard: compat, triaged
Assignee

Comment 1

3 years ago
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 hidden (mozreview-request)

Comment 3

3 years ago
mozreview-review
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)
Assignee

Comment 4

3 years ago
mozreview-review-reply
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".
Assignee

Updated

3 years ago
Attachment #8790044 - Flags: review?(kmaglione+bmo)

Comment 6

3 years ago
mozreview-review
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+
Assignee

Updated

3 years ago
Keywords: checkin-needed

Comment 7

3 years ago
Pushed by kwierso@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/e4e5156020e8
tabs.detectLanguage() returns "und" for undetermined, r=kmag
Keywords: checkin-needed

Comment 8

3 years ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/e4e5156020e8
Status: ASSIGNED → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla51

Updated

11 months ago
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.