Sails.js: how to use the i18n function in assets / js / files.js

I need to use i18n () in my code inside the assets / js of my sailsjs project. How can i do this?

It looks good in my views, but not in my js, why?

Many thanks.

I have sailsjs@0.10.5

+5
source share
2 answers

I agree with Wesley, but if you do not want all client clients to make transfers. I would suggest writing an Ajax call and using the following:

sails.__({ phrase: 'Good day', locale: 'de' }); 

Then it should be returned as the German version of Good Afternoon. Or you can simply send a key phrase and return all your language translations.

0
source

What I do is download translations from the server and use them on the client side. I never encoded transfers in my assets, and I would not if you were you.

Add a route to retrieve your translations (static json) and parse the client side of JSON. There are many libraries that can help you .

Keep in mind that you can always include translations in an assembly for something like require.js.

+1
source

All Articles