Open xian107 opened 5 months ago
Please provide a minimal reproducible example repository, not just code snippets.
The page shows K1,doesn't work。i18next::translator: missingKey en translation K1 K1
@adrai excuse me https://github.com/xian107/texti18.git
Your response data is wrong. You need to return only the corresponding translations for an individual namespace and language:
Only: data: { 'K1': "Yes" }
Your response data is wrong. You need to return only the corresponding translations for an individual namespace and language:
Only:
data: { 'K1': "Yes" }
Only: data: { 'K1': "Yes" }
, How to modify the language? The callback does not pass in the CN data.
i18next is responsible for loading the appropriate language and namespace... your custom request method, only needs to return the corresponding language<->namespace data...
i18next::translator: missingKey en translation K1 K1
` import i18next from "i18next"; import { initReactI18next } from "react-i18next"; import LanguageDetector from "i18next-browser-languagedetector"; import backend from "i18next-http-backend"; import axios from "axios"; i18next .use(LanguageDetector) .use(initReactI18next) .use(backend) .init( { backend: { //loadPath: "https:/xxx.json", request: async (options, url, payload, callback) => { const result = await axios.get("https:/xxx.json") if (result.status === 200 && result.data) { callback(null, { status: 200, data: { en: { translation: { 'K1': "YES" } }, zh: { translation: { 'K1': "是" } //translation: result.data["CN"], }, }, }); }
export default i18next `
page
` import {useTranslation} from 'react-i18next';
export default function Home() { const {t} = useTranslation(); return (
) } ` The page shows K1,doesn't work。i18next::translator: missingKey en translation K1 K1