mirror of
https://github.com/go-gitea/gitea.git
synced 2026-01-16 17:10:36 +00:00
Use flatten translation keys (#36225)
Crowdin does not remove empty lines in nested JSON translation files. Therefore, we use flattened translation keys instead. We have also updated the key-loading logic to ensure that empty values are not applied during translation. --------- Signed-off-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: TheFox0x7 <thefox0x7@gmail.com> Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
@@ -131,16 +131,15 @@ func (l *locale) TrString(trKey string, trArgs ...any) string {
|
||||
var format string
|
||||
idx, ok := l.store.trKeyToIdxMap[trKey]
|
||||
if ok {
|
||||
if msg, ok := l.idxToMsgMap[idx]; ok {
|
||||
format = msg // use the found translation
|
||||
} else if def, ok := l.store.localeMap[l.store.defaultLang]; ok {
|
||||
// try to use default locale's translation
|
||||
if msg, ok := def.idxToMsgMap[idx]; ok {
|
||||
format = msg
|
||||
format = l.idxToMsgMap[idx]
|
||||
if format == "" { // missing translation in this locale, fallback to default
|
||||
if def, ok := l.store.localeMap[l.store.defaultLang]; ok {
|
||||
// try to use default locale's translation
|
||||
format = def.idxToMsgMap[idx]
|
||||
}
|
||||
}
|
||||
}
|
||||
if format == "" {
|
||||
if format == "" { // still missing, use the key itself
|
||||
format = html.EscapeString(trKey)
|
||||
}
|
||||
msg, err := Format(format, trArgs...)
|
||||
|
||||
Reference in New Issue
Block a user