Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

In my views is ok but in my js not, why?

thanks you very much.

I have [email protected]

like image 704
La mujer esponja Avatar asked Nov 09 '22 16:11

La mujer esponja


1 Answers

What I do, is download the translations from the server and use them client side. I never hardcode translations in my assets and I wouldn't if I were you either.

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

Keep in mind that it's always possible to include translations in a build for something like require.js.

like image 149
Wesley Overdijk Avatar answered Nov 15 '22 05:11

Wesley Overdijk