Skip to content

fix language identifier for language file#1432

Merged
petschki merged 3 commits intomasterfrom
fix-i18n-select2
Feb 14, 2025
Merged

fix language identifier for language file#1432
petschki merged 3 commits intomasterfrom
fix-i18n-select2

Conversation

@1letter
Copy link
Contributor

@1letter 1letter commented Feb 14, 2025

fix the generated filename for language files in select2

Comment on lines 113 to 120
var lang = this.options.language;
// Fix for country specific languages
if (lang.split("-").length > 1) {
lang =
lang.split("-")[0] +
"-" +
lang.split("-")[1].toUpperCase();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of calling .split() 3 times I'd suggest:

Suggested change
var lang = this.options.language;
// Fix for country specific languages
if (lang.split("-").length > 1) {
lang =
lang.split("-")[0] +
"-" +
lang.split("-")[1].toUpperCase();
}
let lang = this.options.language.split("-");
// Fix for country specific languages
lang = (lang.length > 1) ? `${lang[0]}-${lang[1]}` : lang[0];

@petschki petschki merged commit f133f41 into master Feb 14, 2025
3 checks passed
@petschki petschki deleted the fix-i18n-select2 branch February 14, 2025 11:46
@1letter 1letter linked an issue Feb 14, 2025 that may be closed by this pull request
@1letter 1letter self-assigned this Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix i18n for country specific languages

2 participants