Skip to content

Commit

Permalink
Merge pull request #1432 from plone/fix-i18n-select2
Browse files Browse the repository at this point in the history
fix language identifier for language file
  • Loading branch information
petschki authored Feb 14, 2025
2 parents 061c899 + 84a5a1f commit f133f41
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/pat/select2/select2.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,11 @@ export default Base.extend({
await import("select2");
try {
// Don't load "en" which is the default where no separate language file exists.
if (this.options.language && this.options.language !== "en") {
await import(`select2/select2_locale_${this.options.language}`);
if (this.options.language && this.options.language !== "en" && !this.options.language.startsWith("en")) {
let lang = this.options.language.split("-");
// Fix for country specific languages
lang = (lang.length > 1) ? `${lang[0]}-${lang[1]}` : lang[0];
await import(`select2/select2_locale_${lang}`);
}
} catch {
console.warn("Language file could not be loaded", this.options.language);
Expand Down

0 comments on commit f133f41

Please sign in to comment.