background preloader

Localization

Facebook Twitter

Walkthrough: Globalizing a Date by Using Client Script. The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location. The culture value that is used by the client script is based on the default culture setting provided by the user's browser settings.

Alternatively, it can be set to a specific culture value by using server settings or server code in your application. A culture value provides information about a specific culture (locale). The culture value is a combination of two letters for a language and two letters for a country or region. Examples include es-MX (Spanish Mexico), es-CO (Spanish Columbia), and fr-CA (French Canada). To implement the procedures in your own development environment you need: Visual Studio or Visual Web Developer 2010 Express.An AJAX-enabled ASP.NET Web site. To begin, you will use the language preference settings in the browser to specify how to format a date. To globalize a date based on configuration file settings. Localize text in JavaScript files in ASP.NET. Localize Strings in Javascript. JavaScript string localization done right | Stéphane Caron.

Subscribe to my RSS here. December 1st 2010 I live and work in a bilingual environment and most of the things I work on needs to be localized. While it’s easy to do localization on the server side, it’s not so easy on the client side. There are several solutions available online, but most of the times they are either over-complicated or contains all the languages strings in one file, none of them really cut it for me. Since I’m obsessed with optimization and performance in the things I develop, I tried to come up with the best solution in that sense.

Please note that this method works well if you have a back-end to feed you the localized strings, if you have to do localization that usually means you have some kind of framework running behind the front-end. So basically, I always only include one localized JavaScript file in my projects, let’s call it “localization.php” and here’s a sample: Now if you looked closely, you’ll see the I reference the gettext PHP function. See that? Passive localization in JavaScript — Eli Grey. Today, I created a passive localization JavaScript library named l10n.js. l10n.js is a JavaScript library that enables passive localization through native JavaScript methods, gracefully degrading if the library is not present. You can make Ajax applications, JavaScript libraries, etc. that can be localized but not require l10n.js to function. There is already a placeholder method for all API calls as specified in the ECMAScript specification and is present in all JavaScript engines, so when l10n.js isn’t present, your application works fine.

Demo You can try out the online demo to see l10n.js in action. Usage API documentation can be found in the readme. Localizing strings Calling toLocaleString() on every localizable string can create a lot of extra typing and bloat for sending your JavaScript down the wire. With this helper function, you can start writing l("Your localizable string") instead of "Your localizable string".toLocaleString(). Variable replacement.