-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add guide on how to translate admin
- Loading branch information
1 parent
3e26522
commit 1ca3ff8
Showing
6 changed files
with
126 additions
and
59 deletions.
There are no files selected for viewing
49 changes: 0 additions & 49 deletions
49
www/apps/resources/app/contribution-guidelines/_admin-translations/page.mdx
This file was deleted.
Oops, something went wrong.
107 changes: 107 additions & 0 deletions
107
www/apps/resources/app/contribution-guidelines/admin-translations/page.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
export const metadata = { | ||
title: `Translate Medusa Admin`, | ||
} | ||
|
||
# {metadata.title} | ||
|
||
The Medusa Admin supports multiple languages, with the default being English. In this documentation, you'll learn how to contribute to the community by translating the Medusa Admin to a language you're fluent in. | ||
|
||
{/* vale docs.We = NO */} | ||
|
||
You can contribute either by translating the admin to a new language, or fixing translations for existing languages. As we can't validate every language's translations, some translations may be incorrect. Your contribution is welcome to fix any translation errors you find. | ||
|
||
{/* vale docs.We = YES */} | ||
|
||
<Note> | ||
|
||
Check out the translated languages either in the admin dashboard's settings or on [GitHub](https://github.com/medusajs/medusa/blob/develop/packages/admin/dashboard/src/i18n/languages.ts). | ||
|
||
</Note> | ||
|
||
--- | ||
|
||
## How to Contribute Translation | ||
|
||
1. Clone the [Medusa monorepository](https://github.com/medusajs/medusa) to your local machine: | ||
|
||
```bash | ||
git clone https://github.com/medusajs/medusa.git | ||
``` | ||
|
||
If you already have it cloned, make sure to pull the latest changes from the `develop` branch. | ||
|
||
2. Install the monorepository's dependencies. Since it's a Yarn workspace, it's highly recommended to use yarn: | ||
|
||
```bash | ||
yarn install | ||
``` | ||
|
||
3. Create a branch that you'll use to open the pull request later: | ||
|
||
```bash | ||
git check -b feat/translate-<LANGUAGE> | ||
``` | ||
|
||
Where `<LANGUAGE>` is your language name. For example, `feat/translate-da`. | ||
|
||
4. Translation files are under `packages/admin/dashboard/src/i18n/translations` as JSON files whose names are the ISO-2 name of the language. | ||
- If you're adding a new language, copy the file `packages/admin/dashboard/src/i18n/translations/en.json` and paste it with the ISO-2 name for your language. For example, if you're adding Danish translations, copy the `en.json` file and paste it as `packages/admin/dashboard/src/i18n/translations/de.json`. | ||
- If you're fixing a translation, find the JSON file of the language under `packages/admin/dashboard/src/i18n/translations`. | ||
|
||
5. Start translating the keys in the JSON file (or updating the targeted ones). All keys in the JSON file must be translated, and your PR tests will fail otherwise. | ||
- You can check whether the JSON file is valid by running the following command in `packages/admin/dashboard`, replacing `da.json` with the JSON file's name: | ||
|
||
```bash title="packages/admin/dashboard" | ||
yarn i18n:validate da.json | ||
``` | ||
|
||
6. After finishing the translation, if you're adding a new language, import its JSON file in `packages/admin/dashboard/src/i18n/translations/index.ts` and add it to the exported object: | ||
|
||
```ts title="packages/admin/dashboard/src/i18n/translations/index.ts" highlights={[["2"], ["6"], ["7"], ["8"]]} | ||
// other imports... | ||
import da from "./da.json" | ||
|
||
export default { | ||
// other languages... | ||
da: { | ||
translation: da, | ||
}, | ||
} | ||
``` | ||
|
||
The language's key in the object is the ISO-2 name of the language. | ||
|
||
7. If you're adding a new language, add it to the file `packages/admin/dashboard/src/i18n/languages.ts`: | ||
|
||
export const languageHighlights = [ | ||
["7", "code", "The ISO-2 name of the language."], | ||
["8", "display_name", "The language's name to be displayed in the admin."], | ||
["9", "ltr", "Whether the language supports a left-to-right layout."], | ||
["10", "date_locale", "An instance of the locale imported from the [date-fns/locale](https://date-fns.org/) package."] | ||
] | ||
|
||
```ts title="packages/admin/dashboard/src/i18n/languages.ts" highlights={languageHighlights} | ||
import { da } from "date-fns/locale" | ||
// other imports... | ||
|
||
export const languages: Language[] = [ | ||
// other languages... | ||
{ | ||
code: "da", | ||
display_name: "Danish", | ||
ltr: true, | ||
date_locale: da | ||
} | ||
] | ||
``` | ||
|
||
`languages` is an array having the following properties: | ||
|
||
- `code`: The ISO-2 name of the language. For example, `da` for Danish. | ||
- `display_name`: The language's name to be displayed in the admin. | ||
- `ltr`: Whether the language supports a left-to-right layout. For example, set this to `false` for languages like Arabic. | ||
- `date_locale`: An instance of the locale imported from the [date-fns/locale](https://date-fns.org/) package. | ||
|
||
8. Once you're done, push the changes into your branch and open a pull request on GitHub. | ||
|
||
Our team will perform a general review on your PR and merge it if no issues are found. The translation will be available in the admin after the next release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters