Skip to content

Commit

Permalink
Update broken site locale to include country (#2587)
Browse files Browse the repository at this point in the history
  • Loading branch information
SlayterDev authored Jul 17, 2024
1 parent c6a7145 commit 9482acc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions shared/js/background/classes/tab-state.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getFromSessionStorage, setToSessionStorage, removeFromSessionStorage } from '../wrapper'
import { getUserLocale } from '../i18n'
import { getFullUserLocale } from '../i18n'
import { Tracker } from './tracker'
import { AdClick } from './ad-click-attribution-policy'

Expand Down Expand Up @@ -66,7 +66,7 @@ export class TabState {
/** @type {number[]} */
this.jsPerformance = []
/** @type {string} */
this.locale = getUserLocale()
this.locale = getFullUserLocale()
// Whilst restoring, prevent the tab data being stored
if (!restoring) {
Storage.backup(this)
Expand Down
8 changes: 8 additions & 0 deletions shared/js/background/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,11 @@ export function getUserLocale () {
}
return lang
}

export function getFullUserLocale () {
if (!browser?.i18n) {
return 'en-US'
}

return browser.i18n.getUILanguage()
}
2 changes: 1 addition & 1 deletion unit-test/background/classes/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ describe('Tab', () => {
userRefreshCount: 0,
openerContext: null,
jsPerformance: [],
locale: 'en'
locale: 'en-US'
}
expect(tabClone.site.enabledFeatures.length).toBe(14)
expect(JSON.stringify(tabClone, null, 4)).toEqual(JSON.stringify(tabSnapshot, null, 4))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function submitAndValidateReport (report) {
}

tab.userRefreshCount = report.userRefreshCount || 0
tab.locale = report.locale || 'en'
tab.locale = report.locale || 'en-US'

const addRequest = (hostname, action, opts = {}) => {
tab.addToTrackers({
Expand Down

0 comments on commit 9482acc

Please sign in to comment.