Skip to content

Commit

Permalink
i18n: Improve the detection of untranslated string
Browse files Browse the repository at this point in the history
Fix #2607
  • Loading branch information
n10v authored and bep committed May 2, 2017
1 parent 635b3bb commit a40d1f6
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion i18n/i18n.go
Expand Up @@ -76,7 +76,21 @@ func (t Translator) initFuncs(bndl *bundle.Bundle) {
tFunc, err := bndl.Tfunc(currentLang)
if err != nil {
jww.WARN.Printf("could not load translations for language %q (%s), will use default content language.\n", lang, err)
} else if translated := tFunc(translationID, args...); translated != translationID {
}

translated := tFunc(translationID, args...)
// If there is no translation for translationID,
// then Tfunc returns translationID itself.
if translated == translationID {
// But if user set same translationID and translation, we should check
// if it really untranslated this way:
// If bndl contains the translationID for specified currentLang,
// then the translationID is actually translated.
_, contains := bndl.Translations()[currentLang][translationID]
if contains {
return translated
}
} else {
return translated
}
if t.cfg.GetBool("logI18nWarnings") {
Expand Down

0 comments on commit a40d1f6

Please sign in to comment.