Add data property to shortcut JSON stringification and parsing for <json-data>
Preprocessed Compound Template Format
Generated viai18n-element/demo/gulpfile.js with useI18nFormatDataProperty = true
In order to avoid detours in JSON.stringify() and JSON.parse() processing for <json-data> contents, <i18n-format> element can take data property to set the parsed JSON data object directly and shortcut JSON stringificaton and parsing for <json-data>.
i18n-element/demo/gulpfile.js can preprocess target tagged template literals to this optimized format. This preprocessing can be enabled by setting useI18nFormatDataProperty = true, disabled by setting useI18nFormatDataProperty = false in i18n-element/demo/gulpfile.js
Format shown in an equivalent tagged template literal format
text['target'] = [
{
"0": "You ({3}) gave no gifts.",
"1": {
"male": "You ({3}) gave him ({4}) {5}.",
"female": "You ({3}) gave her ({4}) {5}.",
"other": "You ({3}) gave them ({4}) {5}."
},
"one": {
"male": "You ({3}) gave him ({4}) and one other person {5}.",
"female": "You ({3}) gave her ({4}) and one other person {5}.",
"other": "You ({3}) gave them ({4}) and one other person {5}."
},
"other": "You ({3}) gave them ({4}) and {1} other people gifts."
},
"{{recipients.length}}",
"{{recipients.0.gender}}",
"{{sender.name}}",
"{{recipients.0.name}}",
"a gift"
];
Preprocess
<json-data>
todata
property fori18n-format
Implement preprocess for https://github.com/t2ym/i18n-format/issues/16
Add
data
property to shortcut JSON stringification and parsing for<json-data>
Preprocessed Compound Template Format
Generated via
i18n-element/demo/gulpfile.js
withuseI18nFormatDataProperty = true
In order to avoid detours in
JSON.stringify()
andJSON.parse()
processing for<json-data>
contents,<i18n-format>
element can takedata
property to set the parsed JSON data object directly and shortcut JSON stringificaton and parsing for<json-data>
.i18n-element/demo/gulpfile.js
can preprocess target tagged template literals to this optimized format. This preprocessing can be enabled by settinguseI18nFormatDataProperty = true
, disabled by settinguseI18nFormatDataProperty = false
ini18n-element/demo/gulpfile.js
Format shown in an equivalent tagged template literal format