JSON i18n

Extension
identifier
Resources

.json

JSON

JSON files are the most common resource file format for JavaScript applications. Every key is associated with a value. Paths can be nested, so that a path of multiple keys lead to a value. In the example below, the first key is expressed as "_override_link_account/bundle_signin/password" and the value is "Enter your password."

Example

{
    "_override_link_account": {
        "bundle_signin": {
            "password": "Enter your password"
        }
    },
        "signin_with": "Sign in with",
        "show": "Show",
        "hide": "Hide",
        "aria_show": "Show password characters",
        "aria_hide": "Hide password characters",
        "cancel": "Cancel",
        "no_thanks": "No thanks, not now",
    }
}

Qordoba's platform parses your source language resource file for strings and keys, which are expressed as paths.

A localized JSON file of the above example will look like this (in this example, Korean):

{
    "_override_link_account": {
        "bundle_signin": {
            "password": "비밀번호를 입력"
        }
    },
        "signin_with": "에 로그인",
        "show": "보여 주다",
        "hide": "숨는 장소",
        "aria_show": "암호 문자를 표시",
        "aria_hide": "암호 문자를 숨기기",
        "cancel": "취소하다",
        "no_thanks": "지금이 더 감사하지",
    }
}

Placeholders

If you've selected the default JSON file parser in your Qordoba project, Qordoba will use its default parser template and escape placeholders -- protecting them from being translated, while still allowing the translator to position them as needed in the translated string.

We recognize the following standard JSON placeholders by default:

Hi %{username}
Hi %{{username}}
Hi {{username}}
Hi {username}
Number of %d (d here will be A-Z and a-z only)
Number of $x (x here will be A-Z and a-z only)

Pluralization

In JSON files, languages with more than just singular and plural forms can be defined by appending the index of the plural form to the end of the string:

{
  "key": "value",
  "keyDeep": {
    "inner": "value"
  },
  "keyContext_male": "the male variant",
  "keyContext_female": "the female variant",
  "keyPluralSimple": "the singular",
  "keyPluralSimple_plural": "the plural",
  "keyPluralMultipleEgArabic_0": "the plural form 0",
  "keyPluralMultipleEgArabic_1": "the plural form 1",
  "keyPluralMultipleEgArabic_2": "the plural form 2",
  "keyPluralMultipleEgArabic_3": "the plural form 3",
  "keyPluralMultipleEgArabic_4": "the plural form 4",
  "keyPluralMultipleEgArabic_5": "the plural form 5"
}