2017-04-26 16:03:06 +00:00
|
|
|
import {
|
|
|
|
__,
|
|
|
|
n__,
|
2017-05-03 19:52:18 +00:00
|
|
|
s__,
|
2017-04-26 16:03:06 +00:00
|
|
|
} from '../locale';
|
2017-04-18 13:55:09 +00:00
|
|
|
|
|
|
|
export default (Vue) => {
|
2017-04-26 16:03:06 +00:00
|
|
|
Vue.mixin({
|
|
|
|
methods: {
|
2017-05-03 19:52:18 +00:00
|
|
|
/**
|
|
|
|
Translates `text`
|
|
|
|
|
|
|
|
@param text The text to be translated
|
|
|
|
@returns {String} The translated text
|
|
|
|
**/
|
2017-04-26 16:03:06 +00:00
|
|
|
__(text) { return __(text); },
|
2017-05-03 19:52:18 +00:00
|
|
|
/**
|
|
|
|
Translate the text with a number
|
|
|
|
if the number is more than 1 it will use the `pluralText` translation.
|
|
|
|
This method allows for contexts, see below re. contexts
|
|
|
|
|
|
|
|
@param text Singular text to translate (eg. '%d day')
|
|
|
|
@param pluralText Plural text to translate (eg. '%d days')
|
|
|
|
@param count Number to decide which translation to use (eg. 2)
|
|
|
|
@returns {String} Translated text with the number replaced (eg. '2 days')
|
|
|
|
**/
|
|
|
|
n__(text, pluralText, count) { return n__(text, pluralText, count); },
|
|
|
|
/**
|
|
|
|
Translate context based text
|
|
|
|
Either pass in the context translation like `Context|Text to translate`
|
|
|
|
or allow for dynamic text by doing passing in the context first & then the text to translate
|
2017-05-03 11:02:26 +00:00
|
|
|
|
2017-05-03 19:52:18 +00:00
|
|
|
@param keyOrContext Can be either the key to translate including the context
|
|
|
|
(eg. 'Context|Text') or just the context for the translation
|
|
|
|
(eg. 'Context')
|
|
|
|
@param key Is the dynamic variable you want to be translated
|
|
|
|
@returns {String} Translated context based text
|
|
|
|
**/
|
|
|
|
s__(keyOrContext, key) { return s__(keyOrContext, key); },
|
2017-04-26 16:03:06 +00:00
|
|
|
},
|
|
|
|
});
|
2017-04-18 13:55:09 +00:00
|
|
|
};
|