Localize Strings in Javascript

前端 未结 12 1583
长发绾君心
长发绾君心 2020-11-28 05:52

I\'m currently using .resx files to manage my server side resources for .NET.

the application that I am dealing with also allows developers to plugin Ja

12条回答
  •  孤独总比滥情好
    2020-11-28 06:10

    Inspired by SproutCore You can set properties of strings:

    'Hello'.fr = 'Bonjour';
    'Hello'.es = 'Hola';
    

    and then simply spit out the proper localization based on your locale:

    var locale = 'en';
    alert( message[locale] );
    

提交回复
热议问题