rmariuzzo/Laravel-JS-Localization

Initialization Explanation

FFXV opened this issue · 6 comments

FFXV commented

Hi!

I have successfully created the messages.js file.

Now I want to use it. However, "Lang" is not recognized.
E.g., if I take from the documentation the following (not even using messages.js):

var lang = new Lang({
    messages: {
        'en.greetings': {
            'hi': 'Hi'
        },
    }
});

lang.get('greetings.hi');
// > "Hi"

.. I cannot get any output. Actually the script stops there. I guess, I have make an import or something similar.

Thanks for any help!

@FFXV this could be related to #63

How are you consuming the generated JS?

FFXV commented
var lang = new Lang({
    messages: '/public/messages.js',
    locale: 'en',
});

This is in my java script. Now, the browser console says "ReferenceError: Lang is not defined".

FFXV commented

The same with the code I posted some weeks ago. Sorry, I moved.

I had this problem when I passed the generated js through webpack. I changed it to bypass webpack and just output the js file to the public/ directory. I don't know what about webpack makes it break the file, but it apparently does.

Interesting @ameenross, we will need to see what webpack does with these files.

This issue will be tracked along with: #63