Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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