Handle empty translation strings as untranslated as defined in https://www.gnu.org/software/gettext/manual/html_node/Untranslated-Entries.html. Fixes #9

This commit is contained in:
Leonel Quinteros
2017-08-30 10:53:39 -03:00
parent 2bb9254f26
commit 756045ab5e
2 changed files with 38 additions and 4 deletions

8
po.go
View File

@@ -29,7 +29,9 @@ func newTranslation() *translation {
func (t *translation) get() string {
// Look for translation index 0
if _, ok := t.trs[0]; ok {
return t.trs[0]
if t.trs[0] != "" {
return t.trs[0]
}
}
// Return unstranlated id by default
@@ -39,7 +41,9 @@ func (t *translation) get() string {
func (t *translation) getN(n int) string {
// Look for translation index
if _, ok := t.trs[n]; ok {
return t.trs[n]
if t.trs[n] != "" {
return t.trs[n]
}
}
// Return unstranlated plural by default