Skip to content

Commit

Permalink
chore: update translation docs
Browse files Browse the repository at this point in the history
  • Loading branch information
potts99 committed Nov 8, 2024
1 parent 02cea3c commit 2d511e8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion apps/client/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ module.exports = {
pages: {
"*": ["peppermint"],
},
localeDetection: false,
localeDetection: true,
};
20 changes: 13 additions & 7 deletions apps/docs/pages/translation.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,21 @@ Before you begin, ensure you have the following:
Navigate to the directory where language files are stored. This is typically a folder named `locales` or `i18n`.

```bash
cd path/to/your/project/locales
cd apps/client/locales
```

Create a new file for the language you want to add. For example, to add French, create a file named `fr.json`.

```bash
touch fr.json
touch /fr/peppermint.json
```

2. **Add Translations**

Open the newly created language file and add the necessary translations. Use the existing language files as a reference for the structure.

Copy the contents of the English file and translate it to the new language.

```json
{
"welcome": "Bienvenue",
Expand All @@ -43,22 +45,27 @@ Before you begin, ensure you have the following:
If your project has a configuration file for supported languages (e.g., `config.js` or `i18n.js`), add the new language to the list of supported languages.

```javascript
// config/i18n.js
export const supportedLanguages = ['en', 'fr', 'es'];
// i18n.js
export const supportedLanguages = ["en", "fr", "es"];
```

4. **Test the New Language**

Start your application and switch to the new language to ensure that translations are displayed correctly. This might involve changing a language setting in your application or using a URL parameter.

This requires you to have the application running.

```bash
npm start
yarn install --legacy-peer-deps
cd apps/api && npm run db:migrate
cd ../../
yarn dev --filter=client --filter=api
```

Access the application and switch to French:

```
http://localhost:3000?lang=fr
http://localhost:3000/fr/
```

5. **Update Documentation**
Expand Down Expand Up @@ -91,4 +98,3 @@ If you encounter any issues, consider the following:
---

Feel free to reach out to the project maintainers if you have any questions or need further assistance. Happy localizing!

0 comments on commit 2d511e8

Please sign in to comment.