GO i18n

LingoHub supports the JSON format used by the go-i18n library. This specific JSON structure is supported alongside standard JSON formats to ensure compatibility with Go application requirements.

Format

  • The placeholder syntax follows the Go template style: {{ .Placeholder }}.
  • Every segment is represented as a JSON object containing id and translation attributes.
  • Plural forms are supported via nested objects within the translation attribute.
  • Optional comment attributes are imported as segment descriptions.

LingoHints can be included in the comment attribute:

[
  {
    "id": "premium_monthly_title",
    "translation": "{{.Price}} monatlich",
    "comment": "Monthly subscription price <lh>{\"status\": \"DRAFT\",\"qc\": {\"min\": \"3\",\"max\": \"20\"},\"labels\": [\"q3-2024\"],\"not_translatable\": false}</lh>"
  }
]

Example

[
  {
    "id": "days_count",
    "translation": {
      "one": "{{.Count}} day",
      "other": "{{.Count}} days"
    }
  },
  {
    "id": "height_meters",
    "translation": {
      "one": "I am {{.Count}} meter tall.",
      "other": "I am {{.Count}} meters tall."
    }
  },
  {
    "id": "person_greeting",
    "translation": "Hello {{.Person}}"
  },
  {
    "id": "unread_email_count",
    "translation": {
      "one": "{{.Person}} has {{.Count}} unread email.",
      "other": "{{.Person}} has {{.Count}} unread emails."
    }
  },
  {
    "id": "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": "app_greeting",
    "translation": "Hello world"
  }
]

References