Browse Source

Adding examples for internationalization

Sébastien Ros 9 years ago
parent
commit
a30fd84509
1 changed files with 21 additions and 0 deletions
  1. 21 0
      README.md

+ 21 - 0
README.md

@@ -109,6 +109,27 @@ Generic types are also supported. Here is how to declare, instantiate and use a
     jint> list.Count; // 2
     jint> list.Count; // 2
 ```
 ```
 
 
+## Internationalization
+
+You can enforce what Time Zone or Culture the engine should use when locale JavaScript methods are used if you don't want to use the computer's default values.
+
+This example forces the Time Zone to Pacific Standard Time.
+```c#
+    var PST = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");
+    var engine = new Engine(cfg => cfg.LocalTimeZone(PST));
+    
+    engine.Execute("new Date().toString()"); // Wed Dec 31 1969 16:00:00 GMT-08:00
+```
+
+This example is using French as the default culture.
+```c#
+    var FR = CultureInfo.GetCultureInfo("fr-FR");
+    var engine = new Engine(cfg => cfg.Culture(FR));
+    
+    engine.Execute("new Number(1.23).toString()"); // 1.23
+    engine.Execute("new Number(1.23).toLocaleString()"); // 1,23
+```
+
 ## Implemented features:
 ## Implemented features:
 
 
 - ECMAScript 5.1 test suite (http://test262.ecmascript.org/) 
 - ECMAScript 5.1 test suite (http://test262.ecmascript.org/)