Skip to content

Instantly share code, notes, and snippets.

Avatar
🐱
I are serious. You now step into my profile.

Ilya Bodrov-Krukowski bodrovis

🐱
I are serious. You now step into my profile.
View GitHub Profile
View Translation.js
loadLocaleFile(locale) {
return import(`@/locales/${locale}.json`)
}
View index.js
import Vue from 'vue'
import VueRouter from 'vue-router'
import i18n from '../i18n'
function load(component) {
// '@' is aliased to src/components
return () => import(`@/views/${component}.vue`)
}
Vue.use(VueRouter)
View main-jquery_i18n.js
$('.lang-switch').click(function(e) {
e.preventDefault();
$.i18n().locale = $(this).data('locale');
update_texts();
});
View demo.json
{
"@metadata": { },
"en": {
"appname-title": "Example Application"
},
"ru": "ru.yml"
}
View demo.js
$.i18n().load({
'en': {
'appname-title': 'Example Application'
},
'ru' : {
'appname-title': 'Демонстрационное приложение'
}
});
View demo.html
<li data-i18n="message-key">Fallback text</li>
View demo.js
var message = "Good day, $1";
$.i18n(message, 'Joe');
View demo.js
var message = "Found $1 {{PLURAL:$1|result|results}}";
$.i18n(message, 1);
var message = "$1 changed {{GENDER:$2|his|her}} profile picture";
$.i18n(message, 'Emma', 'female');
View demo.js
$.i18n({
locale: 'de'
});
// or
$.i18n().locale = 'de';
View demo.html
<html lang="en" dir="ltr">