All Projects → javisperez → Vuetranslate

javisperez / Vuetranslate

Licence: mit
VueJS plugin for translations

Programming Languages

javascript
184084 projects - #8 most used programming language
language
365 projects

Projects that are alternatives of or similar to Vuetranslate

dokuwiki-plugin-translation
Easily setup a multi-language DokuWiki
Stars: ✭ 22 (-73.17%)
Mutual labels:  multilingual, translation
Linguist
Easy multilingual urls and redirection support for the Laravel framework
Stars: ✭ 188 (+129.27%)
Mutual labels:  translation, multilingual
legesher-translations
Home of all the translations for spoken languages into programming language
Stars: ✭ 47 (-42.68%)
Mutual labels:  multilingual, translation
gf-wordnet
A WordNet in GF
Stars: ✭ 15 (-81.71%)
Mutual labels:  multilingual, translation
bible-corpus
A multilingual parallel corpus created from translations of the Bible.
Stars: ✭ 115 (+40.24%)
Mutual labels:  multilingual, translation
Retro Board
Retrospective Board
Stars: ✭ 622 (+658.54%)
Mutual labels:  translation, multilingual
blazor-ui-messages
Localization messages for Telerik UI for Blazor components: https://www.telerik.com/blazor-ui
Stars: ✭ 24 (-70.73%)
Mutual labels:  multilingual, translation
Laravel Translatable
A Laravel package for multilingual models
Stars: ✭ 624 (+660.98%)
Mutual labels:  translation, multilingual
Opendataday
Open Data Day website
Stars: ✭ 70 (-14.63%)
Mutual labels:  translation
Coc Translator
🌸 Translation extension for coc.nvim
Stars: ✭ 77 (-6.1%)
Mutual labels:  translation
Godot Engine.file Editor
A Godot Engine addon that adds a File Editor for multiple file types editing. Create and Write plain text files, configuration files and csv files with custom visualizers and previews. Also supports file translations!
Stars: ✭ 70 (-14.63%)
Mutual labels:  translation
Jovanotti
A fimple tranfcoding library from italian to fome ferious flang
Stars: ✭ 71 (-13.41%)
Mutual labels:  translation
Localizationkit ios
Realtime Dynamic localization translation delivery system for iOS and Mac OSX in Swift. Create and update texts from localization.com without needing to recompile or redeploy. Cocapod for iOS devices (iPad, iPhone, iPod Touch and Mac)
Stars: ✭ 1,206 (+1370.73%)
Mutual labels:  translation
Cosmicos
Sending the lambda calculus into deep space
Stars: ✭ 70 (-14.63%)
Mutual labels:  translation
Developing Ios 11 Apps With Swift
Stanford 公开课,Developing iOS 11 Apps with Swift 字幕翻译
Stars: ✭ 1,237 (+1408.54%)
Mutual labels:  translation
Go Translate
Improved Google Translate interface with asynchronous request and better user experience.
Stars: ✭ 70 (-14.63%)
Mutual labels:  translation
Alfred Dict.cc Workflow
Alfred 3/4 workflow to get translations from dict.cc
Stars: ✭ 69 (-15.85%)
Mutual labels:  translation
Momdo.github.io
Japanese translation of the W3C/WHATWG specification(s).
Stars: ✭ 81 (-1.22%)
Mutual labels:  translation
30 Seconds Zh cn
📙 前端知识精选集,包含 HTML、CSS、JavaScript、React、Node、安全等方面,每天仅需 30 秒。
Stars: ✭ 1,233 (+1403.66%)
Mutual labels:  translation
Skeleton
A ready-to-use CodeIgniter skeleton with tons of new features and a whole new concept of hooks (actions and filters) as well as a ready-to-use and application-free themes and plugins system. Facebook Page: http://bit.ly/2oHzpxC | Facebook Group: http://bit.ly/2o3KOrA. Help me carry on making more free stuff → http://bit.ly/2ppNujE ←
Stars: ✭ 74 (-9.76%)
Mutual labels:  multilingual

VueTranslate

A VueJS (1.x, 2.0+) plugin for basic translations.

What is this?

Is a plugin to handle basic translations for your components, it adds a mixin and a directive to handle it the most comfortable way.

Like Vue-i18n?

Yes and no, Vue-i18n is a great plugin and is a lot more complete than this. This handle translations too, but is a more basic idea and smaller file (is just one file!).

What to expect?

Just translations, it is that simple.

Example

import Vue from 'vue';
import VueTranslate from 'vue-translate-plugin';

Vue.use(VueTranslate);

var myComp = Vue.extend({
	template: `<div>
	        {{ t('Hello World') }}
	        <span v-translate>How are you?</span>
	    </div>`,

    mounted() {
        // Define what language you want to use.
        // This can be called in something like a header with a language selector menu
        // Or any other case, doesn't need to be called in all components, but
        // at least in one, so it sets the global language of the plugin
    	this.$translate.setLang('es_DO');
    },

    // The translations itself, keyed by language or anything else you one
    locales: {
    	es_DO: {
        	'Hello World': 'Hola Mundo',
        	'How are you?': 'Como estás?'
        }
    }
});

var vm = new Vue({
	el: '#app',

	components: {myComp},

	template: `<div>
	    <my-comp></my-comp>
	</div>`
});

Usage

Loading translations

You can do this in three different ways:

  • A locales option in your component:
Vue.component({
	...
	locales: {
		spanish: {
			'hello world': 'hola mundo'
		}
	},
	...
})
  • Inside a component's method:
Vue.component({
	methods: {
		loadMysuperTranslation() {
			this.$translate.setLocales({
				spanish: {
					'hello world': 'hola mundo'
				}
			});
		}
	}
});
  • Globally when loading the plugin:
Vue.use(VueTranslate);

Vue.locales({
	spanish: {
		'hello world': 'hola mundo'
	}
});

Changing the language to use

Use the setLang method of the $translate property, like this:

Vue.component({
	methods: {
		showAppInSpanish() {
			this.$translate.setLang('spanish');
		}
	}
});

Events

You can listen to custom events emitted by the $translate property:

this.$translate.$on('language:changed', language => {
	console.log('The user choose '+language);
})

Parameters

You can use the method textWithParams if you would like to insert parameters in your translation strings.

this.$translate.textWithParams('translation.string', {
  keyA: 'Glenn',
  keyB: 'John'
})

{{ tWithParams('translation.string', { keyA: 'Glenn', keyB: 'John' }) }}

// In locales.js
'translation.string': 'My name is %keyA%. My brother is named %keyB%.'

// Result
'My name is Glenn. My brother is named John.'
language:init

When the first language is set.

language:changed

When the language to use was changed from the previous value.

language:modified

Everytime a language is changed, either is the first time or not.

locales:loaded

When locales are loaded either by any of the 3 options

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].