Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move weblate translations to root directory #13604

Merged
merged 2 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
- 'server/**'
- 'openapi/**'
- 'web/**'
- 'i18n/**'
machine-learning:
- 'machine-learning/**'

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
filters: |
web:
- 'web/**'
- 'i18n/**'
- 'open-api/typescript-sdk/**'
server:
- 'server/**'
Expand Down
1 change: 1 addition & 0 deletions docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion web/src/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

Expand Down
112 changes: 56 additions & 56 deletions web/src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({}) },
];
Expand Down
4 changes: 2 additions & 2 deletions web/src/lib/i18n.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', '');
Expand All @@ -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);
});
}
Expand Down
2 changes: 1 addition & 1 deletion web/src/lib/utils/thumbnail-util.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

Expand Down
1 change: 1 addition & 0 deletions web/svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const config = {
$lib: 'src/lib',
'$lib/*': 'src/lib/*',
'@test-data': 'src/test-data',
$i18n: '../i18n',
},
},
};
Expand Down
Loading