GO i18n Localization

This file type implements the JSON format for the go-i18n library. At the moment just this special JSON format is implemented since it differs from other common JSON formats.

Other by go-i18n supported format, like YAML, TOML are not implemented, yet. Please contact us if you are interested in this implementation.

Format

  • The placeholder syntax is “{{ placeholder }}”.

  • besides common i18n JSON, every segment is represented by an element having the attributes “id”, “translation”

  • Plurals are implemented. “translation” attribute holds an object (see examples below).

Examples

[
  {
    "id": "d_days",
    "translation": {
      "one": "{{.Count}} day",
      "other": "{{.Count}} days"
    }
  },
  {
    "id": "my_height_in_meters",
    "translation": {
      "one": "I am {{.Count}} meter tall.",
      "other": "I am {{.Count}} meters tall."
    }
  },
  {
    "id": "person_greeting",
    "translation": "Hello {{.Person}}"
  },
  {
    "id": "person_unread_email_count",
    "translation": {
      "one": "{{.Person}} has {{.Count}} unread email.",
      "other": "{{.Person}} has {{.Count}} unread emails."
    }
  },
  {
    "id": "person_unread_email_count_timeframe",
    "translation": {
      "one": "{{.Person}} has {{.Count}} unread email in the past {{.Timeframe}}.",
      "other": "{{.Person}} has {{.Count}} unread emails in the past {{.Timeframe}}."
    }
  },
  {
    "id": "program_greeting",
    "translation": "Hello world"
  },
  {
    "id": "your_unread_email_count",
    "translation": {
      "one": "You have {{.Count}} unread email.",
      "other": "You have {{.Count}} unread emails."
    }
  }
]

Last updated