Wrapped String IDs

For nested JSON formats, GL Strings wraps some parts of string IDs in quotes on import

During nested json file imports, GL Strings uses dots . as delimiters or separators to indicate nesting in string IDs. If a JSON file is imported as any of the supported nested JSON formats and follows the format as shown below the resulting string ID would be root.nested.

{
    "root": {
        "nested": "A nested string"
    }
}

Upon export to any nested JSON format supported, the resulting file would contain the same output as above. However, it is important to note that if the same string Id is exported to a format other than a nested JSON, no special consideration is given to the dots(.) in the string ID.

GL Strings supports this behavior for the following JSON file formats: Nested JSON, React Nested JSON, i18next JSON, Ember-I18n.


Importing Strings with Dots(.) in Keys

Sometimes the imported file may have one or more keys that already contains a dot. For example:

{
    "root": {
        "Nested. with dot.": "A nested string"
    },
    "dotted.between": "Root key with a dot"
}

The above example shows both a root key dotted.between and a nested key Nested. with dot. containing dots. For cases like these, when imported as Nested JSON GL Strings wraps such keys in double quotes. In our example above the resultant string IDs after import are root."Nested. with dot." and "dotted.between". During exports back into a nested JSON format the quotes added around the keys during import are removed. This ensures the dots in these keys are preserved.

The wrapping of keys that already contains dots does have its limitations and there are a few exceptions when keys will not be wrapped. Find more information on these below.


Cases when dots in string Ids will not be Wrapped

A dot in a string Id will not be wrapped in double quotes when the following expectations are met

  • It only contains one dot
  • The dot occurs at the end of the key
  • The value of that key is a plain string or number

For example if the following string is imported

{
    "root": {
        "Dot at the end.": "One dot at the end"
    }
}

The resulting string ID will be root.Dot at the end.. Notice the Dot at the end. is not wrapped in double quotes.

Also if we import the following string

{
    "root has a dot.": "test value"
}

The resulting string ID would be root has a dot.. Notice the key root has a dot. is not wrapped.


Caveats

Strings can be imported in several formats, uploaded via the API or created manually on Dashboard. It's possible that some string IDs might contain what looks like wrapped strings. If those strings are exported to a nested json format, the result may differ from expectations. Make sure to confirm the formatting as early as possible.