JSON files revised

I have a new form of json file to utilize for translation.  The new format looks like this:

export default {
about: 'About',
account: 'Account',
actualSize: 'Actual Size',
add: 'Add',
addComment: 'Add a comment',
address: 'Address',
addToCart: 'Add to Cart',
addToCartMessage: 'Successfully added {partNumber}',
admin: 'Admin',
all: 'All',
any: 'Any',
assembly: 'Assembly | Assemblies',
:
:

I’d like to get your thoughts about your ability to handle this format. The sample shows the variations you will find in the file. The biggest changes are: 1) each key will be on a single line with the English value in single quotes after the colon, and b) keys can contain two values representing the singular and plural forms of the word separated by a pipe (|) character. Substitution parameters continue to be enclosed in curly braces, {word}, and should not be translated.

How should I set this up in Studio to translate? Is this possible or what should I ask my client to provide in order to translate these new json formats?

Parents
  • This is clearly NOT JSON format...

    Despite many people's belief, presence of curly brackets, colons and quoted strings does NOT make a file JSON-formatted.
    JSON format has strict syntax, see http://json.org for details.

    What differs your format from JSON is:

    • JSON must start with either curly bracket, or square bracket
      • i.e. your "export default" start of file makes it invalid JSON
    • JSON strings must be enclosd in quotation marks
      • i.e. your "key" strings not being enclosed at all and "value" strings being enclosed in apostrophes make it invalid JSON

    So you won't be able to process this file as-is using the standard JSON file type at all.
    You may try your luck with the Supertext JSON file type, as it may be more benevolent to the syntax...

    Otherwise you would need to process it using the plain text regex file type.
    And you won't be able to handle the plurals... as this is apparently something that's handled by its mother application internally and there is no way to do any "sub-parsing" of the translatable strings in Studio.

    Of course, you can write some pre- and post-processing script which will parse the source string and convert it to/from something else (e.g. XML) where you can have the plurals separated into separate segments.

  • Good point. Thank you. It seems the file is a .js format which is JavaScript. How do I process a .js file format?
Reply Children