summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_shared/translate.js
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2017-04-18 14:55:09 +0100
committerPhil Hughes <me@iamphill.com>2017-04-18 14:55:09 +0100
commit7963c2c25114e871eb42c0859b6d24fc37437a8a (patch)
tree490a40d05bc071d93db865c3d46c9407fad33673 /app/assets/javascripts/vue_shared/translate.js
parent90ba69d224eb7ef3d91332f1b7944c68ad16affd (diff)
downloadgitlab-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.js14
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);
+ },
+ });
+};