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.

пре 2 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # Frontend i18n modification
  2. ## Backend i18n modification
  3. `api/libs/helper.py:117` Add corresponding language support. Such as:
  4. ```python
  5. def supported_language(lang):
  6. if lang in ['en-US', 'zh-Hans', 'de', 'de-AT']:
  7. return lang
  8. ```
  9. ## Adding multiple language files
  10. Add multilingual files for different modules under web/i18n/lang. The file name is Module name.{LANG}.ts. Please refer [LANG](https://www.venea.net/web/culture_code) for details.
  11. ## Introducing a newly added multilingual file
  12. Introduce the newly added multilingual file in the resources object in web/i18n/i18next-config.ts. For example:
  13. ```javascript
  14. const resources = {
  15. 'en': {...},
  16. 'zh-Hans': {...},
  17. _// Introduce the newly added language_
  18. 'new LANG': {
  19. translation: {
  20. common: commonNewLan,
  21. layout: layoutNewLan,
  22. ...
  23. }
  24. }
  25. }
  26. ```
  27. ## Changes in the translation process
  28. ### Multi-language processing of date formatting
  29. Currently, two files are involved in date formatting in multiple languages:
  30. ```javascript
  31. 1. web/app/components/header/account-setting/members-page/index.tsx
  32. _// Line 78_
  33. {dayjs(Number((account.last_login_at || account.created_at)) * 1000).locale(locale === 'zh-Hans' ? 'zh-cn' : 'en').fromNow()}
  34. 2. web/app/components/develop/secret-key/secret-key-modal.tsx
  35. _// Line 82_
  36. const formatDate = (timestamp: any) => {
  37. if (locale === 'en') {
  38. return new Intl.DateTimeFormat('en-US', { year: 'numeric', month: 'long', day: 'numeric' }).format((+timestamp) * 1000)
  39. } else {
  40. return new Intl.DateTimeFormat('fr-CA', { year: 'numeric', month: '2-digit', day: '2-digit' }).format((+timestamp) * 1000)
  41. }
  42. }
  43. ```
  44. Make corresponding changes based on requirements.
  45. ### Handling translation content with variables
  46. There will be variables in the translation, and the value of the variables will be replaced at runtime. Variables in translation will be wrapped in {{ and }}.
  47. When translating content with variables:
  48. 1. Do not change the variable name. That is: the variable name does not need to be translated.
  49. 2. Ensure that the statement remains smooth after the variable is filled.
  50. Find all translations with variables: search for {{ under ./web/i18n/lang.
  51. ### Translation content is too long to destroy UI
  52. If a certain translation content is much longer than other languages, check if it will destroy the UI.
  53. ## Help documentation
  54. The current logic for adjusting the help documentation is: Chinese jumps to Chinese, other languages jump to English. If the help documentation is also multilingual, changes need to be made in this area.
  55. ## Verification
  56. It is recommended to verify the newly added language pack through local deployment of the latest code. For reference: https://docs.dify.ai/getting-started/install-self-hosted/local-source-code
  57. Verification points:
  58. 1. Whether the initial installation has new language drop-down options, and whether the new language can be used for initialization
  59. 2. Whether there is a new language drop-down option in personal settings, and whether the new language can be selected and saved
  60. 3. Whether the text in the interface is displayed in the new language, and whether the text destroys the UI
  61. 4. Whether the content created from the template is all in the new language
  62. 5. (CLOUD version) After logging in through OAuth authorization, whether the current browser language is set directly as the interface language