-
-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
backend request doesn't work #140
Comments
Please provide a minimal reproducible example repository, not just code snippets. |
@adrai excuse me |
Your response data is wrong. Only: |
Only: |
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 (
{t("K1")}
)
}
`
The page shows K1,doesn't work。i18next::translator: missingKey en translation K1 K1
The text was updated successfully, but these errors were encountered: