diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index b33e7d5662a4e..034fbe0008a62 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -33,6 +33,7 @@ jobs: - 'server/**' - 'openapi/**' - 'web/**' + - 'i18n/**' machine-learning: - 'machine-learning/**' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 064e3c27616f7..52e0ba7b074fa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,6 +30,7 @@ jobs: filters: | web: - 'web/**' + - 'i18n/**' - 'open-api/typescript-sdk/**' server: - 'server/**' diff --git a/docker/docker-compose.dev.yml b/docker/docker-compose.dev.yml index 552b4a8673e69..f2509e0d2f522 100644 --- a/docker/docker-compose.dev.yml +++ b/docker/docker-compose.dev.yml @@ -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: diff --git a/server/Dockerfile b/server/Dockerfile index 5b92311dc91f2..85fda6607e5eb 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -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 diff --git a/web/src/app.d.ts b/web/src/app.d.ts index b13a0c97d59de..ccec3f33d6ef0 100644 --- a/web/src/app.d.ts +++ b/web/src/app.d.ts @@ -28,7 +28,7 @@ interface Element { requestFullscreen?(options?: FullscreenOptions): Promise; } -import type en from '$lib/i18n/en.json'; +import type en from '$lib/en.json'; import 'svelte-i18n'; type NestedKeys = K extends keyof T & string diff --git a/web/src/lib/components/album-page/__tests__/album-card.spec.ts b/web/src/lib/components/album-page/__tests__/album-card.spec.ts index 79136bca02803..8da9fbfd4591f 100644 --- a/web/src/lib/components/album-page/__tests__/album-card.spec.ts +++ b/web/src/lib/components/album-page/__tests__/album-card.spec.ts @@ -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'); }); diff --git a/web/src/lib/constants.ts b/web/src/lib/constants.ts index c94b53239b092..aa1d976b6f44d 100644 --- a/web/src/lib/constants.ts +++ b/web/src/lib/constants.ts @@ -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({}) }, ]; diff --git a/web/src/lib/i18n.spec.ts b/web/src/lib/i18n.spec.ts index 13d926e6473f3..63aae0419c8a5 100644 --- a/web/src/lib/i18n.spec.ts +++ b/web/src/lib/i18n.spec.ts @@ -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); }); } diff --git a/web/src/lib/utils/thumbnail-util.spec.ts b/web/src/lib/utils/thumbnail-util.spec.ts index b4dbec8752477..7fc53f662bf71 100644 --- a/web/src/lib/utils/thumbnail-util.spec.ts +++ b/web/src/lib/utils/thumbnail-util.spec.ts @@ -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'); }); diff --git a/web/svelte.config.js b/web/svelte.config.js index a66f798f318c4..c5c93e5330d13 100644 --- a/web/svelte.config.js +++ b/web/svelte.config.js @@ -19,6 +19,7 @@ const config = { $lib: 'src/lib', '$lib/*': 'src/lib/*', '@test-data': 'src/test-data', + $i18n: '../i18n', }, }, };