<!--간단 예시-->
<script type="text/javascript" src="https://unpkg.com/i18next/dist/umd/i18next.min.js"></script>
<div>
<h1 id="i18n-text"></h1>
</div>
<div>
<select onchange="change(this.value)">
<option selected value="en">영어</option>
<option value = "ko">한국어</option>
<option value = "ja">일본어</option>
</select>
</div>
<script>
i18next.init({
lng: 'en', // if you're using a language detector, do not define the lng option
debug: true,
resources: {
en: {
translation: {
"key": "hello!!!"
}
},
ko: {
translation: {
"key": "안녕!!!"
}
},
ja: {
translation: {
"key": "こんにちは!!!"
}
}
}
});
function change(value){
i18next.changeLanguage(value);
document.getElementById('i18n-text').innerHTML = i18next.t('key');
}
document.getElementById('i18n-text').innerHTML = i18next.t('key');
</script>