feat(i18n): Add translation progress

This commit is contained in:
LinkinStars
2023-03-01 12:30:50 +08:00
parent acf89a399b
commit 9727e89218
2 changed files with 31 additions and 12 deletions
+24 -12
View File
@@ -1,26 +1,38 @@
# all support language
language_options:
- label: "English(US)"
- label: "English"
value: "en_US"
- label: "Español(ES)"
progress: 100
- label: "Español"
value: "es_ES"
- label: "Português(PT)"
progress: 0
- label: "Português"
value: "pt_PT"
- label: "Deutsch(DE)"
progress: 0
- label: "Deutsch"
value: "de_DE"
- label: "Français(FR)"
progress: 4
- label: "Français"
value: "fr_FR"
- label: "日本語(JA)"
progress: 100
- label: "日本語"
value: "ja_JP"
- label: "Italiano(IT)"
progress: 0
- label: "Italiano"
value: "it_IT"
- label: "Русский(RU)"
progress: 16
- label: "Русский"
value: "ru_RU"
- label: "简体中文(CN)"
progress: 13
- label: "简体中文"
value: "zh_CN"
- label: "繁體中文(CN)"
progress: 100
- label: "繁體中文"
value: "zh_TW"
- label: "한국어(KO)"
progress: 100
- label: "한국어"
value: "ko_KR"
- label: "Tiếng Việt(VI)"
progress: 0
- label: "Tiếng Việt"
value: "vi_VN"
progress: 0
+7
View File
@@ -20,6 +20,8 @@ var GlobalTrans i18n.Translator
type LangOption struct {
Label string `json:"label"`
Value string `json:"value"`
// Translation completion percentage
Progress int `json:"progress"`
}
// DefaultLangOption default language option. If user config the language is default, the language option is admin choose.
@@ -94,6 +96,11 @@ func NewTranslator(c *I18n) (tr i18n.Translator, err error) {
return nil, fmt.Errorf("i18n file parsing failed: %s", err)
}
LanguageOptions = s.LangOption
for _, option := range LanguageOptions {
if option.Progress != 100 {
option.Label = fmt.Sprintf("%s (%d%%)", option.Label, option.Progress)
}
}
return GlobalTrans, err
}