2021-12-01 07:50:01 +00:00
|
|
|
// Copyright 2021 The Gitea Authors. All rights reserved.
|
2022-11-27 18:20:29 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2021-12-01 07:50:01 +00:00
|
|
|
|
|
|
|
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 10:08:49 +00:00
|
|
|
"fr-FR", "Français",
|
2021-12-01 07:50:01 +00:00
|
|
|
"nl-NL", "Nederlands",
|
2022-06-15 10:08:49 +00:00
|
|
|
"lv-LV", "Latviešu",
|
|
|
|
"ru-RU", "Русский",
|
2021-12-01 07:50:01 +00:00
|
|
|
"uk-UA", "Українська",
|
|
|
|
"ja-JP", "日本語",
|
2022-06-15 10:08:49 +00:00
|
|
|
"es-ES", "Español",
|
|
|
|
"pt-BR", "Português do Brasil",
|
2021-12-01 07:50:01 +00:00
|
|
|
"pt-PT", "Português de Portugal",
|
2022-06-15 10:08:49 +00:00
|
|
|
"pl-PL", "Polski",
|
|
|
|
"bg-BG", "Български",
|
|
|
|
"it-IT", "Italiano",
|
|
|
|
"fi-FI", "Suomi",
|
2021-12-01 07:50:01 +00:00
|
|
|
"tr-TR", "Türkçe",
|
2022-06-15 10:08:49 +00:00
|
|
|
"cs-CZ", "Čeština",
|
|
|
|
"sv-SE", "Svenska",
|
2021-12-01 07:50:01 +00:00
|
|
|
"ko-KR", "한국어",
|
2022-06-15 10:08:49 +00:00
|
|
|
"el-GR", "Ελληνικά",
|
2021-12-01 07:50:01 +00:00
|
|
|
"fa-IR", "فارسی",
|
2022-06-15 10:08:49 +00:00
|
|
|
"hu-HU", "Magyar nyelv",
|
|
|
|
"id-ID", "Bahasa Indonesia",
|
2021-12-01 07:50:01 +00:00
|
|
|
"ml-IN", "മലയാളം",
|
|
|
|
}
|
|
|
|
|
|
|
|
func defaultI18nLangs() (res []string) {
|
|
|
|
for i := 0; i < len(defaultI18nLangNames); i += 2 {
|
|
|
|
res = append(res, defaultI18nLangNames[i])
|
|
|
|
}
|
2022-06-20 10:02:49 +00:00
|
|
|
return res
|
2021-12-01 07:50:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func defaultI18nNames() (res []string) {
|
|
|
|
for i := 0; i < len(defaultI18nLangNames); i += 2 {
|
|
|
|
res = append(res, defaultI18nLangNames[i+1])
|
|
|
|
}
|
2022-06-20 10:02:49 +00:00
|
|
|
return res
|
2021-12-01 07:50:01 +00:00
|
|
|
}
|
2023-02-19 16:12:01 +00:00
|
|
|
|
|
|
|
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()
|
|
|
|
}
|
|
|
|
}
|