default language for application
hello, I need to change the default language for the application from English to Italian. I have already created the new language definition but I can't set the default language. Ho can i do that ?
2 Replies
fascinating-indigo•2y ago
Hey @dannywhiteagile what library are you using?
genetic-orangeOP•2y ago
i18n
I solved this using something like that:
import i18n from "i18next";
import detector from "i18next-browser-languagedetector";
import Backend from "i18next-xhr-backend";
import { initReactI18next } from "react-i18next";
i18n
.use(Backend)
.use(detector)
.use(initReactI18next)
.init({
lng: 'it',
supportedLngs: ["it", "en"],
backend: {
loadPath: "/locales/{{lng}}/{{ns}}.json",
},
ns: ["common"],
defaultNS: "common",
fallbackLng: [ "it", "en"],
});
export default i18n;
lng:'it' is the relevant part