1
0
mirror of https://github.com/immich-app/immich.git synced 2024-11-21 18:16:55 +02:00

chore: move weblate translations to root directory (#13604)

* chore: move translations to root directory

* chore: update build processes to work with new i18n location
This commit is contained in:
Ben 2024-10-22 11:39:28 -04:00 committed by GitHub
parent 62e0658e5a
commit e98acc976e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
66 changed files with 66 additions and 61 deletions

View File

@ -33,6 +33,7 @@ jobs:
- 'server/**'
- 'openapi/**'
- 'web/**'
- 'i18n/**'
machine-learning:
- 'machine-learning/**'

View File

@ -30,6 +30,7 @@ jobs:
filters: |
web:
- 'web/**'
- 'i18n/**'
- 'open-api/typescript-sdk/**'
server:
- 'server/**'

View File

@ -66,6 +66,7 @@ services:
- 24678:24678
volumes:
- ../web:/usr/src/app
- ../i18n:/usr/src/i18n
- ../open-api/:/usr/src/open-api/
- /usr/src/app/node_modules
ulimits:

View File

@ -37,6 +37,7 @@ WORKDIR /usr/src/app
COPY web/package*.json web/svelte.config.js ./
RUN npm ci
COPY web ./
COPY i18n ../i18n
RUN npm run build

2
web/src/app.d.ts vendored
View File

@ -28,7 +28,7 @@ interface Element {
requestFullscreen?(options?: FullscreenOptions): Promise<void>;
}
import type en from '$lib/i18n/en.json';
import type en from '$lib/en.json';
import 'svelte-i18n';
type NestedKeys<T, K = keyof T> = K extends keyof T & string

View File

@ -12,7 +12,7 @@ describe('AlbumCard component', () => {
beforeAll(async () => {
await init({ fallbackLocale: 'en-US' });
register('en-US', () => import('$lib/i18n/en.json'));
register('en-US', () => import('$i18n/en.json'));
await waitLocale('en-US');
});

View File

@ -250,79 +250,79 @@ export const locales = [
{ code: 'zu-ZA', name: 'Zulu (South Africa)' },
];
export const defaultLang = { name: 'English', code: 'en', loader: () => import('$lib/i18n/en.json') };
export const defaultLang = { name: 'English', code: 'en', loader: () => import('$i18n/en.json') };
export const langs = [
{ name: 'Afrikaans', code: 'af', loader: () => import('$lib/i18n/af.json') },
{ name: 'Arabic', code: 'ar', loader: () => import('$lib/i18n/ar.json') },
{ name: 'Azerbaijani', code: 'az', loader: () => import('$lib/i18n/az.json') },
{ name: 'Belarusian', code: 'be', loader: () => import('$lib/i18n/be.json') },
{ name: 'Bulgarian', code: 'bg', loader: () => import('$lib/i18n/bg.json') },
{ name: 'Bislama', code: 'bi', loader: () => import('$lib/i18n/bi.json') },
{ name: 'Catalan', code: 'ca', loader: () => import('$lib/i18n/ca.json') },
{ name: 'Czech', code: 'cs', loader: () => import('$lib/i18n/cs.json') },
{ name: 'Chuvash', code: 'cv', loader: () => import('$lib/i18n/cv.json') },
{ name: 'Danish', code: 'da', loader: () => import('$lib/i18n/da.json') },
{ name: 'German', code: 'de', loader: () => import('$lib/i18n/de.json') },
{ name: 'Afrikaans', code: 'af', loader: () => import('$i18n/af.json') },
{ name: 'Arabic', code: 'ar', loader: () => import('$i18n/ar.json') },
{ name: 'Azerbaijani', code: 'az', loader: () => import('$i18n/az.json') },
{ name: 'Belarusian', code: 'be', loader: () => import('$i18n/be.json') },
{ name: 'Bulgarian', code: 'bg', loader: () => import('$i18n/bg.json') },
{ name: 'Bislama', code: 'bi', loader: () => import('$i18n/bi.json') },
{ name: 'Catalan', code: 'ca', loader: () => import('$i18n/ca.json') },
{ name: 'Czech', code: 'cs', loader: () => import('$i18n/cs.json') },
{ name: 'Chuvash', code: 'cv', loader: () => import('$i18n/cv.json') },
{ name: 'Danish', code: 'da', loader: () => import('$i18n/da.json') },
{ name: 'German', code: 'de', loader: () => import('$i18n/de.json') },
defaultLang,
{ name: 'Greek', code: 'el', loader: () => import('$lib/i18n/el.json') },
{ name: 'Spanish', code: 'es', loader: () => import('$lib/i18n/es.json') },
{ name: 'Estonian', code: 'et', loader: () => import('$lib/i18n/et.json') },
{ name: 'Persian', code: 'fa', loader: () => import('$lib/i18n/fa.json') },
{ name: 'Finnish', code: 'fi', loader: () => import('$lib/i18n/fi.json') },
{ name: 'French', code: 'fr', loader: () => import('$lib/i18n/fr.json') },
{ name: 'Hebrew', code: 'he', loader: () => import('$lib/i18n/he.json') },
{ name: 'Hindi', code: 'hi', loader: () => import('$lib/i18n/hi.json') },
{ name: 'Croatian', code: 'hr', loader: () => import('$lib/i18n/hr.json') },
{ name: 'Hungarian', code: 'hu', loader: () => import('$lib/i18n/hu.json') },
{ name: 'Armenian', code: 'hy', loader: () => import('$lib/i18n/hy.json') },
{ name: 'Indonesian', code: 'id', loader: () => import('$lib/i18n/id.json') },
{ name: 'Italian', code: 'it', loader: () => import('$lib/i18n/it.json') },
{ name: 'Japanese', code: 'ja', loader: () => import('$lib/i18n/ja.json') },
{ name: 'Kurdish (Northern)', code: 'kmr', loader: () => import('$lib/i18n/kmr.json') },
{ name: 'Korean', code: 'ko', loader: () => import('$lib/i18n/ko.json') },
{ name: 'Luxembourgish', code: 'lb', loader: () => import('$lib/i18n/lb.json') },
{ name: 'Lithuanian', code: 'lt', loader: () => import('$lib/i18n/lt.json') },
{ name: 'Latvian', code: 'lv', loader: () => import('$lib/i18n/lv.json') },
{ name: 'Malay (Pattani)', code: 'mfa', loader: () => import('$lib/i18n/mfa.json') },
{ name: 'Macedonian', code: 'mk', loader: () => import('$lib/i18n/mk.json') },
{ name: 'Mongolian', code: 'mn', loader: () => import('$lib/i18n/mn.json') },
{ name: 'Marathi', code: 'mr', loader: () => import('$lib/i18n/mr.json') },
{ name: 'Malay', code: 'ms', loader: () => import('$lib/i18n/ms.json') },
{ name: 'Norwegian Bokmål', code: 'nb-NO', weblateCode: 'nb_NO', loader: () => import('$lib/i18n/nb_NO.json') },
{ name: 'Dutch', code: 'nl', loader: () => import('$lib/i18n/nl.json') },
{ name: 'Polish', code: 'pl', loader: () => import('$lib/i18n/pl.json') },
{ name: 'Portuguese', code: 'pt', loader: () => import('$lib/i18n/pt.json') },
{ name: 'Portuguese (Brazil) ', code: 'pt-BR', weblateCode: 'pt_BR', loader: () => import('$lib/i18n/pt_BR.json') },
{ name: 'Romanian', code: 'ro', loader: () => import('$lib/i18n/ro.json') },
{ name: 'Russian', code: 'ru', loader: () => import('$lib/i18n/ru.json') },
{ name: 'Slovak', code: 'sk', loader: () => import('$lib/i18n/sk.json') },
{ name: 'Slovenian', code: 'sl', loader: () => import('$lib/i18n/sl.json') },
{ name: 'Greek', code: 'el', loader: () => import('$i18n/el.json') },
{ name: 'Spanish', code: 'es', loader: () => import('$i18n/es.json') },
{ name: 'Estonian', code: 'et', loader: () => import('$i18n/et.json') },
{ name: 'Persian', code: 'fa', loader: () => import('$i18n/fa.json') },
{ name: 'Finnish', code: 'fi', loader: () => import('$i18n/fi.json') },
{ name: 'French', code: 'fr', loader: () => import('$i18n/fr.json') },
{ name: 'Hebrew', code: 'he', loader: () => import('$i18n/he.json') },
{ name: 'Hindi', code: 'hi', loader: () => import('$i18n/hi.json') },
{ name: 'Croatian', code: 'hr', loader: () => import('$i18n/hr.json') },
{ name: 'Hungarian', code: 'hu', loader: () => import('$i18n/hu.json') },
{ name: 'Armenian', code: 'hy', loader: () => import('$i18n/hy.json') },
{ name: 'Indonesian', code: 'id', loader: () => import('$i18n/id.json') },
{ name: 'Italian', code: 'it', loader: () => import('$i18n/it.json') },
{ name: 'Japanese', code: 'ja', loader: () => import('$i18n/ja.json') },
{ name: 'Kurdish (Northern)', code: 'kmr', loader: () => import('$i18n/kmr.json') },
{ name: 'Korean', code: 'ko', loader: () => import('$i18n/ko.json') },
{ name: 'Luxembourgish', code: 'lb', loader: () => import('$i18n/lb.json') },
{ name: 'Lithuanian', code: 'lt', loader: () => import('$i18n/lt.json') },
{ name: 'Latvian', code: 'lv', loader: () => import('$i18n/lv.json') },
{ name: 'Malay (Pattani)', code: 'mfa', loader: () => import('$i18n/mfa.json') },
{ name: 'Macedonian', code: 'mk', loader: () => import('$i18n/mk.json') },
{ name: 'Mongolian', code: 'mn', loader: () => import('$i18n/mn.json') },
{ name: 'Marathi', code: 'mr', loader: () => import('$i18n/mr.json') },
{ name: 'Malay', code: 'ms', loader: () => import('$i18n/ms.json') },
{ name: 'Norwegian Bokmål', code: 'nb-NO', weblateCode: 'nb_NO', loader: () => import('$i18n/nb_NO.json') },
{ name: 'Dutch', code: 'nl', loader: () => import('$i18n/nl.json') },
{ name: 'Polish', code: 'pl', loader: () => import('$i18n/pl.json') },
{ name: 'Portuguese', code: 'pt', loader: () => import('$i18n/pt.json') },
{ name: 'Portuguese (Brazil) ', code: 'pt-BR', weblateCode: 'pt_BR', loader: () => import('$i18n/pt_BR.json') },
{ name: 'Romanian', code: 'ro', loader: () => import('$i18n/ro.json') },
{ name: 'Russian', code: 'ru', loader: () => import('$i18n/ru.json') },
{ name: 'Slovak', code: 'sk', loader: () => import('$i18n/sk.json') },
{ name: 'Slovenian', code: 'sl', loader: () => import('$i18n/sl.json') },
{
name: 'Serbian (Cyrillic)',
code: 'sr-Cyrl',
weblateCode: 'sr_Cyrl',
loader: () => import('$lib/i18n/sr_Cyrl.json'),
loader: () => import('$i18n/sr_Cyrl.json'),
},
{ name: 'Serbian (Latin)', code: 'sr-Latn', weblateCode: 'sr_Latn', loader: () => import('$lib/i18n/sr_Latn.json') },
{ name: 'Swedish', code: 'sv', loader: () => import('$lib/i18n/sv.json') },
{ name: 'Tamil', code: 'ta', loader: () => import('$lib/i18n/ta.json') },
{ name: 'Telugu', code: 'te', loader: () => import('$lib/i18n/te.json') },
{ name: 'Thai', code: 'th', loader: () => import('$lib/i18n/th.json') },
{ name: 'Turkish', code: 'tr', loader: () => import('$lib/i18n/tr.json') },
{ name: 'Ukrainian', code: 'uk', loader: () => import('$lib/i18n/uk.json') },
{ name: 'Vietnamese', code: 'vi', loader: () => import('$lib/i18n/vi.json') },
{ name: 'Serbian (Latin)', code: 'sr-Latn', weblateCode: 'sr_Latn', loader: () => import('$i18n/sr_Latn.json') },
{ name: 'Swedish', code: 'sv', loader: () => import('$i18n/sv.json') },
{ name: 'Tamil', code: 'ta', loader: () => import('$i18n/ta.json') },
{ name: 'Telugu', code: 'te', loader: () => import('$i18n/te.json') },
{ name: 'Thai', code: 'th', loader: () => import('$i18n/th.json') },
{ name: 'Turkish', code: 'tr', loader: () => import('$i18n/tr.json') },
{ name: 'Ukrainian', code: 'uk', loader: () => import('$i18n/uk.json') },
{ name: 'Vietnamese', code: 'vi', loader: () => import('$i18n/vi.json') },
{
name: 'Chinese (Traditional)',
code: 'zh-TW',
weblateCode: 'zh_Hant',
loader: () => import('$lib/i18n/zh_Hant.json'),
loader: () => import('$i18n/zh_Hant.json'),
},
{
name: 'Chinese (Simplified)',
code: 'zh-CN',
weblateCode: 'zh_SIMPLIFIED',
loader: () => import('$lib/i18n/zh_SIMPLIFIED.json'),
loader: () => import('$i18n/zh_SIMPLIFIED.json'),
},
{ name: 'Development (keys only)', code: 'dev', loader: () => Promise.resolve({}) },
];

View File

@ -4,7 +4,7 @@ import { readFileSync, readdirSync } from 'node:fs';
describe('i18n', () => {
describe('loaders', () => {
const languageFiles = readdirSync('src/lib/i18n').sort();
const languageFiles = readdirSync('../i18n').sort();
for (const filename of languageFiles) {
test(`${filename} should have a loader`, async () => {
const code = filename.replaceAll('.json', '');
@ -17,7 +17,7 @@ describe('i18n', () => {
// verify it loads the right file
const module: { default?: unknown } = await item.loader();
const translations = JSON.stringify(module.default, null, 2).trim();
const content = readFileSync(`src/lib/i18n/${filename}`).toString().trim();
const content = readFileSync(`../i18n/${filename}`).toString().trim();
expect(translations === content, `${item.name} did not load ${filename}`).toEqual(true);
});
}

View File

@ -10,7 +10,7 @@ const fourPeople = [{ name: 'person1' }, { name: 'person2' }, { name: 'person3'
describe('getAltText', () => {
beforeAll(async () => {
await init({ fallbackLocale: 'en-US' });
register('en-US', () => import('$lib/i18n/en.json'));
register('en-US', () => import('$i18n/en.json'));
await waitLocale('en-US');
});

View File

@ -19,6 +19,7 @@ const config = {
$lib: 'src/lib',
'$lib/*': 'src/lib/*',
'@test-data': 'src/test-data',
$i18n: '../i18n',
},
},
};