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.

README.md 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. # Internationalization (i18n)
  2. ## Introduction
  3. This directory contains the internationalization (i18n) files for this project.
  4. ## File Structure
  5. ```
  6. ├── [ 24] README.md
  7. ├── [ 704] en-US
  8. │   ├── [2.4K] app-annotation.ts
  9. │   ├── [5.2K] app-api.ts
  10. │   ├── [ 16K] app-debug.ts
  11. │   ├── [2.1K] app-log.ts
  12. │   ├── [5.3K] app-overview.ts
  13. │   ├── [1.9K] app.ts
  14. │   ├── [4.1K] billing.ts
  15. │   ├── [ 17K] common.ts
  16. │   ├── [ 859] custom.ts
  17. │   ├── [5.7K] dataset-creation.ts
  18. │   ├── [ 10K] dataset-documents.ts
  19. │   ├── [ 761] dataset-hit-testing.ts
  20. │   ├── [1.7K] dataset-settings.ts
  21. │   ├── [2.0K] dataset.ts
  22. │   ├── [ 941] explore.ts
  23. │   ├── [ 52] layout.ts
  24. │   ├── [2.3K] login.ts
  25. │   ├── [ 52] register.ts
  26. │   ├── [2.5K] share.ts
  27. │   └── [2.8K] tools.ts
  28. ├── [1.6K] i18next-config.ts
  29. ├── [ 634] index.ts
  30. ├── [4.4K] language.ts
  31. ```
  32. We use English as the default language. The i18n files are organized by language and then by module. For example, the English translation for the `app` module is in `en-US/app.ts`.
  33. If you want to add a new language or modify an existing translation, you can create a new file for the language or modify the existing file. The file name should be the language code (e.g., `zh-Hans` for Chinese) and the file extension should be `.ts`.
  34. For example, if you want to add french translation, you can create a new folder `fr-FR` and add the translation files in it.
  35. By default we will use `LanguagesSupported` to determine which languages are supported. For example, in login page and settings page, we will use `LanguagesSupported` to determine which languages are supported and display them in the language selection dropdown.
  36. ## Example
  37. 1. Create a new folder for the new language.
  38. ```
  39. cd web/i18n
  40. cp -r en-US id-ID
  41. ```
  42. 2. Modify the translation files in the new folder.
  43. 1. Add type to new language in the `language.ts` file.
  44. ```typescript
  45. export type I18nText = {
  46. 'en-US': string
  47. 'zh-Hans': string
  48. 'pt-BR': string
  49. 'es-ES': string
  50. 'fr-FR': string
  51. 'de-DE': string
  52. 'ja-JP': string
  53. 'ko-KR': string
  54. 'ru-RU': string
  55. 'it-IT': string
  56. 'uk-UA': string
  57. 'id-ID': string
  58. 'tr-TR': string
  59. 'YOUR_LANGUAGE_CODE': string
  60. }
  61. ```
  62. 4. Add the new language to the `language.json` file.
  63. ```typescript
  64. export const languages = [
  65. {
  66. value: 'en-US',
  67. name: 'English(United States)',
  68. example: 'Hello, Dify!',
  69. supported: true,
  70. },
  71. {
  72. value: 'zh-Hans',
  73. name: '简体中文',
  74. example: '你好,Dify!',
  75. supported: true,
  76. },
  77. {
  78. value: 'pt-BR',
  79. name: 'Português(Brasil)',
  80. example: 'Olá, Dify!',
  81. supported: true,
  82. },
  83. {
  84. value: 'es-ES',
  85. name: 'Español(España)',
  86. example: 'Saluton, Dify!',
  87. supported: false,
  88. },
  89. {
  90. value: 'fr-FR',
  91. name: 'Français(France)',
  92. example: 'Bonjour, Dify!',
  93. supported: false,
  94. },
  95. {
  96. value: 'de-DE',
  97. name: 'Deutsch(Deutschland)',
  98. example: 'Hallo, Dify!',
  99. supported: false,
  100. },
  101. {
  102. value: 'ja-JP',
  103. name: '日本語 (日本)',
  104. example: 'こんにちは、Dify!',
  105. supported: false,
  106. },
  107. {
  108. value: 'ko-KR',
  109. name: '한국어 (대한민국)',
  110. example: '안녕, Dify!',
  111. supported: true,
  112. },
  113. {
  114. value: 'ru-RU',
  115. name: 'Русский(Россия)',
  116. example: ' Привет, Dify!',
  117. supported: false,
  118. },
  119. {
  120. value: 'it-IT',
  121. name: 'Italiano(Italia)',
  122. example: 'Ciao, Dify!',
  123. supported: false,
  124. },
  125. {
  126. value: 'th-TH',
  127. name: 'ไทย(ประเทศไทย)',
  128. example: 'สวัสดี Dify!',
  129. supported: false,
  130. },
  131. {
  132. value: 'id-ID',
  133. name: 'Bahasa Indonesia',
  134. example: 'Halo, Dify!',
  135. supported: true,
  136. },
  137. {
  138. value: 'uk-UA',
  139. name: 'Українська(Україна)',
  140. example: 'Привет, Dify!',
  141. supported: true,
  142. },
  143. // Add your language here 👇
  144. ...
  145. // Add your language here 👆
  146. ]
  147. ```
  148. 5. Don't forget to mark the supported field as `true` if the language is supported.
  149. 1. Sometime you might need to do some changes in the server side. Please change this file as well. 👇
  150. https://github.com/langgenius/dify/blob/61e4bbabaf2758354db4073cbea09fdd21a5bec1/api/constants/languages.py#L5
  151. ## Clean Up
  152. That's it! You have successfully added a new language to the project. If you want to remove a language, you can simply delete the folder and remove the language from the `language.ts` file.
  153. We have a list of languages that we support in the `language.ts` file. But some of them are not supported yet. So, they are marked as `false`. If you want to support a language, you can follow the steps above and mark the supported field as `true`.