mirror of
https://github.com/langgenius/dify.git
synced 2025-11-02 11:52:58 +00:00
1.4 KiB
1.4 KiB
library
- i18next
- react-i18next
hooks
- useTranslation
- useGetLanguage
- useI18N
- useRenderI18nObject
impl
- App Boot
- app/layout.tsx load i18n and init context
- use
<I18nServer/>- read locale with
getLocaleOnServer(in node.js)- locale from cookie, or browser request header
- only used in client app init and 2 server code(plugin desc, datasets)
- use
<I18N/>- init i18n context
setLocaleOnClientchangeLanguage(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)
- is
- read locale with
- use
- app/layout.tsx load i18n and init context
- i18n context
locale- current locale code (exeu-US,zh-Hans)i18n- uselesssetLocaleOnClient- used by App Boot and user change language
load i18n resources
- client: i18n/i18next-config.ts
- ns = camalCase(filename)
- ex:
app/components/datasets/create/embedding-process/index.tsxt('datasetSettings.form.retrievalSetting.title')
- server: i18n/server.ts
- ns = filename
- ex:
app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/settings/page.tsxtranslate(locale, 'dataset-settings')
TODO
- ts docs for useGetLanguage
- ts docs for useI18N
- client docs for i18n
- server docs for i18n