Reputation: 435
I have a web application which caters javascript files
example:
I want to do make customized (some string substitutions) version of this file made available for international traffic under /dynamic/{country}
I wish to dynamically generate these versions of file by doing these string substitution operations. I envisage having a single servlet mapped at "/dynamic". This would take the url(/dynamic/en/static/com/example/file1), find the country code(en) and source file (/static/com/example/file1), and do corresponding translations
Are there are better approaches to help my situation?
Upvotes: 2
Views: 134
Reputation: 49095
It sounds like you are trying to do i18n for javascript.
You need to make it so that your language conversions are stored separately from your code and that your code will pull the correct translated message as opposed to being preprocessed.
That is your code ("sample.js") will pull the translated message. Your translated messages will be stored declaratively (like a big json object with keys, or a properties file) in their own file.
Take a look at http://plugins.jquery.com/project/jquery_i18n_properties which works very similar to how Java does it.
Your approach to the problem is interesting but it is generally not what people do.
Upvotes: 3