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