Skip to content

Commit f133f41

Browse files
authored
Merge pull request #1432 from plone/fix-i18n-select2
fix language identifier for language file
2 parents 061c899 + 84a5a1f commit f133f41

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/pat/select2/select2.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,11 @@ export default Base.extend({
109109
await import("select2");
110110
try {
111111
// Don't load "en" which is the default where no separate language file exists.
112-
if (this.options.language && this.options.language !== "en") {
113-
await import(`select2/select2_locale_${this.options.language}`);
112+
if (this.options.language && this.options.language !== "en" && !this.options.language.startsWith("en")) {
113+
let lang = this.options.language.split("-");
114+
// Fix for country specific languages
115+
lang = (lang.length > 1) ? `${lang[0]}-${lang[1]}` : lang[0];
116+
await import(`select2/select2_locale_${lang}`);
114117
}
115118
} catch {
116119
console.warn("Language file could not be loaded", this.options.language);

0 commit comments

Comments
 (0)