Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.
TypeScript cloud-alternativecollaborationcollaborative-editingdropboxfile-serverfile-sharingfile-storagefile-syncfull-text-searchhomelabnextcloudon-premiseopen-sourceprivacy-firstprivate-cloudrealtimesecureself-hostedstorage-serverwebdav
chore(i18n): update CONTRIBUTING.md and simplify i18n declarations
johavendcf57c4ea179
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex b6b3ea40..78e6f71e 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -139,6 +139,46 @@ npm -w backend run start:dev- Prefer clear naming and documentation within your code- Document significant architectural changes and updates+## i18n Translations++All translation files follow the same structure:++- **Key**: the original text in **English** (used as the reference in the code)+- **Value**: the translated text in the target language++### Translation Locations++Translations must be added or updated in the following directories.++#### Backend++Used for **notifications** and **emails**.++To declare a new language:++1. Edit `backend/src/common/i18n.ts` and add the language code to the `LANG_SUPPORTED` constant.+2. Create a new language file in `backend/src/applications/notifications/i18n/` named `language_region.ts` (lowercase, with an underscore separating+ the region).+3. Import the new file in `backend/src/applications/notifications/i18n/index.ts`, like the other languages, and add it to the `translations` variable.++#### Frontend++Used for the **web user interface**.++To declare a new language:++1. Edit `frontend/src/i18n/l10n.ts` and add the language code and language name to the `i18nLanguageText` variable.+2. Create a new language file in `frontend/src/i18n` named `language-region.json`, using the same language code declared previously.+3. Import the *ngx-bootstrap* locale in `frontend/src/i18n/lib/bs.i18n.ts`. Check if the locale exists in:+ https://github.com/valor-software/ngx-bootstrap/tree/development/src/chronos/i18n+4. Import *day.js* locale in `frontend/src/i18n/lib/dayjs.i18n.ts`. Check if the locale exists in:+ https://github.com/iamkun/dayjs/tree/dev/src/locale++> [!TIP]+> English is the default language used in the codebase.+> Since translation keys are written in English, the English translation file may be missing or incomplete. This is expected.+> Any other translation file can be used as a reference for the structure.+## Troubleshooting- **Backend:** Check API logs for errors. Use your browser to test endpoints.diff --git a/backend/src/common/i18n.ts b/backend/src/common/i18n.tsindex d1ee16ce..35060305 100644--- a/backend/src/common/i18n.ts+++ b/backend/src/common/i18n.ts@@ -1,6 +1,6 @@export const LANG_DEFAULT = 'en' as const-export type i18nLocaleSupported = 'de' | 'en' | 'es' | 'fr' | 'hi' | 'it' | 'ja' | 'ko' | 'pl' | 'pt' | 'pt-BR' | 'ru' | 'tr' | 'zh'-export const LANG_SUPPORTED = new Set<i18nLocaleSupported>(['de', 'en', 'es', 'fr', 'hi', 'it', 'ja', 'ko', 'pl', 'pt', 'pt-BR', 'ru', 'tr', 'zh'])+export const LANG_SUPPORTED = new Set(['de', 'en', 'es', 'fr', 'hi', 'it', 'ja', 'ko', 'pl', 'pt', 'pt-BR', 'ru', 'tr', 'zh'] as const)+export type i18nLocaleSupported = typeof LANG_SUPPORTED extends Set<infer T> ? T : neverexport type i18nLocale = Exclude<i18nLocaleSupported, typeof LANG_DEFAULT>export function normalizeLanguage(language: string): i18nLocaleSupported | null {diff --git a/frontend/src/i18n/l10n.ts b/frontend/src/i18n/l10n.tsindex eb8e9ca2..b6fa8f58 100755--- a/frontend/src/i18n/l10n.ts+++ b/frontend/src/i18n/l10n.ts@@ -39,8 +39,14 @@ export const i18nLanguageText: Record<i18nLocaleSupported | typeof USER_LANGUAGEzh: '中文(简体) '}+type L10nSchema = { locale: { language: i18nLocaleSupported }; dir: 'ltr' | 'rtl' }[]++const LANG_SCHEMA: L10nSchema = (Object.keys(i18nLanguageText) as (keyof typeof i18nLanguageText)[])+ .filter((language): language is i18nLocaleSupported => language !== USER_LANGUAGE_AUTO)+ .map((language) => ({ locale: { language }, dir: 'ltr' as const }))+export const l10nConfig: L10nConfig & {- schema: { locale: { language: i18nLocaleSupported }; dir: 'ltr' | 'rtl' }[]+ schema: L10nSchema} = {format: LANG_FORMAT,// Provider without static asset: resources will be loaded through TranslationLoader@@ -49,22 +55,7 @@ export const l10nConfig: L10nConfig & {cache: true,keySeparator: '|',defaultLocale: { language: LANG_DEFAULT },- schema: [- { locale: { language: 'de' }, dir: 'ltr' },- { locale: { language: 'en' }, dir: 'ltr' },- { locale: { language: 'es' }, dir: 'ltr' },- { locale: { language: 'fr' }, dir: 'ltr' },- { locale: { language: 'hi' }, dir: 'ltr' },- { locale: { language: 'it' }, dir: 'ltr' },- { locale: { language: 'ja' }, dir: 'ltr' },- { locale: { language: 'ko' }, dir: 'ltr' },- { locale: { language: 'pl' }, dir: 'ltr' },- { locale: { language: 'pt' }, dir: 'ltr' },- { locale: { language: 'pt-BR' }, dir: 'ltr' },- { locale: { language: 'ru' }, dir: 'ltr' },- { locale: { language: 'tr' }, dir: 'ltr' },- { locale: { language: 'zh' }, dir: 'ltr' }- ]+ schema: LANG_SCHEMA}export function getBrowserL10nLocale(): L10nLocale {