From 8163b3438b87be054f2cb8a9c9231bf09de2e544 Mon Sep 17 00:00:00 2001 From: Marius David Wieschollek Date: Tue, 22 Dec 2020 18:02:18 +0100 Subject: Change file name Signed-off-by: Marius David Wieschollek --- scripts/message-description-sync.mjs | 54 +++++++++++++++++++++++++++++++++++ scripts/sync-message-descriptions.mjs | 54 ----------------------------------- 2 files changed, 54 insertions(+), 54 deletions(-) create mode 100644 scripts/message-description-sync.mjs delete mode 100644 scripts/sync-message-descriptions.mjs (limited to 'scripts') diff --git a/scripts/message-description-sync.mjs b/scripts/message-description-sync.mjs new file mode 100644 index 0000000..ba1d94a --- /dev/null +++ b/scripts/message-description-sync.mjs @@ -0,0 +1,54 @@ +import LanguageTags from '../src/platform/generic/_locales/en/messages.json'; +import LanguageTagsBg from '../src/platform/generic/_locales/bg/messages.json'; +import LanguageTagsDe from '../src/platform/generic/_locales/de/messages.json'; +import LanguageTagsEs from '../src/platform/generic/_locales/es/messages.json'; +import LanguageTagsFr from '../src/platform/generic/_locales/fr/messages.json'; +import LanguageTagsIt from '../src/platform/generic/_locales/it/messages.json'; +import LanguageTagsPl from '../src/platform/generic/_locales/pl/messages.json'; +import LanguageTagsRu from '../src/platform/generic/_locales/ru/messages.json'; +import LanguageTagsTr from '../src/platform/generic/_locales/tr/messages.json'; +import fs from 'fs'; +import path from 'path'; + + +let languages = { + bg: LanguageTagsBg, + de: LanguageTagsDe, + es: LanguageTagsEs, + fr: LanguageTagsFr, + it: LanguageTagsIt, + pl: LanguageTagsPl, + ru: LanguageTagsRu, + tr: LanguageTagsTr + }, + changes = {}; + +for(let tag in LanguageTags) { + if(!LanguageTags.hasOwnProperty(tag)) continue; + let languageTag = LanguageTags[tag]; + if(!languageTag.hasOwnProperty('description') || languageTag.description.length === 0) continue; + + for(let language in languages) { + if(!languages.hasOwnProperty(language)) continue; + if(!languages[language].hasOwnProperty(tag)) continue; + let translation = languages[language][tag]; + + if(!translation.hasOwnProperty('description') || translation.description.length === 0 || translation.description !== languageTag.description) { + translation.description = languageTag.description; + changes[language] = true; + } + + if(languageTag.hasOwnProperty('placeholders') && (translation.hasOwnProperty('placeholders') || JSON.stringify(languageTag.placeholders) !== JSON.stringify(translation.placeholders))) { + translation.placeholders = languageTag.placeholders; + changes[language] = true; + } + } +} + +for(let language in changes) { + if(!changes.hasOwnProperty(language) || !languages.hasOwnProperty(language)) continue; + + let data = JSON.stringify(languages[language], null, 4), + file = path.resolve(`src/platform/generic/_locales/${language}/messages.json`); + fs.writeFileSync(file, data); +} \ No newline at end of file diff --git a/scripts/sync-message-descriptions.mjs b/scripts/sync-message-descriptions.mjs deleted file mode 100644 index ba1d94a..0000000 --- a/scripts/sync-message-descriptions.mjs +++ /dev/null @@ -1,54 +0,0 @@ -import LanguageTags from '../src/platform/generic/_locales/en/messages.json'; -import LanguageTagsBg from '../src/platform/generic/_locales/bg/messages.json'; -import LanguageTagsDe from '../src/platform/generic/_locales/de/messages.json'; -import LanguageTagsEs from '../src/platform/generic/_locales/es/messages.json'; -import LanguageTagsFr from '../src/platform/generic/_locales/fr/messages.json'; -import LanguageTagsIt from '../src/platform/generic/_locales/it/messages.json'; -import LanguageTagsPl from '../src/platform/generic/_locales/pl/messages.json'; -import LanguageTagsRu from '../src/platform/generic/_locales/ru/messages.json'; -import LanguageTagsTr from '../src/platform/generic/_locales/tr/messages.json'; -import fs from 'fs'; -import path from 'path'; - - -let languages = { - bg: LanguageTagsBg, - de: LanguageTagsDe, - es: LanguageTagsEs, - fr: LanguageTagsFr, - it: LanguageTagsIt, - pl: LanguageTagsPl, - ru: LanguageTagsRu, - tr: LanguageTagsTr - }, - changes = {}; - -for(let tag in LanguageTags) { - if(!LanguageTags.hasOwnProperty(tag)) continue; - let languageTag = LanguageTags[tag]; - if(!languageTag.hasOwnProperty('description') || languageTag.description.length === 0) continue; - - for(let language in languages) { - if(!languages.hasOwnProperty(language)) continue; - if(!languages[language].hasOwnProperty(tag)) continue; - let translation = languages[language][tag]; - - if(!translation.hasOwnProperty('description') || translation.description.length === 0 || translation.description !== languageTag.description) { - translation.description = languageTag.description; - changes[language] = true; - } - - if(languageTag.hasOwnProperty('placeholders') && (translation.hasOwnProperty('placeholders') || JSON.stringify(languageTag.placeholders) !== JSON.stringify(translation.placeholders))) { - translation.placeholders = languageTag.placeholders; - changes[language] = true; - } - } -} - -for(let language in changes) { - if(!changes.hasOwnProperty(language) || !languages.hasOwnProperty(language)) continue; - - let data = JSON.stringify(languages[language], null, 4), - file = path.resolve(`src/platform/generic/_locales/${language}/messages.json`); - fs.writeFileSync(file, data); -} \ No newline at end of file -- cgit v1.2.3