I'm thinking of the best way to localize my website. I am using Laravel, which already has a php localization class, but I will also need to translate some javascript strings
Ideally, I would use a library or translation file which could be editable through Poedit and could used for both javascript and php, but I can't find a solution for that. Is it even possible without having to create a whole new code library?
The solution I thought of until now is far from ideal:
- Use a php localization class for php strings
- Use a javascript localization library for javascript
- Store the language in a cookie which could be read by both ends.
The idea of keeping two separate language files (one for php and one for javascript) does not seem like an elegant solution.
I saw some javascript libraries for laravel, but they require you to compile your library into a javascript array file every time you update something, which would make it not very dynamic and also redundant, since most php strings won't be used in javascript and vice-versa.
Any thoughts on this?