Last active
November 8, 2022 03:57
-
-
Save zbraniecki/32f60ee1df744a14a9b5e95e810398bd to your computer and use it in GitHub Desktop.
Localizable Manifest Options Size Comparison
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const display = false; | |
const pretty = false; | |
let input = { | |
"title": { | |
"display": "Lorem Ipsum", | |
}, | |
"description": { | |
"display": "Lorem Ipsum Dolor Sit Amet", | |
}, | |
"tooltip": { | |
"display": "Lorem Ipsum Dolor Sit Amet", | |
}, | |
}; | |
let locales = [ | |
"ar", "sk", "ml", "sr-Cyrl", "sr-Latn", "en", | |
"fr", "de", "it-IT", "de-AT", "ja", "zh-Hans", | |
"pl", "cs", "en-AU", "es-CL", "und" | |
]; | |
function print(data, file) { | |
let result; | |
if (pretty) { | |
result = JSON.stringify(data, null, " "); | |
} else { | |
result = JSON.stringify(data); | |
} | |
if (display) { | |
console.log(result); | |
} else { | |
fs.writeFile(file, result, () => {}); | |
} | |
} | |
function standard() { | |
let data = {}; | |
for (let key in input) { | |
data[key] = { | |
"display": [], | |
}; | |
for (let locale of locales) { | |
data[key]["display"].push({ | |
"locale": locale, | |
"value": input[key]["display"], | |
}); | |
} | |
} | |
print(data, "v1.json"); | |
} | |
function variantTwo() { | |
let data = {}; | |
for (let key in input) { | |
data[key] = { | |
"display": {}, | |
}; | |
for (let locale of locales) { | |
data[key]["display"][locale] = input[key]["display"]; | |
} | |
} | |
print(data, "v2.json"); | |
} | |
function variantThree() { | |
let data = {}; | |
for (let locale of locales) { | |
data[locale] = input; | |
} | |
print(data, "v3.json"); | |
} | |
standard(); | |
variantTwo(); | |
variantThree(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"title": { | |
"display": [ | |
{ | |
"locale": "ar", | |
"value": "Lorem Ipsum" | |
}, | |
{ | |
"locale": "sk", | |
"value": "Lorem Ipsum" | |
}, | |
{ | |
"locale": "ml", | |
"value": "Lorem Ipsum" | |
}, | |
{ | |
"locale": "sr-Cyrl", | |
"value": "Lorem Ipsum" | |
}, | |
{ | |
"locale": "sr-Latn", | |
"value": "Lorem Ipsum" | |
}, | |
{ | |
"locale": "en", | |
"value": "Lorem Ipsum" | |
}, | |
{ | |
"locale": "fr", | |
"value": "Lorem Ipsum" | |
}, | |
{ | |
"locale": "de", | |
"value": "Lorem Ipsum" | |
}, | |
{ | |
"locale": "it-IT", | |
"value": "Lorem Ipsum" | |
}, | |
{ | |
"locale": "de-AT", | |
"value": "Lorem Ipsum" | |
}, | |
{ | |
"locale": "ja", | |
"value": "Lorem Ipsum" | |
}, | |
{ | |
"locale": "zh-Hans", | |
"value": "Lorem Ipsum" | |
}, | |
{ | |
"locale": "pl", | |
"value": "Lorem Ipsum" | |
}, | |
{ | |
"locale": "cs", | |
"value": "Lorem Ipsum" | |
}, | |
{ | |
"locale": "en-AU", | |
"value": "Lorem Ipsum" | |
}, | |
{ | |
"locale": "es-CL", | |
"value": "Lorem Ipsum" | |
}, | |
{ | |
"locale": "und", | |
"value": "Lorem Ipsum" | |
} | |
] | |
}, | |
"description": { | |
"display": [ | |
{ | |
"locale": "ar", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "sk", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "ml", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "sr-Cyrl", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "sr-Latn", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "en", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "fr", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "de", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "it-IT", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "de-AT", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "ja", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "zh-Hans", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "pl", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "cs", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "en-AU", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "es-CL", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "und", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
} | |
] | |
}, | |
"tooltip": { | |
"display": [ | |
{ | |
"locale": "ar", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "sk", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "ml", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "sr-Cyrl", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "sr-Latn", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "en", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "fr", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "de", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "it-IT", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "de-AT", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "ja", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "zh-Hans", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "pl", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "cs", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "en-AU", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "es-CL", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
{ | |
"locale": "und", | |
"value": "Lorem Ipsum Dolor Sit Amet" | |
} | |
] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"title": { | |
"display": { | |
"ar": "Lorem Ipsum", | |
"sk": "Lorem Ipsum", | |
"ml": "Lorem Ipsum", | |
"sr-Cyrl": "Lorem Ipsum", | |
"sr-Latn": "Lorem Ipsum", | |
"en": "Lorem Ipsum", | |
"fr": "Lorem Ipsum", | |
"de": "Lorem Ipsum", | |
"it-IT": "Lorem Ipsum", | |
"de-AT": "Lorem Ipsum", | |
"ja": "Lorem Ipsum", | |
"zh-Hans": "Lorem Ipsum", | |
"pl": "Lorem Ipsum", | |
"cs": "Lorem Ipsum", | |
"en-AU": "Lorem Ipsum", | |
"es-CL": "Lorem Ipsum", | |
"und": "Lorem Ipsum" | |
} | |
}, | |
"description": { | |
"display": { | |
"ar": "Lorem Ipsum Dolor Sit Amet", | |
"sk": "Lorem Ipsum Dolor Sit Amet", | |
"ml": "Lorem Ipsum Dolor Sit Amet", | |
"sr-Cyrl": "Lorem Ipsum Dolor Sit Amet", | |
"sr-Latn": "Lorem Ipsum Dolor Sit Amet", | |
"en": "Lorem Ipsum Dolor Sit Amet", | |
"fr": "Lorem Ipsum Dolor Sit Amet", | |
"de": "Lorem Ipsum Dolor Sit Amet", | |
"it-IT": "Lorem Ipsum Dolor Sit Amet", | |
"de-AT": "Lorem Ipsum Dolor Sit Amet", | |
"ja": "Lorem Ipsum Dolor Sit Amet", | |
"zh-Hans": "Lorem Ipsum Dolor Sit Amet", | |
"pl": "Lorem Ipsum Dolor Sit Amet", | |
"cs": "Lorem Ipsum Dolor Sit Amet", | |
"en-AU": "Lorem Ipsum Dolor Sit Amet", | |
"es-CL": "Lorem Ipsum Dolor Sit Amet", | |
"und": "Lorem Ipsum Dolor Sit Amet" | |
} | |
}, | |
"tooltip": { | |
"display": { | |
"ar": "Lorem Ipsum Dolor Sit Amet", | |
"sk": "Lorem Ipsum Dolor Sit Amet", | |
"ml": "Lorem Ipsum Dolor Sit Amet", | |
"sr-Cyrl": "Lorem Ipsum Dolor Sit Amet", | |
"sr-Latn": "Lorem Ipsum Dolor Sit Amet", | |
"en": "Lorem Ipsum Dolor Sit Amet", | |
"fr": "Lorem Ipsum Dolor Sit Amet", | |
"de": "Lorem Ipsum Dolor Sit Amet", | |
"it-IT": "Lorem Ipsum Dolor Sit Amet", | |
"de-AT": "Lorem Ipsum Dolor Sit Amet", | |
"ja": "Lorem Ipsum Dolor Sit Amet", | |
"zh-Hans": "Lorem Ipsum Dolor Sit Amet", | |
"pl": "Lorem Ipsum Dolor Sit Amet", | |
"cs": "Lorem Ipsum Dolor Sit Amet", | |
"en-AU": "Lorem Ipsum Dolor Sit Amet", | |
"es-CL": "Lorem Ipsum Dolor Sit Amet", | |
"und": "Lorem Ipsum Dolor Sit Amet" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"ar": { | |
"title": { | |
"display": "Lorem Ipsum" | |
}, | |
"description": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
"tooltip": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
} | |
}, | |
"sk": { | |
"title": { | |
"display": "Lorem Ipsum" | |
}, | |
"description": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
"tooltip": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
} | |
}, | |
"ml": { | |
"title": { | |
"display": "Lorem Ipsum" | |
}, | |
"description": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
"tooltip": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
} | |
}, | |
"sr-Cyrl": { | |
"title": { | |
"display": "Lorem Ipsum" | |
}, | |
"description": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
"tooltip": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
} | |
}, | |
"sr-Latn": { | |
"title": { | |
"display": "Lorem Ipsum" | |
}, | |
"description": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
"tooltip": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
} | |
}, | |
"en": { | |
"title": { | |
"display": "Lorem Ipsum" | |
}, | |
"description": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
"tooltip": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
} | |
}, | |
"fr": { | |
"title": { | |
"display": "Lorem Ipsum" | |
}, | |
"description": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
"tooltip": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
} | |
}, | |
"de": { | |
"title": { | |
"display": "Lorem Ipsum" | |
}, | |
"description": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
"tooltip": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
} | |
}, | |
"it-IT": { | |
"title": { | |
"display": "Lorem Ipsum" | |
}, | |
"description": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
"tooltip": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
} | |
}, | |
"de-AT": { | |
"title": { | |
"display": "Lorem Ipsum" | |
}, | |
"description": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
"tooltip": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
} | |
}, | |
"ja": { | |
"title": { | |
"display": "Lorem Ipsum" | |
}, | |
"description": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
"tooltip": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
} | |
}, | |
"zh-Hans": { | |
"title": { | |
"display": "Lorem Ipsum" | |
}, | |
"description": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
"tooltip": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
} | |
}, | |
"pl": { | |
"title": { | |
"display": "Lorem Ipsum" | |
}, | |
"description": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
"tooltip": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
} | |
}, | |
"cs": { | |
"title": { | |
"display": "Lorem Ipsum" | |
}, | |
"description": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
"tooltip": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
} | |
}, | |
"en-AU": { | |
"title": { | |
"display": "Lorem Ipsum" | |
}, | |
"description": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
"tooltip": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
} | |
}, | |
"es-CL": { | |
"title": { | |
"display": "Lorem Ipsum" | |
}, | |
"description": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
"tooltip": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
} | |
}, | |
"und": { | |
"title": { | |
"display": "Lorem Ipsum" | |
}, | |
"description": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
}, | |
"tooltip": { | |
"display": "Lorem Ipsum Dolor Sit Amet" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment