Skip to content

Commit 2b6949c

Browse files
committed
docs: enhance contributing guide with detailed testing instructions for i18n package
1 parent b333d8c commit 2b6949c

File tree

5 files changed

+94
-2
lines changed

5 files changed

+94
-2
lines changed

CONTRIBUTING.md

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,93 @@ Add your new language to the translations export file at `packages/i18n/src/tran
220220
export {default as fr_FR} from './fr-FR';
221221
```
222222

223-
##### Test your translation
223+
#### Test your translation
224224

225225
Build the package and test the new language in a sample application to ensure all translations are working correctly:
226226

227227
```bash
228228
pnpm build --filter @asgardeo/i18n
229229
```
230230

231+
To test your new language translation, you have two options:
232+
233+
##### Option 1: Using `npm` symlinks
234+
235+
Create a symlink to test your local changes without publishing:
236+
237+
```bash
238+
# Navigate to the i18n package
239+
cd packages/i18n
240+
241+
# Create a global symlink
242+
npm link
243+
244+
# Navigate to your test application
245+
cd /path/to/your/test-app
246+
247+
# Link the local i18n package
248+
npm link @asgardeo/i18n
249+
```
250+
251+
For more information about npm symlinks, see the [npm link documentation](https://docs.npmjs.com/cli/v10/commands/npm-link).
252+
253+
##### Option 2: Integrate into an existing sample
254+
255+
Use one of the existing sample applications in the [`samples/`](../samples/) directory:
256+
257+
```bash
258+
# Navigate to a sample app (e.g., teamspace-react)
259+
cd samples/teamspace-react
260+
261+
# Install dependencies
262+
pnpm install
263+
264+
# The sample will automatically use your local i18n package changes
265+
```
266+
267+
##### Testing with AsgardeoProvider
268+
269+
Once you have your testing environment set up (using either option above), configure the AsgardeoProvider to use your new language:
270+
271+
- **Import your new language bundle**
272+
273+
```tsx
274+
import {fr_FR} from '@asgardeo/i18n';
275+
```
276+
277+
- **Configure the AsgardeoProvider with the new language**
278+
279+
```tsx
280+
<AsgardeoProvider
281+
baseUrl={import.meta.env.VITE_ASGARDEO_BASE_URL}
282+
clientId={import.meta.env.VITE_ASGARDEO_CLIENT_ID}
283+
// ... other configuration
284+
preferences={{
285+
i18n: {
286+
language: 'fr-FR',
287+
bundles: {
288+
'fr-FR': fr_FR,
289+
},
290+
},
291+
}}
292+
>
293+
<App />
294+
</AsgardeoProvider>
295+
```
296+
297+
For more details on the i18n preferences interface, see the [`I18nPreferences`](packages/javascript/src/models/config.ts#L232).
298+
299+
- **Verify the translations**
300+
301+
- Navigate through your application's authentication flows
302+
- Check that all UI text appears in your new language
303+
- Verify that buttons, labels, error messages, and other UI elements display the correct translations
304+
- Test different authentication scenarios (sign-in, sign-up, errors) to ensure comprehensive coverage
305+
306+
- **Test text direction (if applicable)**
307+
308+
For right-to-left languages, ensure that the UI layout adjusts correctly based on the `direction` property in your metadata.
309+
231310
##### Update documentation
232311

233312
Update any relevant documentation to mention the newly supported language.

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/teamspace-nextjs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"start": "next start"
1010
},
1111
"dependencies": {
12+
"@asgardeo/i18n": "workspace:^",
1213
"@asgardeo/nextjs": "workspace:^",
1314
"@hookform/resolvers": "^3.9.1",
1415
"@radix-ui/react-accordion": "1.2.2",

samples/teamspace-react/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"preview": "vite preview"
1111
},
1212
"dependencies": {
13+
"@asgardeo/i18n": "workspace:^",
1314
"@asgardeo/react": "workspace:^",
1415
"@asgardeo/react-router": "workspace:^",
1516
"@radix-ui/react-label": "^2.1.7",
@@ -42,4 +43,4 @@
4243
"typescript-eslint": "^8.30.1",
4344
"vite": "^6.3.5"
4445
}
45-
}
46+
}

samples/teamspace-react/src/main.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ createRoot(document.getElementById('root')!).render(
4545
// },
4646
// },
4747
},
48+
// Import the locale file and add it here to enable i18n
49+
// ex: import fr_FR from './i18n/fr-FR.json';
50+
// i18n: {
51+
// language: 'fr-FR',
52+
// bundles: {
53+
// 'fr-FR': fr_FR,
54+
// },
55+
// },
4856
}}
4957
>
5058
<App />

0 commit comments

Comments
 (0)