2021-12-01 13:20:01 +05:30
|
|
|
// Copyright 2021 The Gitea Authors. All rights reserved.
|
2022-11-27 23:50:29 +05:30
|
|
|
// SPDX-License-Identifier: MIT
|
2021-12-01 13:20:01 +05:30
|
|
|
|
|
|
|
package setting
|
|
|
|
|
|
|
|
// defaultI18nLangNames must be a slice, we need the order
|
|
|
|
var defaultI18nLangNames = []string{
|
|
|
|
"en-US", "English",
|
|
|
|
"zh-CN", "简体中文",
|
|
|
|
"zh-HK", "繁體中文(香港)",
|
|
|
|
"zh-TW", "繁體中文(台灣)",
|
|
|
|
"de-DE", "Deutsch",
|
2022-06-15 15:38:49 +05:30
|
|
|
"fr-FR", "Français",
|
2021-12-01 13:20:01 +05:30
|
|
|
"nl-NL", "Nederlands",
|
2022-06-15 15:38:49 +05:30
|
|
|
"lv-LV", "Latviešu",
|
|
|
|
"ru-RU", "Русский",
|
2021-12-01 13:20:01 +05:30
|
|
|
"uk-UA", "Українська",
|
|
|
|
"ja-JP", "日本語",
|
2022-06-15 15:38:49 +05:30
|
|
|
"es-ES", "Español",
|
|
|
|
"pt-BR", "Português do Brasil",
|
2021-12-01 13:20:01 +05:30
|
|
|
"pt-PT", "Português de Portugal",
|
2022-06-15 15:38:49 +05:30
|
|
|
"pl-PL", "Polski",
|
|
|
|
"bg-BG", "Български",
|
|
|
|
"it-IT", "Italiano",
|
|
|
|
"fi-FI", "Suomi",
|
2021-12-01 13:20:01 +05:30
|
|
|
"tr-TR", "Türkçe",
|
2022-06-15 15:38:49 +05:30
|
|
|
"cs-CZ", "Čeština",
|
|
|
|
"sv-SE", "Svenska",
|
2021-12-01 13:20:01 +05:30
|
|
|
"ko-KR", "한국어",
|
2022-06-15 15:38:49 +05:30
|
|
|
"el-GR", "Ελληνικά",
|
2021-12-01 13:20:01 +05:30
|
|
|
"fa-IR", "فارسی",
|
2022-06-15 15:38:49 +05:30
|
|
|
"hu-HU", "Magyar nyelv",
|
|
|
|
"id-ID", "Bahasa Indonesia",
|
2021-12-01 13:20:01 +05:30
|
|
|
"ml-IN", "മലയാളം",
|
|
|
|
}
|
|
|
|
|
|
|
|
func defaultI18nLangs() (res []string) {
|
|
|
|
for i := 0; i < len(defaultI18nLangNames); i += 2 {
|
|
|
|
res = append(res, defaultI18nLangNames[i])
|
|
|
|
}
|
2022-06-20 15:32:49 +05:30
|
|
|
return res
|
2021-12-01 13:20:01 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
func defaultI18nNames() (res []string) {
|
|
|
|
for i := 0; i < len(defaultI18nLangNames); i += 2 {
|
|
|
|
res = append(res, defaultI18nLangNames[i+1])
|
|
|
|
}
|
2022-06-20 15:32:49 +05:30
|
|
|
return res
|
2021-12-01 13:20:01 +05:30
|
|
|
}
|
2023-02-19 21:42:01 +05:30
|
|
|
|
|
|
|
var (
|
|
|
|
// I18n settings
|
|
|
|
Langs []string
|
|
|
|
Names []string
|
|
|
|
)
|
|
|
|
|
|
|
|
func loadI18nFrom(rootCfg ConfigProvider) {
|
|
|
|
Langs = rootCfg.Section("i18n").Key("LANGS").Strings(",")
|
|
|
|
if len(Langs) == 0 {
|
|
|
|
Langs = defaultI18nLangs()
|
|
|
|
}
|
|
|
|
Names = rootCfg.Section("i18n").Key("NAMES").Strings(",")
|
|
|
|
if len(Names) == 0 {
|
|
|
|
Names = defaultI18nNames()
|
|
|
|
}
|
|
|
|
}
|