We've launched a new support center at help.smartling.com. This site will continue to be maintained into January 2017. Please update your bookmarks.
Follow

New Defaults for JSON Handling

This article applies to accounts created after June 11th 2015 and all files uploaded to any account after 13 October 2015.

Smartling has introduced new defaults for handling JSON files to give you more useful integration out-of-the-box. Previously, Smartling would simply capture each JSON value as a string, without capturing any key or variant metadata and without recognizing placeholders.

Under the new default behavior, JSON keys are captured and used to make strings unique. The following placeholder formats will now be detected by default:

  • {x}
  • {{x}}
  • ${x}
  • %x%
  • %%x%%
  • ##x##
  • __x__

In effect, the new default behavior will parse JSON files as if they contained the following integration directives (or the equivalent API settings):

"smartling" : {
"translate_mode" : "custom",
"translate_paths" : ["/*"],
"source_key_paths" : ["/{*}"],
"variants_enabled" : true,
"placeholder_format_custom": ["%%[^%]+?%%", "%[^%]+?%","##[^#]+?##","__[^_]+?__","[$]\\{[^\\}\\{]+?\\}","\\{\\{[^\\}\\{]+?\\}\\}","(?<!\\{)\\{[^\\}\\{]+?\\}(?!\\})"]
},

As always, you can specify different handling using directives. Any directives you specify will override the default behavior. So, for example, if you specify a custom placeholder format, Smartling will recognize only your specified format. See our developer documentation for help specifying integration directives.

Note: The “translate_keys” directive has now been deprecated. If you upload a file containing this directive, it will fail.  You can continue to specify the keys you want translated by migrating to the “translate_paths” directive.

Example of old and new behavior

JSON:

{
"MESSAGEID1" : {
"Greeting" : "Hello, {name}",
"Body" : "Welcome to the World"
},
"MESSAGEID2" : {
"Greeting" : "Hello, {name}",
"Body" : "Sorry to see you go."
}
}

 

Old default behavior:

String

Key

Variant

Hello, {name}.

- -

Welcome to the world.

- -

Sorry to see you go.

- -

 

New default behavior:

String

Key

Variant

Hello, {name}.

MESSAGEID1:#:Greeting

MESSAGEID1:#:Greeting

Welcome to the world.

MESSAGEID1:#:Body

MESSAGEID1:#:Body

Hello, {name}.

MESSAGEID2:#:Greeting

MESSAGEID2:#:Greeting

Sorry to see you go.

MESSAGEID2:#:Body

MESSAGEID2:#:Body

In the old behavior {name} was not a placeholder in the first string, and the string was not made unique by its key.  In the new behavior {name} is a placeholder and both strings are made unique by the keys in the file.

In order to get the old behavior users can add the following directives to the front of their file:

"smartling" : {
"variants_enabled" : false,
"placeholder_format_custom": ["$NULL"]
},

This effectively stops the unique string behavior and stops creating placeholders.

Note: Smartling uses keys to match strings when importing translations, so you should add the same directives the translated file as were present in the original file, or your strings may not match.

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request
Powered by Zendesk