Localizable java script

  • Thread starter Thread starter Gawel
  • Start date Start date
G

Gawel

Hajo,

I have app.js file where I store all my java script functions. I am
wondering how to localize it.
I can create second file like app_de.js and switch these two guys
manually but maybe there is other possibility that allows me preserve
one file?

thanks

Pawel Pabich
 
Hi,
Hajo,

I have app.js file where I store all my java script functions. I am
wondering how to localize it.
I can create second file like app_de.js and switch these two guys
manually but maybe there is other possibility that allows me preserve
one file?

thanks

Pawel Pabich

The way I do it, I create and register (on the server) a script
containing client-side variables with the strings, which I fetched from
resource files.

Example:

String initializeStrings = "<script type=\"text/javascript\">"
+ "var TEXT_ALERT = \""
+ Utilities.CResourceFactory.GetString( typeof( BrowserPage ), "alert" )
+ "\";"
+ "</script>";
this.RegisterClientScriptBlock( "initializeScript", initializeStrings );

In reality it's a bit more sophisticated than that.

NB: The CResourceFactory is using a ResourceManager to get the actual
string.

I use the same technique to initialize all server-dependant client-side
variables, constants, etc...

HTH,
Laurent
 
Yes, that's next possible solutin I'm wondering if there is something
built in asp.net that supports this case?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top