nikhilk / scriptsharp

Script# Project - a C# to JavaScript compiler, to power your HTML5 and Node.js web development.
http://scriptsharp.com
Other
658 stars 182 forks source link

Localization using Script# #420

Closed parthangshu closed 10 years ago

parthangshu commented 10 years ago

Hi,

May I request you to provide localization sample using Script#? I believe in this blog localization sample is there. But unfortunately I am not able to find that.

Kindly provide me some sample link or ideas. Many thanks in advance.

Regards, Partha

nikhilk commented 10 years ago

The general idea is add a resx file (say Foo.resx) using the resx template within the script# folder (in the add item dialog). It is important to note that adding a normal resx file will get you into a non-compiling state.

Then for a localized variant, add another resx file (say Foo.hi.resx). This will cause the compiler to build script.js and script.hi.js where the latter will merge neutral locale strings from Foo.resx and overriden strings from Foo.hi.resx.

The compiler simply produces locale-specific scripts. How you decide which script to use at runtime, i.e. serve from your web server/load via script loader (eg. requirejs)/etc to actually localize your app is up to you.

Hope that gets you started.