vue.js: from internationalization (i18n) to localization (l10n) and back again

What is internationalization?!?

Open Source to the rescue

  • Made by @kazupon a core contributor of vue.js
  • Easy to get started with
  • powerful enough for most use cases (lacks some features like proper pluralization for languages having multiple pluralforms or possibility for gender specific translations)
  • learn more reading the documentation
  • based on i18next: learn once — translate everywhere
  • extendable, powerful i18n features
  • plugins for language detection, loading, caching, …
  • learn more reading the documentation and the i18next documentation for translation functionalities like plural, context, …

From internationalization to localization

After enabling the developers it’s time to enable your localization team to translate your product.

Step 1: Creating a fast translation loop — continuous localization

It’s time for some code — show me your code

<!DOCTYPE html>
<html>
<head>
<script src=”https://unpkg.com/vue/dist/vue.js"></script>
<script src=”https://unpkg.com/vue-i18n/dist/vue-i18n.js"></script>
<script src=”https://unpkg.com/locizer/locizer.min.js"></script>
</head>
// ...
<script>
locizer
.init({
fallbackLng: 'en', // load this if detected lng is not support
referenceLng: 'en', // the source language
projectId: [PROJECTID], // your locize project id
apiKey: [APIKEY] // your locize api key
})
.load('translations', (err, translations, detectedLng) => {
// build message catalog format
var messages = {};
messages[detectedLng] = translations;
// Create VueI18n instance with options
const i18n = new VueI18n({
locale: detectedLng, // set locale
messages: messages, // set locale messages
})
// Create a Vue instance with `i18n` option
new Vue({ i18n }).$mount('#app')
})
</script>
Directly loading translations from the CDN

Time to have new paths sent to locize automatically

// Create VueI18n instance with options
const i18n = new VueI18n({
locale: detectedLng, // set locale
messages: messages, // set locale messages
missing: function(locale, path, vue) {
// pipe to locize - that key will be created for you
locizer.add('translations', path, path);
}

})

The power of true continuous localization

Step 2: Enable translations to be in high quality

InContext editor enabled
<script src="https://unpkg.com/locize-editor/locize-editor.js"></script>
locizeEditor.init({
lng: detectedLng,
defaultNS: 'translations',
referenceLng: 'en',
projectId: [PROJECTID]
})

Summary

--

--

Always in search for the holy grail ;)...loving javascript, node.js, html5, interaction design, usability

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jan Mühlemann

Always in search for the holy grail ;)...loving javascript, node.js, html5, interaction design, usability