-
Notifications
You must be signed in to change notification settings - Fork 171
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
Using 'Lang' class with Vue.js #89
Comments
This is related to how the template is defined. I think this is related to another existing issue. I will check it later, since I'm in the hospital right now. |
This one will be deal with #63 |
My solution to that problem is to use the command without including
// Inside my /resources/assets/js/lang.js
import lang from 'lang.js';
import messages from 'js/messages';
const Lang = new lang({
messages
});
export default Lang;
import Lang from `js/lang`; // ES6, with webpack configured to resolve `js => /resources/assets/js`
var Lang = require('path/to/your/lang.js'); // Alternatively
Lang.get('my.translation');
// ... |
Even simpler solution: Add this filter to Vue: Vue.filter('trans', (...args) => {
return Lang.get(...args);
}); Then you can do stuff like this: {{ 'messages.home' | trans }} or: {{ 'messages.welcome' | trans({ name: 'Joe' }) }} |
@josiasmontag Awesome! Thanks for the tip! |
Testing just like michgeek showed I get to catch the message object with |
returns But functions are not avaiable. Returns same as in comment above. Wasted couple of hours, it seems package does not work with Vue. |
Hi @PhPPgAdminBug! Try creating an instance: var lang = new window.Lang;
alert(lang.get('my.trans_word'); |
@rmariuzzo This package, has same issue. |
Figured that returns But: is always FALSE, while messages path to file is right, and there are all messages Also, this one part of code will not work const Lang = new lang({ export default Lang;` Because it imports node_modules files. If we put messages files to assets/js, it will throw MIX errors, errors, and errors again. |
@PhPPgAdminBug the |
The original reported issue will be tracked at: #63 |
It so happens that I can't import the 'Lang' class in my Vue component; I receive a ReferenceError. Any help would be appreciated.
The text was updated successfully, but these errors were encountered: