diff options
author | Albert Nigmatzianov <albertnigma@gmail.com> | 2017-05-02 19:01:05 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-05-02 22:45:37 +0200 |
commit | a40d1f6ed2aedddc99725658993258cd557640ed (patch) | |
tree | 9738bf7265f0c4cce967ab5ebb40333a07166fed /i18n | |
parent | 635b3bb4eb873978c7d52e6c0cb85da0c4d25299 (diff) |
i18n: Improve the detection of untranslated string
Fix #2607
Diffstat (limited to 'i18n')
-rw-r--r-- | i18n/i18n.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/i18n/i18n.go b/i18n/i18n.go index ce268fac3..80fc5bb04 100644 --- a/i18n/i18n.go +++ b/i18n/i18n.go @@ -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") { |