i18next japanese plural test
i18next japanese plural test
by Csaba Hellinger
HTML
<script src="https://unpkg.com/i18next/dist/umd/i18next.min.js"></script>
<p>Check the console log to see the output.</p>
JavaScript
(async function() {
await i18next.init({
compatibilityJSON: 'v3',
interpolation: {
prefix: '__',
suffix: '__',
},
resources: {
en: {
translation: {
hello: 'First month',
hello_plural: 'First __count__ months',
}
},
ja: {
translation: {
hello: 'First __count__ month',
}
}
}
});
await i18next.changeLanguage('en');
console.log(i18next.t('hello', { count: 1 })); // First month
console.log(i18next.t('hello', { count: 3 })); // First 3 months
await i18next.changeLanguage('ja');
console.log(i18next.t('hello', { count: 1 })); // First 1 month
console.log(i18next.t('hello', { count: 3 })); // First 3 month
}());