You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
3.1 KiB

3 weeks ago
  1. ---
  2. title: "Translations"
  3. description: Guide to translaitng the language.
  4. icon: "globe"
  5. ---
  6. WealthMentor has translations across a variety of languages thanks to the help of many contributors such as @Cs4K1Sr4C.
  7. languages. We're always looking to improve our translations however, if you notice something is off or missing, please
  8. feel free to make the necessary updates or submit a ticket on GitHub!
  9. ## Translating the Frontend
  10. We use i18next to handle our frontend translations. How it works is we have a folder for each language
  11. in [next/public/locales](https://github.com/reworkd/WealthMentor/tree/main/next/public/locales).
  12. ```bash title="next/public/locales"
  13. > en
  14. > fr
  15. > hu
  16. ...
  17. > zh
  18. ```
  19. For each component within the app, we namespace their translations. For example, our ChatWindow uses the `chat` name
  20. space and its translations will be found in the `chat.json` under each folder. Translations are key value pairs where
  21. the key represents the
  22. desired text and the value represents the translation for a given langauge.
  23. An example from the `chat` namespace:
  24. - English: `"EMBARKING_ON_NEW_GOAL": "Embarking on a new goal:"`
  25. - Spanish:`"EMBARKING_ON_NEW_GOAL": "Embarcándose en un nuevo objetivo:"`
  26. #### Adding a new langauge
  27. To add a new language, go into our i18 config and add a new locale
  28. ```bash title="next/next-i18next.config.js"
  29. i18n: {
  30. defaultLocale: "en",
  31. locales:
  32. [
  33. "en",
  34. "hu",
  35. ...,
  36. "sk",
  37. "hr",
  38. "tr",
  39. // Insert new language code here
  40. ],
  41. ...
  42. ```
  43. Then head over to our languages definition and add a section to the available languages list
  44. ```tsx title="next/src/utils/languages.ts"
  45. export const availableLanguages: Language[] = [
  46. ENGLISH,
  47. { code: "fr", name: "Français", flag: "🇫🇷" },
  48. // ...
  49. { code: "tr", name: "Türkçe", flag: "🇹🇷" },
  50. // Insert new language here
  51. ];
  52. ```
  53. After this, you must create a new folder with your langauge code
  54. in [next/public/locales](https://github.com/reworkd/WealthMentor/tree/main/next/public/locales) and add translations for all
  55. namespaces of our app. Note these values may not hot reload, so you must manually restart your next server.
  56. ## Translating the Backend
  57. The backend translations are handled via the model itself.
  58. We simply prompt it to provide the answer in the user selected langauge.
  59. This means that whenever a new frontend language is added, the language is immediately supported on the backend!
  60. This does however mean that we don't currently have much room to actually edit the translations provided by the model.
  61. ## Translating the Readme
  62. We have a few README translations that live in [main/docs](https://github.com/reworkd/WealthMentor/tree/main/docs) such
  63. as `README.zh-HANS.md`. If you'd like to translate the README to your language, make a similar file.
  64. After doing this, add a link badge to our main english README alongside the other badges. Example:
  65. <a href="https://github.com/reworkd/WealthMentor/blob/master/README.md">
  66. <img src="https://img.shields.io/badge/lang-English-blue.svg" alt="English" />
  67. </a>
  68. ## Translating our Documentation
  69. This documentation is very experimental. Because of this, we have no plans to support translation just yet.