Skip to content

Commit

Permalink
feat(en-lol): add translation (#24)
Browse files Browse the repository at this point in the history
also infra for non-standard locales

---------

Co-authored-by: Hagen <[email protected]>
  • Loading branch information
Ozpyn and MrGriefs authored May 6, 2024
1 parent 8efd306 commit e6b272d
Show file tree
Hide file tree
Showing 14 changed files with 630 additions and 20 deletions.
4 changes: 3 additions & 1 deletion .scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ const Ajv = require('ajv');
const { parseExpression } = require('@babel/parser');
const { isLocale, getLocaleFiles, findJsonNode, getLocaleDirents } = require('../util');
const { locales, sourceLocale } = require('../constants');
const { [sourceLocale]: source } = require('../data');
const _data = require('../data');

const { [sourceLocale]: source } = _data;
const base = path.resolve(__dirname, '..');
const ajv = new Ajv({ allErrors: true, strict: false, logger: false });

Expand All @@ -31,6 +32,7 @@ function warn(message) {
}

for (const code of locales) {
if (_data[code].locale?.standard === false) continue;
if (!isLocale(code)) error(`Language code "${code}" is not valid for this project.`);
}

Expand Down
5 changes: 3 additions & 2 deletions .scripts/update-readmes.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const crowdinLocales = new Set();
for (const locale in data) if (data[locale].locale?.crowdin) crowdinLocales.add(locale);

const base = path.resolve(__dirname, '..');
const source = data[sourceLocale];
delete data[sourceLocale];

const displayNames = Object.fromEntries(locales.map(locale => [locale, new Intl.DisplayNames(locale, { type: 'language' })]));
Expand Down Expand Up @@ -52,8 +53,8 @@ const format = (str, info) => {
const formatReadme = locale => {
const readme = crowdinLocales.has(locale) ? crowdinReadme : localeReadme;
const percent = l10nPercent[locale];
const nativeDisplayName = capital(displayNames[locale].of(locale), locale);
const englishDisplayName = displayNames[sourceLocale].of(locale);
const nativeDisplayName = data[locale].meta?.locale?.[locale]?.display_name?.long || capital(displayNames[locale].of(locale), locale);
const englishDisplayName = source.meta?.locale?.[locale]?.display_name?.long || displayNames[sourceLocale].of(locale);

return format(readme, {
locale,
Expand Down
21 changes: 9 additions & 12 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,20 @@
{
"url": "./schema.json",
"fileMatch": [
"[a-z][a-z]-[A-Z][A-Z]/**.json",
"![a-z][a-z]-[A-Z][A-Z]/locale.json",
"[a-z][a-z]-[A-Z][A-Z].json",
"![a-z][a-z]-[A-Z][A-Z].locale.json",
"[a-z][a-z]/**.json",
"![a-z][a-z]/locale.json",
"[a-z][a-z].json",
"![a-z][a-z].locale.json",
"/[a-z][a-z]{[a-z],}{-*,}/**/*.json",
"!/[a-z][a-z]{[a-z],}{-*,}/{locale,meta}.json",
]
},
{
"url": "./locale.schema.json",
"fileMatch": [
"[a-z][a-z]-[A-Z][A-Z]/locale.json",
"[a-z][a-z]-[A-Z][A-Z].locale.json",
"[a-z][a-z]/locale.json",
"[a-z][a-z].locale.json",
"/[a-z][a-z]{[a-z],}{-*,}/locale.json",
]
},
{
"url": "./meta.schema.json",
"fileMatch": [
"/[a-z][a-z]{[a-z],}{-*,}/meta.json",
]
}
]
Expand Down
10 changes: 10 additions & 0 deletions en-GB/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"locale": {
"en-lolcat": {
"display_name": {
"long": "LOLCAT (Kingdom of Cats)",
"short": "LOLCAT"
}
}
}
}
Loading

0 comments on commit e6b272d

Please sign in to comment.