From bb0b09075405df1f7f40c4edb3cf641b51812eea Mon Sep 17 00:00:00 2001 From: Wendel Fabiano Ribeiro da Silva Date: Mon, 2 Mar 2026 21:48:20 +0000 Subject: [PATCH 1/2] docs: document how to add a new language Adds a short guide explaining how to add a new locale, including required changes in context.tsx and types.ts. References the commit that introduced the pt locale as an example. On branch docs/add-language-guide Changes to be committed: modified: README.md --- README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/README.md b/README.md index 8f58560..ef15eae 100644 --- a/README.md +++ b/README.md @@ -9,3 +9,37 @@ Understand how joins work by interacting and see it visually * `cd Visual-JOIN` * `npm install` * `npm run dev` + + + +## Adding a new language + +To add a new language (example: `pt`): + +1. Create a file under `src/i18n/locales/` (see `pt.ts` as an example). +2. Implement all required keys from the `Translations` type. +3. Add a case in `loadLocale` inside `context.tsx` for lazy loading: + +```ts +case 'pt': + return (await import('./locales/pt')).default +``` + +4. Allow the locale in `getSavedLocale()` inside `context.tsx` (add it to the supported locale list). + +5. Add the locale to the `Locale` type and the `LOCALES` object in `types.ts`: + +```ts +export type Locale = 'en' | 'es' | 'fr' | 'de' | 'sv' | 'pt' + +export const LOCALES = { + ... + pt: 'Português', +} +``` + +Each locale is lazy-loaded automatically. + +For a complete reference implementation, see the commit that introduced the `pt` locale: + +https://github.com/spathon/Visual-JOIN/commit/7d6ffdcdfbd95215f47b09d6b04070e837b09226 \ No newline at end of file From 5f505ae2f210a3ecad48d123ec199fb1345e422f Mon Sep 17 00:00:00 2001 From: Wendel Fabiano Ribeiro da Silva Date: Wed, 4 Mar 2026 21:28:15 +0000 Subject: [PATCH 2/2] docs: update lng guide after i18n simplification Adjust the README guide for adding new languages after the i18n simplification. Removes the step requiring changes in context.tsx and updates the reference link to the PR that introduced the Portuguese locale. On branch docs/add-language-guide Your branch is up to date with 'origin/docs/add-language-guide'. Changes to be committed: modified: README.md --- README.md | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index ef15eae..d709def 100644 --- a/README.md +++ b/README.md @@ -14,32 +14,18 @@ Understand how joins work by interacting and see it visually ## Adding a new language -To add a new language (example: `pt`): +To add a new language: 1. Create a file under `src/i18n/locales/` (see `pt.ts` as an example). -2. Implement all required keys from the `Translations` type. -3. Add a case in `loadLocale` inside `context.tsx` for lazy loading: - -```ts -case 'pt': - return (await import('./locales/pt')).default -``` -4. Allow the locale in `getSavedLocale()` inside `context.tsx` (add it to the supported locale list). +2. Implement all required keys from the `Translations` type. -5. Add the locale to the `Locale` type and the `LOCALES` object in `types.ts`: +3. Register the locale in `src/i18n/types.ts`: ```ts -export type Locale = 'en' | 'es' | 'fr' | 'de' | 'sv' | 'pt' +export const SUPPORTED_LOCALES = ['en', 'es', 'fr', 'de', 'sv', 'pt'] as const export const LOCALES = { ... pt: 'Português', -} -``` - -Each locale is lazy-loaded automatically. - -For a complete reference implementation, see the commit that introduced the `pt` locale: - -https://github.com/spathon/Visual-JOIN/commit/7d6ffdcdfbd95215f47b09d6b04070e837b09226 \ No newline at end of file +} \ No newline at end of file