messageformat-validator
Advanced tools
Comparing version
@@ -132,2 +132,3 @@ #!/usr/bin/env -S node --no-warnings --experimental-json-modules | ||
const writes = []; | ||
const localesPaths = glob.sync(pathCombined); | ||
@@ -314,5 +315,5 @@ const results = await Promise.all(localesPaths.map(async (localesPath, idx) => { | ||
const output = validateLocales({ locales, sourceLocale }); | ||
const translatorOutput = {}; | ||
await Promise.all(output.map(async(locale, idx) => { | ||
const printMissing = {}; | ||
const localeFile = `${locales[locale.locale].file}`; | ||
@@ -379,3 +380,3 @@ const localeFilePath = `${localesPath}${localeFile}`; | ||
if (['missing', 'untranslated'].includes(issue.type)) { | ||
translatorOutput[issue.key] = issue.source; | ||
printMissing[issue.key] = issue.source; | ||
} | ||
@@ -403,3 +404,3 @@ } | ||
if (program.removeExtraneous || program.addMissing || program.sort) { | ||
await writeFile(localeFilePath, locales[locale.locale].contents); | ||
writes.push([localeFilePath, locales[locale.locale].contents]); | ||
} | ||
@@ -409,3 +410,3 @@ } | ||
if (program.printMissing) { | ||
console.log(JSON.stringify(translatorOutput, null, 2)); | ||
console.log(JSON.stringify(printMissing, null, 2)); | ||
} | ||
@@ -465,2 +466,6 @@ else if (program.removeExtraneous) { | ||
for (const [path, contents] of writes) { | ||
await writeFile(path, contents); | ||
} | ||
if (results.filter(r => r).length) { | ||
@@ -467,0 +472,0 @@ |
@@ -6,3 +6,3 @@ import { readdir, writeFile } from 'node:fs/promises'; | ||
const defaultLocales = ['ar', 'cy', 'da', 'de', 'en', 'en-gb', 'es', 'es-es', 'fr', 'fr-ca', 'fr-fr', 'haw', 'hi', 'ja', 'ko', 'mi', 'nl', 'pt', 'sv', 'tr', 'zh-cn', 'zh-tw']; | ||
const defaultLocales = ['ar', 'cy', 'da', 'de', 'en', 'en-gb', 'es', 'es-es', 'fr', 'fr-ca', 'fr-fr', 'haw', 'hi', 'ja', 'ko', 'mi', 'nl', 'pt', 'sv', 'th', 'tr', 'vi', 'zh-cn', 'zh-tw']; | ||
const defaultLocaleMap = { 'fr-on': 'fr-ca' }; | ||
@@ -57,3 +57,3 @@ | ||
locales.forEach(locale => { | ||
nonDefaultLocales.forEach(locale => { | ||
try { | ||
@@ -60,0 +60,0 @@ locale = Intl.getCanonicalLocales(locale.trim().toLowerCase())[0]; |
{ | ||
"name": "messageformat-validator", | ||
"version": "3.0.0-beta.8", | ||
"version": "3.0.0-beta.9", | ||
"description": "Validates that ICU MessageFormat messages are well-formed, and that translated target messages are compatible with their source.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -164,2 +164,11 @@ export default { | ||
}, | ||
"th": { | ||
"delimiters": { | ||
"quotationStart": "“", | ||
"quotationEnd": "”", | ||
"alternateQuotationStart": "‘", | ||
"alternateQuotationEnd": "’", | ||
"apostrophe": "’" | ||
} | ||
}, | ||
"tr": { | ||
@@ -171,2 +180,11 @@ "delimiters": { | ||
"alternateQuotationEnd": "’", | ||
"apostrophe": "’", | ||
} | ||
}, | ||
"vi": { | ||
"delimiters": { | ||
"quotationStart": "“", | ||
"quotationEnd": "”", | ||
"alternateQuotationStart": "‘", | ||
"alternateQuotationEnd": "’", | ||
"apostrophe": "’" | ||
@@ -173,0 +191,0 @@ } |
57176
0.84%1400
1.6%