nicksnyder / go-i18n

Translate your Go program into multiple languages.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Extract messages with empty text

parsaaes opened this issue · comments

I wanted to extract a message which is an empty string in the default language, but has a valid translation in other languages.
Consider this:

i18n.Message {
   ID:    "id",
   Other: "",
}

When I run goi18n extract, it doesn't update the main toml file with this message. But I want the toml file updated with this line:

id = ""

Is this behaviour normal?

Hi @nicksnyder
Did you check this? I find out that there's also a test related to this here:

{
name: "global declaration",
fileName: "file.go",
file: `package main
import "github.com/nicksnyder/go-i18n/v2/i18n"
var m = &i18n.Message{
ID: "Plural ID",
}
`,
},

Shouldn't we expect this from this test?

activeFile: []byte(`"Plural ID" = ""`)

I can work on this if you agree.

It has been a while since I thought about this, but given there is a test it appears this was at least a semi-intentional decision. I don’t know if there are other things that will break if this assumption is changed.

If there is no message in the default language, then how does the translator know what message to write?

What you are describing feels like logic that needs to exist in the application.

if (default language)
    // message not displayed in default language
else
    // i18n message with non-empty string in default language
    

You're right it's more reasonable to have it in the application logic rather than seeing it as a translation issue. I will close this issue. Thanks!