diff --git a/crowdin.yml b/crowdin.yml index aa63bedeb..51597bf01 100644 --- a/crowdin.yml +++ b/crowdin.yml @@ -12,5 +12,8 @@ files: "en-EN": en "es-ES": es "fr-FR": fr + "nl-NL": nl + "pt-PT": pt "ru-RU": ru + "zh-CH": zh ... diff --git a/internal/server/asset.go b/internal/server/asset.go index d834ccbed..5c4559a9b 100644 --- a/internal/server/asset.go +++ b/internal/server/asset.go @@ -11,6 +11,7 @@ import ( "net/http" "path" "path/filepath" + "strings" "github.com/valyala/fasthttp" @@ -71,8 +72,23 @@ func newLocalesEmbeddedHandler() (handler fasthttp.RequestHandler) { entries, err := locales.ReadDir("locales") if err == nil { for _, entry := range entries { - if entry.IsDir() && len(entry.Name()) == 2 { - languages = append(languages, entry.Name()) + if entry.IsDir() { + var lng string + + switch len(entry.Name()) { + case 2: + lng = entry.Name() + case 0: + continue + default: + lng = strings.SplitN(entry.Name(), "-", 2)[0] + } + + if utils.IsStringInSlice(lng, languages) { + continue + } + + languages = append(languages, lng) } } } @@ -94,7 +110,7 @@ func newLocalesEmbeddedHandler() (handler fasthttp.RequestHandler) { var data []byte if data, err = locales.ReadFile(fmt.Sprintf("locales/%s/%s.json", locale, namespace)); err != nil { - if variant != "" && utils.IsStringInSliceFold(language, languages) { + if utils.IsStringInSliceFold(language, languages) { data = []byte("{}") } diff --git a/internal/server/locales/nl-NL/portal.json b/internal/server/locales/nl/portal.json similarity index 100% rename from internal/server/locales/nl-NL/portal.json rename to internal/server/locales/nl/portal.json diff --git a/internal/server/locales/pt-PT/portal.json b/internal/server/locales/pt/portal.json similarity index 100% rename from internal/server/locales/pt-PT/portal.json rename to internal/server/locales/pt/portal.json diff --git a/internal/server/locales/zh-CN/portal.json b/internal/server/locales/zh/portal.json similarity index 100% rename from internal/server/locales/zh-CN/portal.json rename to internal/server/locales/zh/portal.json diff --git a/web/src/i18n/index.ts b/web/src/i18n/index.ts index fa11e9867..53231ccd1 100644 --- a/web/src/i18n/index.ts +++ b/web/src/i18n/index.ts @@ -26,15 +26,16 @@ i18n.use(Backend) de: ["en"], es: ["en"], fr: ["en"], - "nl-NL": ["en"], - "pt-PT": ["en"], + nl: ["en"], + pt: ["en"], ru: ["en"], sv: ["en"], "sv-SE": ["sv", "en"], - "zh-CN": ["en"], - "zh-TW": ["en"], + zh: ["en"], + "zh-CN": ["zh", "en"], + "zh-TW": ["zh", "en"], }, - supportedLngs: ["en", "de", "es", "fr", "nl-NL", "pt-PT", "ru", "sv", "sv-SE", "zh-CN", "zh-TW"], + supportedLngs: ["en", "de", "es", "fr", "nl", "pt", "ru", "sv", "sv-SE", "zh", "zh-CN", "zh-TW"], lowerCaseLng: false, nonExplicitSupportedLngs: true, interpolation: {