docs: format all md files (#24195)

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
This commit is contained in:
yihong
2025-08-20 13:49:11 +08:00
committed by GitHub
parent 52857eb6b3
commit 4c1ad40f8e
53 changed files with 1039 additions and 976 deletions

View File

@@ -7,6 +7,7 @@ This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next
### Run by source code
Before starting the web frontend service, please make sure the following environment is ready.
- [Node.js](https://nodejs.org) >= v22.11.x
- [pnpm](https://pnpm.io) v10.x
@@ -103,11 +104,9 @@ pnpm run test
```
If you are not familiar with writing tests, here is some code to refer to:
* [classnames.spec.ts](./utils/classnames.spec.ts)
* [index.spec.tsx](./app/components/base/button/index.spec.tsx)
- [classnames.spec.ts](./utils/classnames.spec.ts)
- [index.spec.tsx](./app/components/base/button/index.spec.tsx)
## Documentation

View File

@@ -1,19 +1,18 @@
## library
* i18next
* react-i18next
- i18next
- react-i18next
## hooks
* useTranslation
* useGetLanguage
* useI18N
* useRenderI18nObject
- useTranslation
- useGetLanguage
- useI18N
- useRenderI18nObject
## impl
* App Boot
- App Boot
- app/layout.tsx load i18n and init context
- use `<I18nServer/>`
- read locale with `getLocaleOnServer` (in node.js)
@@ -23,9 +22,9 @@
- init i18n context
- `setLocaleOnClient`
- `changeLanguage` (defined in i18n/i18next-config, also init i18n resources (side effects))
* is `i18next.changeLanguage`
* all languages text is merge & load in FrontEnd as .js (see i18n/i18next-config)
* i18n context
- is `i18next.changeLanguage`
- all languages text is merge & load in FrontEnd as .js (see i18n/i18next-config)
- i18n context
- `locale` - current locale code (ex `eu-US`, `zh-Hans`)
- `i18n` - useless
- `setLocaleOnClient` - used by App Boot and user change language
@@ -33,17 +32,17 @@
### load i18n resources
- client: i18n/i18next-config.ts
* ns = camalCase(filename)
* ex: `app/components/datasets/create/embedding-process/index.tsx`
* `t('datasetSettings.form.retrievalSetting.title')`
- ns = camalCase(filename)
- ex: `app/components/datasets/create/embedding-process/index.tsx`
- `t('datasetSettings.form.retrievalSetting.title')`
- server: i18n/server.ts
* ns = filename
* ex: `app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/settings/page.tsx`
* `translate(locale, 'dataset-settings')`
- ns = filename
- ex: `app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/settings/page.tsx`
- `translate(locale, 'dataset-settings')`
## TODO
* [ ] ts docs for useGetLanguage
* [ ] ts docs for useI18N
* [ ] client docs for i18n
* [ ] server docs for i18n
- [ ] ts docs for useGetLanguage
- [ ] ts docs for useI18N
- [ ] client docs for i18n
- [ ] server docs for i18n

View File

@@ -53,7 +53,7 @@ cp -r en-US fr-FR
2. Modify the translation files in the new folder.
3. Add type to new language in the `language.ts` file.
1. Add type to new language in the `language.ts` file.
```typescript
export type I18nText = {
@@ -163,10 +163,8 @@ export const languages = [
5. Don't forget to mark the supported field as `true` if the language is supported.
6. Sometime you might need to do some changes in the server side. Please change this file as well. 👇
https://github.com/langgenius/dify/blob/61e4bbabaf2758354db4073cbea09fdd21a5bec1/api/constants/languages.py#L5
1. Sometime you might need to do some changes in the server side. Please change this file as well. 👇
https://github.com/langgenius/dify/blob/61e4bbabaf2758354db4073cbea09fdd21a5bec1/api/constants/languages.py#L5
## Clean Up