[Dev Tip] Localisation with js

Beside loading resource by ajax call, load all resources,… We also can use another approach – which is more traditional by using hidden fields.

With asp.net mvc, typescript, jquery, we can play

1) A general view library

module Hydra.Views {

export class View {
public $Root: JQuery;

// You want innit because you want run construction tasks before beginning the
// behaviour of the view
Init(): void {


GetLocalisation(resourceKey: string): string {
var $localisation = $("#localisation-resource-" + resourceKey);
if ($localisation.length == 0) console.log("Couldn't find localisation hidden div for " + resourceKey + ", you can use the @Html.HiddenLocalisations(\"Key... to make localisation available");
return $localisation.val();

2) on specific view


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s