In the following question on multilingual website design, it is suggested to use a PHP "pre-processor" in order to generate localized PHP files. The generation would only be triggered once, and on each update to underlying content.
https://stackoverflow.com/questions/19249159/best-practice-multi-language-website/19425499#19425499
I am currently adapting a website for localization using this approach, but I'm wondering what suggestions people have for dealing with javascript files within this framework.
I'm working with ASP.NET, so I'm not the PHP Expert. But as in PHP we have resource files (.resx instead of .po) and what we do is automatically add all entries in a certain .resx file to the page as Javascript variables.
So we have all localized files in one place and format. Works well for us.
I saw similar ideas for PHP:
Translation in JavaScript like gettext in PHP?
Maybe there are complete solutions out there, otherwise you just have to build something that would do this:
var var1 = "<?php echo gettext("Var1 text"); ?>";