restrictedinfinity
restrictedinfinity

Reputation: 435

Web application to serve dynamic text substituted files

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

  1. How do i configure servlet to get the url
  2. Read the actual file using relative path

Are there are better approaches to help my situation?

Upvotes: 2

Views: 134

Answers (1)

Adam Gent
Adam Gent

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

Related Questions