diff options
author | Phil Hughes <me@iamphill.com> | 2017-04-18 14:55:09 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-04-18 14:55:09 +0100 |
commit | 7963c2c25114e871eb42c0859b6d24fc37437a8a (patch) | |
tree | 490a40d05bc071d93db865c3d46c9407fad33673 /app/assets/javascripts/vue_shared/translate.js | |
parent | 90ba69d224eb7ef3d91332f1b7944c68ad16affd (diff) | |
download | gitlab-ce-7963c2c25114e871eb42c0859b6d24fc37437a8a.tar.gz |
Added Vue filters & directives for translating
Diffstat (limited to 'app/assets/javascripts/vue_shared/translate.js')
-rw-r--r-- | app/assets/javascripts/vue_shared/translate.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/app/assets/javascripts/vue_shared/translate.js b/app/assets/javascripts/vue_shared/translate.js new file mode 100644 index 00000000000..88b7c0bb954 --- /dev/null +++ b/app/assets/javascripts/vue_shared/translate.js @@ -0,0 +1,14 @@ +import locale from '../locale'; + +export default (Vue) => { + Vue.filter('translate', text => locale.gettext(text)); + + Vue.directive('translate', { + bind(el) { + const $el = el; + const text = $el.textContent.trim(); + + $el.textContent = locale.gettext(text); + }, + }); +}; |