From 94123c52bfa84fca0005335a09e520563aa4d494 Mon Sep 17 00:00:00 2001 From: Waled Khatiz Date: Sun, 1 Sep 2024 04:04:44 +1000 Subject: [PATCH] docs: more details in the README-LANGUAGES.md --- messages/README-LANGUAGES.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/messages/README-LANGUAGES.md b/messages/README-LANGUAGES.md index f01d457..8e11526 100644 --- a/messages/README-LANGUAGES.md +++ b/messages/README-LANGUAGES.md @@ -13,7 +13,7 @@ If you do not see a JSON for your language then may add the language by followin ## Adding a language 1. Add the language to the `const SUPPORTED_LANGUAGES = ['en', 'de'];` variable in the `./src/i18n.ts` file. -2. Create a new `.json` file in the `./messages` directory named after the [ISO Language Code](https://www.w3schools.com/tags/ref_language_codes.asp) of the language. +2. Create a new `.json` file in the `./messages` directory named after the [ISO Language Code](https://www.w3schools.com/tags/ref_language_codes.asp) of the language (all lower case so language code es-ES should be es-es.json). 3. Copy the contents of the `en.json` file, make your way down the key-value pairs changing **only the values** to the translated equivalent. ## Usage @@ -75,6 +75,20 @@ Translated: The JSON is organized by the file names in the `/components` directory. Find the `.tsx` file that generates the untranslated text and modify it to use the translated value. +## Wrong Language Code + +It is common to mix up the 'es' language code with the 'es-ES' language code, for example. + +To see the language code that is actually being sent to the server you can do as follows: +1) Set your browser settings to the language you are trying to translate. +2) Open your browser developer tools. +3) Go to the 'Network' tab. +4) Ensure the Network tab is recording traffic (it typically is already recording). +5) Refresh the website and you will see all the requests the browser made to the server. +6) Scroll up to the very first request that was sent when you refreshed and click on it. The details of that request should be displayed. +7) In the 'Headers' tab of the details scroll down to 'Request Headers'. +8) Under 'Request Headers' you will see the 'Accept-Language' header whose value will be the language code(s) being sent by your browser, each with a 'q' value to specify which language code is most preferred. + ### Documentation If the error persists consult the [next-intl documentation](https://next-intl-docs.vercel.app/docs/getting-started).