Click here to Skip to main content
15,670,482 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Hello everyone! Can anyone help me with localization on javascript in Visual Studio?
I have a simple Visual Studio web application. Programming language is C#. I want to do something like adding 3 javascripts to the page. One in russian, one in english and one in kazakh. For example: <script type="text/javascript" src="englishLanguage.js" /> In "englishLanguage.js" would be all my English variables. And on the page, I would get those variables. However, I wasn't able to do so.

In aspx page in the head, I am adding some scripts.
<script runat="server" type="text/javascript" src="russianLanguage.js" charset="utf-8" > </script>
<script runat="server" type="text/javascript" src="englishLanguage.js" charset="utf-8" > </script>

<script type="text/javascript">
Some function to retrieve the variable from those scripts based on the current culture (englishLanguage.js,russianLanguage.js)

In those scripts lies the simple string: var uilanguage = { someString: "russian string" }; --- for russianLanguage.js

var uilanguage = { someString: "english string" }; --- for englishLanguage.js

Any other example would be helpful!
Please help!

Updated 31-Jan-13 18:52pm
Orcun Iyigun 31-Jan-13 1:23am    
You have to be more SPECIFIC!!!

1 solution

Javascript itself does not require localization.
Just make sure that everything your server sends to the client is Unicode (including .js files).

Hope this helps,
Share this answer
[no name] 31-Jan-13 4:40am    
How do I do it?
Pablo Aliskevicius 31-Jan-13 5:49am    
Most text editors offer an 'encoding' option for files. In Visual Studio, you can see it using File/Save As: there is a combo with encodings there. You can do that for all your Javascript files.
For your ASPX-generated content, you can add a globalization element to your web.config. See; if your machine.config specifies something different than UTF-8, you should specify UTF8 there.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900