nicksnyder / go-i18n

Translate your Go program into multiple languages.
MIT License
3.03k stars 277 forks source link

Empty string as message content is ignored #329

Open resah opened 4 months ago

resah commented 4 months ago

I use JSON files for translations, like

{
  "application": {
    "formatter": {
      "name": "My application formatter",
      "desc": "Some explanatory description for the formatter"
    },
    "v1": {
      "label": "Label for the version v1",
      "desc": "Description for this version",
      "fields": {
        "FirstVariableToSet": {
          "label": "MyVariable",
          "desc": ""
        }
      }
    }
  }
}

I think it is absolutely valid to have an empty translation for a key, like application.v1.fields.FirstVariableToSet.desc.

Unfortunately the key (and its value) is completely scrapped during message file import.

Culprit: https://github.com/nicksnyder/go-i18n/blob/b42d9bd0c568eebf5ce123ec94b9b13438f46855/i18n/message_template.go#L37

Would it be possible to support empty message values in the future? Or maybe with a configuration parameter, whether they should be ignored or not.

nicksnyder commented 1 month ago

Unfortunately the key (and its value) is completely scrapped during message file import.

What problem does this cause for you?