store-locales: verify App Store and Play codes against the official lists (2026-10-11), drop zu, aliases for the 2025 languages, tests
This commit is contained in:
parent
67e490520b
commit
efb3521279
3 changed files with 67 additions and 4 deletions
|
|
@ -54,6 +54,44 @@ describe('store locales', () => {
|
|||
expect(appleLocale('EN-gb')).toEqual({ code: 'en-GB', known: true, alias: 'EN-gb' });
|
||||
expect(appleLocale('xx-YY')).toEqual({ code: 'xx-YY', known: false });
|
||||
});
|
||||
test('the official lists (checked 2026-10-11): 50 App Store locales, 86 Play codes', () => {
|
||||
// Apple: "Managing metadata in your app by using locale shortcodes" (App Store Connect API docs)
|
||||
expect([...APPLE_LOCALES].sort()).toEqual(['ar-SA', 'bn-BD', 'ca', 'cs', 'da', 'de-DE', 'el', 'en-AU', 'en-CA', 'en-GB',
|
||||
'en-US', 'es-ES', 'es-MX', 'fi', 'fr-CA', 'fr-FR', 'gu-IN', 'he', 'hi', 'hr', 'hu', 'id', 'it', 'ja', 'kn-IN', 'ko',
|
||||
'ml-IN', 'mr-IN', 'ms', 'nl-NL', 'no', 'or-IN', 'pa-IN', 'pl', 'pt-BR', 'pt-PT', 'ro', 'ru', 'sk', 'sl-SI', 'sv', 'ta-IN',
|
||||
'te-IN', 'th', 'tr', 'uk', 'ur-PK', 'vi', 'zh-Hans', 'zh-Hant']);
|
||||
// Google: Play Console Help "Translate and localize your app" > "View list of available languages"
|
||||
expect(PLAY_LOCALES).toHaveLength(86);
|
||||
expect(new Set(PLAY_LOCALES).size).toBe(86);
|
||||
for (const c of ['bn-BD', 'gu', 'kn-IN', 'ml-IN', 'mr-IN', 'pa', 'sl', 'ta-IN', 'te-IN', 'ur', 'iw-IL', 'es-US', 'fil', 'rm', 'fa-AE'])
|
||||
expect(PLAY_LOCALES).toContain(c);
|
||||
for (const c of ['zu', 'he', 'or', 'or-IN', 'tr', 'ja']) expect(PLAY_LOCALES).not.toContain(c);
|
||||
});
|
||||
test('the 2025 App Store languages pair with Play where Play has them', () => {
|
||||
const want: Record<string, string | undefined> = { 'bn-BD': 'bn-BD', 'gu-IN': 'gu', 'kn-IN': 'kn-IN', 'ml-IN': 'ml-IN',
|
||||
'mr-IN': 'mr-IN', 'or-IN': undefined, 'pa-IN': 'pa', 'sl-SI': 'sl', 'ta-IN': 'ta-IN', 'te-IN': 'te-IN', 'ur-PK': 'ur' };
|
||||
for (const [a, p] of Object.entries(want)) {
|
||||
expect(appleToPlay(a)).toBe(p);
|
||||
if (p) expect(playToApple(p)).toBe(a);
|
||||
}
|
||||
// every App Store locale maps to a real Play code or to none, and back again
|
||||
for (const a of APPLE_LOCALES) { const p = appleToPlay(a); if (p) { expect(PLAY_LOCALES).toContain(p); expect(playToApple(p)).toBe(a); } }
|
||||
// bare spellings in fastlane folders
|
||||
expect(appleLocale('ta').code).toBe('ta-IN');
|
||||
expect(appleLocale('sl').code).toBe('sl-SI');
|
||||
expect(appleLocale('ur')).toEqual({ code: 'ur-PK', known: true, alias: 'ur' });
|
||||
expect(playLocale('pa-IN')).toEqual({ code: 'pa', known: true, alias: 'pa-IN' });
|
||||
expect(playLocale('ur-PK').code).toBe('ur');
|
||||
expect(playLocale('bn').code).toBe('bn-BD');
|
||||
expect(playLocale('zu').known).toBe(false);
|
||||
});
|
||||
test('every alias lands on a listed code', async () => {
|
||||
const src = await Bun.file(new URL('../cli/lib/store-locales.ts', import.meta.url)).text();
|
||||
for (const k of [...src.matchAll(/'([A-Za-z-]+)': '[A-Za-z0-9-]+'/g)].map(m => m[1]!)) {
|
||||
const a = appleLocale(k), p = playLocale(k);
|
||||
expect(a.known || p.known).toBe(true);
|
||||
}
|
||||
});
|
||||
test('fastlane supply folders -> Play codes', () => {
|
||||
expect(playLocale('tr-TR')).toEqual({ code: 'tr-TR', known: true });
|
||||
expect(playLocale('iw-IL').known).toBe(true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue