Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rename ALT_LOCALES
  • Loading branch information
mapmeld committed Jul 26, 2025
commit a9b8f5e5f1a97bfbec294c253f1dbf9772c6607d
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* accept values from common locale selectors */
const SYNONYMS = {
const ALT_LOCALES = {
'zh-CN': 'zh-Hans',
'zh-Hans-CN': 'zh-Hans',
'zh-HK': 'zh-Hant',
Expand Down Expand Up @@ -125,7 +125,7 @@ function findStreetsSource(style) {
* @returns {object} the modified style
*/
MapboxLanguage.prototype.setLanguage = function (style, language) {
language = SYNONYMS[language] || language;
language = ALT_LOCALES[language] || language;
if (this.supportedLanguages.indexOf(language) < 0) {
throw new Error(`Language ${ language } is not supported`);
}
Expand Down Expand Up @@ -156,7 +156,7 @@ MapboxLanguage.prototype._initialStyleUpdate = function () {

function browserLanguage(supportedLanguages) {
let language = navigator.languages ? navigator.languages[0] : (navigator.language || navigator.userLanguage);
language = SYNONYMS[language] || language;
language = ALT_LOCALES[language] || language;
const parts = language && language.split('-');
let languageCode = language;
if (parts.length > 1) {
Expand Down