Skip to content

Commit

Permalink
Consistently use browser.i18n language
Browse files Browse the repository at this point in the history
Make the language used for date formatting and document lang attribute
consistent with the language used for strings by using browser.i18n for
both mechanisms (instead of something relying on navigator.language
which is a different setting).

Also fixes the problems when navigator.language is not specified, see #487 and #274.
  • Loading branch information
Cimbali committed Mar 2, 2020
1 parent bc9c962 commit eb68a48
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion background.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ const Brief = {
let relativeDate = new this.common.RelativeDate(lastUpdateTime);
let time, pluralForms, form;
let lang = Brief.window.navigator.language;
let lang = browser.i18n.getUILanguage();
switch (true) {
case relativeDate.deltaMinutes === 0:
Expand Down
2 changes: 1 addition & 1 deletion ui/brief.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async function init() {
Commands.applyStyle();

let doc = contentIframe.contentDocument;
doc.documentElement.setAttribute('lang', navigator.language);
doc.documentElement.setAttribute('lang', browser.i18n.getUILanguage());

ViewList.init();
FeedList.init();
Expand Down
4 changes: 2 additions & 2 deletions ui/feedview.js
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ function EntryView(aFeedView, aEntryData) {
this._getElement('feed-name').innerHTML = feed.title;
this._getElement('authors').innerHTML = this.revision.authors;

let lang = navigator.language;
let lang = browser.i18n.getUILanguage();
this._getElement('date').textContent = this.getDateString();
this._getElement('date').setAttribute('title', this.date.toLocaleString(lang));

Expand Down Expand Up @@ -1355,7 +1355,7 @@ EntryView.prototype = {

getDateString: function EntryView_getDateString(aOnlyDatePart) {
let relativeDate = new RelativeDate(this.date.getTime());
let lang = navigator.language;
let lang = browser.i18n.getUILanguage();

if (aOnlyDatePart) {
switch (true) {
Expand Down

0 comments on commit eb68a48

Please sign in to comment.