Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

feat(i18n): Add translation progress

LinkinStars9727e89218c6
diff --git a/i18n/i18n.yaml b/i18n/i18n.yaml
index 87db7100..b45acd8c 100644
--- a/i18n/i18n.yaml
+++ b/i18n/i18n.yaml
@@ -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
diff --git a/internal/base/translator/provider.go b/internal/base/translator/provider.go
index bff57486..e992aec3 100644
--- a/internal/base/translator/provider.go
+++ b/internal/base/translator/provider.go
@@ -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
}