Files
classroomio/apps/docs-v2/content/docs/contributor-guides/adding-translation-to-code.mdx
T
Adeyemi AdetunjiandRotimi Best 2526f4c227 feat: migrate docs from Nextra to Fumadocs (#606)
* feat: checkpoint

* feat: Migrate docs to Fumadocs

* chore: docs layout

* chore:
- remove home route
- make docs home route
- remove docs prefix

* chore: docs layout

* chore:
- reorder sidebar
- fix home page redirect

* chore: rename package to avoid error during pnpm clean

* chore: remove private and sideEffects properties from package.json

* chore: requested fixes

* feat: update fumadocs layout

* feat: hide theme switch on sidebar

* add /docs

* feat: enhance documentation and layout with new guides and updates

- Added multiple how-to guides for creating courses, exercises, and managing organization settings.
- Updated existing documentation for clarity and consistency, including renaming sections for better navigation.
- Introduced new assets such as logos and favicon for improved branding.
- Modified layout components to enhance user experience and visual appeal.
- Updated package dependencies to include lucide-react for icon usage.

* chore: update pnpm-lock.yaml with dependency version changes

* add favicon

* fix: update links in documentation for consistency

- Corrected the links in the create-exercise and signup guides to ensure they point to the correct paths, enhancing clarity and navigation for users.

* delete docs

---------

Co-authored-by: Rotimi Best <best@classroomio.com>
2025-12-21 13:36:04 +01:00

47 lines
1.9 KiB
Plaintext

---
title: Adding Translation To Your Code - Developer's Guide
description: Developer's guide to adding translations to the code.
---
In this guide, we'll walk through the process of adding translations to your code. This enables multi-translation support on the platform, enhancing the experience for every user.
## Obtain Your RapidAPI Key
Follow these steps:
1. Open your browser and navigate to https://rapidapi.com/hub.
2. Sign up using your GitHub account or email, whichever you prefer.
3. Search for 'Google Translate' then click on the 'Pricing' tab.
4. Choose a subscription plan and return to the 'Endpoints' tab.
5. Focus on the last tab (on your right).
6. Your key is located in the 'headers' object under 'X-RapidAPI-Key'.
7. Go to your `.env` file in the `/apps/dashboard` directory and assign your key to this variable `RAPID_API_KEY`
## Update Your English File
Once you have your API Key, follow these steps to add a translation:
1. Open the English file named `en` located in `apps/dashboard/src/lib/utils/translations/en.json`.
2. Create an object with a name corresponding to the translation you wish to add.
Example: `"tabs": { "profile": "Profile", "landing_page": "Landing Page" }`.
3. Now, navigate to the file where you want to insert the translation.
4. Import the translation function:
```bash
import { t } from '$lib/utils/functions/translations';
```
5. Locate the line where you want to add the translation and use the following syntax: `$t('path to the value in the object')`.
Example: `<p>{$t('tabs.profile')}</p>` (This will output "Profile").
Note: `$t('')` returns a string.
## Run the translate script
Once you've updated the English file, you need to update the other files. To do this, run a command. Firstly ensure you're still in the `/apps/dashboard` directory, then execute:
```zsh title="Terminal"
pnpm run script:translate
```
This command runs a script that updates the other translation files.