.json file type for language, Is there a way to use the .yaml file typePlease outline the motivation for the proposal.
Instead of translation.json we could use translation.yaml
depends on the backend loading...https://github.com/i18next/i18next-http-backend#backend-options -> check the parse option (parse yaml)
Thanks, @jamuhl for responding but looks like file with .yaml type is not supporting
for example, I'm trying the below code but it's not working.
import i18n from 'i18next';
import Backend from 'i18next-http-backend';
import LanguageDetector from 'i18next-browser-languagedetector';
import { initReactI18next } from 'react-i18next';
const languages = ['en'];
i18n
.use(Backend)
.use(LanguageDetector)
.use(initReactI18next)
.init({
fallbackLng: 'en',
debug: true,
whitelist: languages,
backend: {
loadPath: '/locales/{{lng}}/{{ns}}.yaml',
},
interpolation: {
escapeValue: false, // not needed for react as it escapes by default
},
});
export default i18n;
In place of .yaml if i put .json then it is working :-1:
like said...have a look at parse option...just changing the loadPath is not enough -> you will have to define how to parse yaml to js object
okay! Thanks @jamuhl it worked. Just need to add more code as below
Reference for other's
import yaml from 'js-yaml';
backend: {
loadPath: '/locales/{{lng}}/{{ns}}.yaml',
parse: function(data) { return yaml.load(data) },
},
Most helpful comment
okay! Thanks @jamuhl it worked. Just need to add more code as below
Reference for other's