Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What about directive? #5

Closed
Disorrder opened this issue Sep 15, 2015 · 4 comments
Closed

What about directive? #5

Disorrder opened this issue Sep 15, 2015 · 4 comments

Comments

@Disorrder
Copy link

Please, make it useful like angular-translate. I mean, it's really good to use it by directive and filter

For example,

<span v-translate="error.{{authError}}"></span>

Renders into

<span>Unexpected username!</span>
@kazupon
Copy link
Owner

kazupon commented Sep 16, 2015

Hi @Disorrder !!
Thank you for your comment.

The vue-i18n is inspired by Rails Internationalization API.
http://guides.rubyonrails.org/i18n.html

I think that current translation style is simple than better angular translate style.

Also, it's flexible as in the following code (e.g. inline, computed property and method).
https://jsfiddle.net/kazupon/0wmy4va2/3/

I don't plan to add feature in future.

@Disorrder
Copy link
Author

分かった :D
I've got used to angular syntax and now using Vue for extremely compact MVVM application, this code works fine.
(es6 & jade syntax)

Vue.directive('translate', {
    isLiteral: true,
    update(val) {
        this.el.innerHTML = this.vm.$t(val);
    }
})
span(v-if="error", v-translate="error.{{error}}")

@kazupon
Copy link
Owner

kazupon commented Sep 17, 2015

Yes !
You can extend with custome directive. :)

@airtonix
Copy link

@Disorrder this would have also worked:

<a :v-text="$t('error.' + error)"></a>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants