Common localization for asp.net, javascript and silverlight?
How do you localize ASP.NET + javascript + Silverlight?
I would like to be able to include the same texts in different languages ββin asp.net pages, javascript in the page, and Silverlight objects in the page.
I have tried with the following method, but I have no experience in practice and I would like to hear your opinion or alternatives:
1) Create a class library ( ResourcesTest
) and add a resource file ( Phrases.resx
) with some lines ( Hello='Hello'
) plus a localized version ( Phrases.da.resx: Hello='Hej'
).
2) Add empty javascript file ( PhrasesHandler.js
).
3) In AssemblyInfo.cs, do this so the texts can be used by javascript / Silverlight:
[assembly: WebResource ("ResourcesTest.PhrasesHandler.js", "application / x-javascript")] [assembly: ScriptResource ("ResourcesTest.PhrasesHandler.js", "ResourcesTest.Phrases", "Phrases")]
4) Referencing a resource from ASP.NET code ( ResourcesTest.Phrases.Hello
) or including an embedded javascript resource in a web page:
<asp: ScriptManager ID = "sm1" runat = "server"> <Scripts> <asp: ScriptReference Assembly = "ResourcesTest" Name = "ResourcesTest.PhrasesHandler.js" /> </Scripts> </ asp: ScriptManager>
and then access the texts from javascript (for example Phrases.Hello
) or from Silverlight via javascript ( HtmlPage.Window.Eval("Phrases.Hello")
).
I find this method quite complicated and I am worried about working with such a system, but have not found any other way to share localized / multilingual resources between ASP.NET, javascript and Silverlight.
You have? How do you localize ASP.NET + javascript + Silverlight?
source to share