cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [2/4] cordova-plugin-globalization git commit: CB-7972 Add cordova-plugin-globalization support for Windows platform
Date Tue, 13 Jan 2015 20:03:43 GMT
CB-7972 Add cordova-plugin-globalization support for Windows platform

Added Windows platform support
Moved and refactored wp8 implementation to common code
Updated documentation including more accurate definition of wp8 methods quirks


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/commit/46e575d8
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/tree/46e575d8
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/diff/46e575d8

Branch: refs/heads/master
Commit: 46e575d8f2c32e422ddbb6c8012f281f4ade19dd
Parents: 40ab774
Author: daserge <daserge@yandex.ru>
Authored: Sat Nov 22 14:09:25 2014 +0300
Committer: daserge <daserge@yandex.ru>
Committed: Sat Nov 22 23:51:33 2014 +0300

----------------------------------------------------------------------
 doc/index.md                                    |   86 +-
 plugin.xml                                      |   10 +
 src/windows/GlobalizationProxy.js               |  124 ++
 src/windows/GlobalizationProxy.winmd            |  Bin 0 -> 20992 bytes
 .../GlobalizationProxy/GlobalizationProxy.sln   |   38 +
 .../GlobalizationProxy/.gitignore               |    3 +
 .../Cordova/JSON/JsonHelper.cs                  |   87 ++
 .../Globalization/GlobalizationApiTypes.cs      |  429 +++++++
 .../Globalization/GlobalizationImpl.cs          |  612 ++++++++++
 .../Globalization/SettableCultureInfo.cs        |   36 +
 .../GlobalizationProxy/GlobalizationProxy.cs    |  107 ++
 .../GlobalizationProxy.csproj                   |  130 ++
 .../Properties/AssemblyInfo.cs                  |   29 +
 src/wp/Globalization.cs                         | 1141 +-----------------
 14 files changed, 1738 insertions(+), 1094 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/46e575d8/doc/index.md
----------------------------------------------------------------------
diff --git a/doc/index.md b/doc/index.md
index 35878dd..67279ff 100644
--- a/doc/index.md
+++ b/doc/index.md
@@ -85,6 +85,7 @@ error's expected code is `GlobalizationError.UNKNOWN_ERROR`.
 - Firefox OS
 - iOS
 - Windows Phone 8
+- Windows
 
 ### Example
 
@@ -109,6 +110,12 @@ a hyphen.
 - Note that the regional variant is a property of the "Language" setting and
 not determined by the unrelated "Country/Region" setting on Windows Phone.
 
+### Windows Quirks
+
+- Returns the ISO 639-1 two-letter language code and ISO 3166-1 country code
+of the regional variant corresponding to the "Language" setting, separated by
+a hyphen.
+
 ## navigator.globalization.getLocaleName
 
 Returns the BCP 47 compliant tag for the client's current locale setting.
@@ -135,6 +142,7 @@ error's expected code is `GlobalizationError.UNKNOWN_ERROR`.
 - Firefox OS
 - iOS
 - Windows Phone 8
+- Windows
 
 ### Example
 
@@ -157,6 +165,12 @@ method is essentially the same as `navigator.globalizatin.getPreferredLanguage()
 of the regional variant corresponding to the "Regional Format" setting, separated
 by a hyphen.
 
+### Windows Quirks
+
+- Locale setting can be changed in Control Panel -> Clock, Language and Region 
+-> Region -> Administrative -> Change system locale on Windows 8.1/8.0, 
+and in Settings -> Region -> Regional Format on Windows Phone 8.1.
+
 
 ## navigator.globalization.dateToString
 
@@ -191,6 +205,7 @@ The `options.selector` can be `date`, `time` or `date and time`.
 - Firefox OS
 - iOS
 - Windows Phone 8
+- Windows
 
 ### Example
 
@@ -217,6 +232,18 @@ options:
 
 - The `formatLength` option supports only `short` and `full` values.
 
+- The pattern for 'date and time' selector is always a full datetime format.
+
+- The returned value may be not completely aligned with ICU depending on a user locale.
+
+### Windows Quirks
+
+- The `formatLength` option supports only `short` and `full` values.
+
+- The pattern for 'date and time' selector is always a full datetime format.
+
+- The returned value may be not completely aligned with ICU depending on a user locale.
+
 ### Firefox OS Quirks
 
 - `formatLength` is not distinguishing `long` and `full` 
@@ -324,6 +351,7 @@ The value of `options.item` can be `months` or `days`.
 - Firefox OS
 - iOS
 - Windows Phone 8
+- Windows
 
 ### Example
 
@@ -345,6 +373,15 @@ a series of twelve popup dialogs, one per month, with text similar to
 
 - `options.type` supports a `genitive` value, important for some languages
 
+### Windows Phone 8 Quirks
+
+- The array of months contains 13 elements.
+- The returned array may be not completely aligned with ICU depending on a user locale.
+
+### Windows Quirks
+
+- The array of months contains 13 elements.
+- The returned array may be not completely aligned with ICU depending on a user locale.
 
 ## navigator.globalization.getDatePattern
 
@@ -385,6 +422,7 @@ time`.
 - BlackBerry 10
 - iOS
 - Windows Phone 8
+- Windows
 
 ### Example
 
@@ -409,6 +447,19 @@ a popup dialog with text such as `pattern: M/d/yyyy h:mm a`:
 
 - The `dst_offset` property is not supported, and always returns zero.
 
+- The pattern may be not completely aligned with ICU depending on a user locale.
+
+### Windows Quirks
+
+- The `formatLength` supports only `short` and `full` values.
+
+- The `pattern` for `date and time` pattern returns only full datetime format.
+
+- The `timezone` returns the full time zone name.
+
+- The `dst_offset` property is not supported, and always returns zero.
+
+- The pattern may be not completely aligned with ICU depending on a user locale.
 
 ## navigator.globalization.getFirstDayOfWeek
 
@@ -436,6 +487,7 @@ error's expected code is `GlobalizationError.UNKNOWN_ERROR`.
 - Firefox OS
 - iOS
 - Windows Phone 8
+- Windows
 
 ### Example
 
@@ -447,6 +499,10 @@ popup dialog with text similar to `day: 1`.
         function () {alert('Error getting day\n');}
     );
 
+###	Windows Quirks
+
+- On Windows 8.0/8.1 the value depends on user' calendar preferences. On Windows Phone 8.1 
+the value depends on current locale.
 
 ## navigator.globalization.getNumberPattern
 
@@ -492,6 +548,7 @@ The `options.type` can be `decimal`, `percent`, or `currency`.
 - BlackBerry 10
 - iOS
 - Windows Phone 8
+- Windows
 
 ### Example
 
@@ -525,7 +582,13 @@ Results:
 
 ### Windows Phone 8 Quirks
 
-- The `pattern` property is not supported, and retuens an empty string.
+- The `pattern` property is not supported, and returns an empty string.
+
+- The `fraction` property is not supported, and returns zero.
+
+### Windows Quirks
+
+- The `pattern` property is not supported, and returns an empty string.
 
 - The `fraction` property is not supported, and returns zero.
 
@@ -558,6 +621,7 @@ executes. The error's expected code is `GlobalizationError.UNKNOWN_ERROR`.
 - Firefox OS
 - iOS
 - Windows Phone 8
+- Windows
 
 ### Example
 
@@ -602,6 +666,7 @@ The `options.type` can be 'decimal', 'percent', or 'currency'.
 - BlackBerry 10
 - iOS
 - Windows Phone 8
+- Windows
 
 ### Example
 
@@ -666,6 +731,7 @@ error's expected code is `GlobalizationError.PARSING_ERROR`.
 - Firefox OS
 - iOS
 - Windows Phone 8
+- Windows
 
 ### Example
 
@@ -683,11 +749,24 @@ integer represents an array index.
         {selector: 'date'}
     );
 
-
 ### Windows Phone 8 Quirks
 
 - The `formatLength` option supports only `short` and `full` values.
 
+- The pattern for 'date and time' selector is always a full datetime format.
+
+- The inbound `dateString` parameter should be formed in compliance with a pattern returned by getDatePattern.
+This pattern may be not completely aligned with ICU depending on a user locale.
+
+### Windows Quirks
+
+- The `formatLength` option supports only `short` and `full` values.
+
+- The pattern for 'date and time' selector is always a full datetime format.
+
+- The inbound `dateString` parameter should be formed in compliance with a pattern returned by getDatePattern.
+This pattern may be not completely aligned with ICU depending on a user locale.
+
 ## navigator.globalization.stringToNumber
 
 Parses a number formatted as a string according to the client's user
@@ -720,6 +799,7 @@ The `options.type` can be `decimal`, `percent`, or `currency`.
 - BlackBerry 10
 - iOS
 - Windows Phone 8
+- Windows
 
 ### Example
 
@@ -758,6 +838,8 @@ This object is created and populated by Cordova, and returned to a callback in t
 - BlackBerry 10
 - Firefox OS
 - iOS
+- Windows Phone 8
+- Windows
 
 ### Example
 

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/46e575d8/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 52354ff..aa09be0 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -111,6 +111,16 @@
         </config-file>
 
         <source-file src="src/wp/Globalization.cs" />
+        <source-file src="src/windows/GlobalizationProxy/GlobalizationProxy/Globalization/GlobalizationApiTypes.cs" />
+        <source-file src="src/windows/GlobalizationProxy/GlobalizationProxy/Globalization/GlobalizationImpl.cs" />
+    </platform>
+
+    <!-- windows -->
+    <platform name="windows">
+        <js-module src="src/windows/GlobalizationProxy.js" name="GlobalizationProxy">
+            <runs/>
+        </js-module>
+        <framework src="src/Windows/GlobalizationProxy.winmd" custom="true"/>
     </platform>
 
     <!-- tizen -->

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/46e575d8/src/windows/GlobalizationProxy.js
----------------------------------------------------------------------
diff --git a/src/windows/GlobalizationProxy.js b/src/windows/GlobalizationProxy.js
new file mode 100644
index 0000000..1edb233
--- /dev/null
+++ b/src/windows/GlobalizationProxy.js
@@ -0,0 +1,124 @@
+/*  
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+*/
+
+var GlobalizationError = require('./GlobalizationError');
+
+module.exports = {
+    getPreferredLanguage: function (win, fail) {
+        try {
+            var language = Windows.System.UserProfile.GlobalizationPreferences.languages[0];
+            win({ value: language });
+        } catch (e) {
+            fail(e);
+        }
+    },
+
+    getLocaleName: function (win, fail) {
+        tryDoAction(GlobalizationProxy.GlobalizationProxy.getLocaleName, "", win, fail);
+    },
+
+    dateToString: function (win, fail, args) {
+        args[0].options = args[0].options || { formatLength: "full", selector: "date and time" };        
+
+        tryDoAction(GlobalizationProxy.GlobalizationProxy.dateToString, 
+            JSON.stringify({
+                date: args[0].date,
+                options: args[0].options
+            }), win, fail);
+    },
+
+    stringToDate: function (win, fail, args) {
+        tryDoAction(GlobalizationProxy.GlobalizationProxy.stringToDate, 
+            JSON.stringify({
+                dateString: args[0].dateString,
+                options: args[0].options
+            }), win, fail);
+    },
+
+    getDateNames: function (win, fail, args) {
+        tryDoAction(GlobalizationProxy.GlobalizationProxy.getDateNames, 
+            JSON.stringify({
+                options: args[0].options
+            }), win, fail);
+    },
+
+    isDayLightSavingsTime: function (win, fail, args) {
+        tryDoAction(GlobalizationProxy.GlobalizationProxy.isDayLightSavingsTime, 
+            JSON.stringify({
+                date: args[0].date,
+            }), win, fail);
+    },
+
+    getFirstDayOfWeek: function (win, fail) {
+        tryDoAction(GlobalizationProxy.GlobalizationProxy.getFirstDayOfWeek, "", win, fail);
+    },
+
+    numberToString: function (win, fail, args) {
+        tryDoAction(GlobalizationProxy.GlobalizationProxy.numberToString, 
+            JSON.stringify({
+                number: args[0].number,
+                options: args[0].options
+            }), win, fail);
+    },
+
+    stringToNumber: function (win, fail, args) {
+        tryDoAction(GlobalizationProxy.GlobalizationProxy.stringToNumber, 
+            JSON.stringify({
+                numberString: args[0].numberString,
+                options: args[0].options
+            }), win, fail);
+    },
+
+    getDatePattern: function (win, fail, args) {
+        tryDoAction(GlobalizationProxy.GlobalizationProxy.getDatePattern, 
+            JSON.stringify({
+                options: args[0].options
+            }), win, fail);
+    },
+
+    getNumberPattern: function (win, fail, args) {
+        tryDoAction(GlobalizationProxy.GlobalizationProxy.getNumberPattern, 
+            JSON.stringify({
+                options: args[0].options
+            }), win, fail);
+    },
+
+    getCurrencyPattern: function (win, fail, args) {
+        fail("Not implemented");
+    }
+};
+
+function tryDoAction(action, args, win, fail) {
+    try {        
+        var result = action(args);
+        var obj = JSON.parse(result);
+        checkForGlobalizationError(obj);
+        win(obj);
+    } catch (e) {
+        fail(e);
+    }
+}
+
+function checkForGlobalizationError(obj) {
+    if (obj && 'code' in obj && 'message' in obj) {
+        throw new GlobalizationError(obj.code, obj.message);
+    }
+}
+
+(function init() {
+    // Actually navigator.systemLanguage returns a locale
+    GlobalizationProxy.GlobalizationProxy.setLocale(navigator.systemLanguage);
+})();
+
+require("cordova/exec/proxy").add("Globalization", module.exports);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/46e575d8/src/windows/GlobalizationProxy.winmd
----------------------------------------------------------------------
diff --git a/src/windows/GlobalizationProxy.winmd b/src/windows/GlobalizationProxy.winmd
new file mode 100644
index 0000000..1248be0
Binary files /dev/null and b/src/windows/GlobalizationProxy.winmd differ

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/46e575d8/src/windows/GlobalizationProxy/GlobalizationProxy.sln
----------------------------------------------------------------------
diff --git a/src/windows/GlobalizationProxy/GlobalizationProxy.sln b/src/windows/GlobalizationProxy/GlobalizationProxy.sln
new file mode 100644
index 0000000..c26bb89
--- /dev/null
+++ b/src/windows/GlobalizationProxy/GlobalizationProxy.sln
@@ -0,0 +1,38 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GlobalizationProxy", "GlobalizationProxy\GlobalizationProxy.csproj", "{1133E9BE-C7CC-49FF-AEC7-4AE5BC35CCBC}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Debug|ARM = Debug|ARM
+		Debug|x64 = Debug|x64
+		Debug|x86 = Debug|x86
+		Release|Any CPU = Release|Any CPU
+		Release|ARM = Release|ARM
+		Release|x64 = Release|x64
+		Release|x86 = Release|x86
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{1133E9BE-C7CC-49FF-AEC7-4AE5BC35CCBC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{1133E9BE-C7CC-49FF-AEC7-4AE5BC35CCBC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{1133E9BE-C7CC-49FF-AEC7-4AE5BC35CCBC}.Debug|ARM.ActiveCfg = Debug|ARM
+		{1133E9BE-C7CC-49FF-AEC7-4AE5BC35CCBC}.Debug|ARM.Build.0 = Debug|ARM
+		{1133E9BE-C7CC-49FF-AEC7-4AE5BC35CCBC}.Debug|x64.ActiveCfg = Debug|x64
+		{1133E9BE-C7CC-49FF-AEC7-4AE5BC35CCBC}.Debug|x64.Build.0 = Debug|x64
+		{1133E9BE-C7CC-49FF-AEC7-4AE5BC35CCBC}.Debug|x86.ActiveCfg = Debug|x86
+		{1133E9BE-C7CC-49FF-AEC7-4AE5BC35CCBC}.Debug|x86.Build.0 = Debug|x86
+		{1133E9BE-C7CC-49FF-AEC7-4AE5BC35CCBC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{1133E9BE-C7CC-49FF-AEC7-4AE5BC35CCBC}.Release|Any CPU.Build.0 = Release|Any CPU
+		{1133E9BE-C7CC-49FF-AEC7-4AE5BC35CCBC}.Release|ARM.ActiveCfg = Release|ARM
+		{1133E9BE-C7CC-49FF-AEC7-4AE5BC35CCBC}.Release|ARM.Build.0 = Release|ARM
+		{1133E9BE-C7CC-49FF-AEC7-4AE5BC35CCBC}.Release|x64.ActiveCfg = Release|x64
+		{1133E9BE-C7CC-49FF-AEC7-4AE5BC35CCBC}.Release|x64.Build.0 = Release|x64
+		{1133E9BE-C7CC-49FF-AEC7-4AE5BC35CCBC}.Release|x86.ActiveCfg = Release|x86
+		{1133E9BE-C7CC-49FF-AEC7-4AE5BC35CCBC}.Release|x86.Build.0 = Release|x86
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/46e575d8/src/windows/GlobalizationProxy/GlobalizationProxy/.gitignore
----------------------------------------------------------------------
diff --git a/src/windows/GlobalizationProxy/GlobalizationProxy/.gitignore b/src/windows/GlobalizationProxy/GlobalizationProxy/.gitignore
new file mode 100644
index 0000000..b84aa9d
--- /dev/null
+++ b/src/windows/GlobalizationProxy/GlobalizationProxy/.gitignore
@@ -0,0 +1,3 @@
+/bin/
+/obj/
+*.suo
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/46e575d8/src/windows/GlobalizationProxy/GlobalizationProxy/Cordova/JSON/JsonHelper.cs
----------------------------------------------------------------------
diff --git a/src/windows/GlobalizationProxy/GlobalizationProxy/Cordova/JSON/JsonHelper.cs b/src/windows/GlobalizationProxy/GlobalizationProxy/Cordova/JSON/JsonHelper.cs
new file mode 100644
index 0000000..88b3c2a
--- /dev/null
+++ b/src/windows/GlobalizationProxy/GlobalizationProxy/Cordova/JSON/JsonHelper.cs
@@ -0,0 +1,87 @@
+/*  
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+*/
+
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Runtime.Serialization.Json;
+using System.Text;
+
+namespace GlobalizationProxy.Cordova.JSON
+{
+    /// <summary>
+    /// Provides JSON serialization/deserialization functionality.
+    /// </summary>
+    static class JsonHelper
+    {
+        /// <summary>
+        /// Serializes object to JSON string representation
+        /// </summary>
+        /// <param name="obj">object to serialize</param>
+        /// <returns>JSON representation of the object. Returns 'null' string for null passed as argument</returns>
+        public static string Serialize(object obj)
+        {
+            if (obj == null)
+            {
+                return "null";
+            }
+
+            DataContractJsonSerializer ser = new DataContractJsonSerializer(obj.GetType());
+
+            MemoryStream ms = new MemoryStream();
+            ser.WriteObject(ms, obj);
+
+            ms.Position = 0;
+
+            string json = String.Empty;
+
+            using (StreamReader sr = new StreamReader(ms))
+            {
+                json = sr.ReadToEnd();
+            }
+
+            ms.Dispose();
+
+            return json;
+
+        }
+
+        /// <summary>
+        /// Parses json string to object instance
+        /// </summary>
+        /// <typeparam name="T">type of the object</typeparam>
+        /// <param name="json">json string representation of the object</param>
+        /// <returns>Deserialized object instance</returns>
+        public static T Deserialize<T>(string json)
+        {
+            DataContractJsonSerializer deserializer = new DataContractJsonSerializer(typeof(T));
+            object result = null;
+            try
+            {
+                using (MemoryStream mem = new MemoryStream(Encoding.UTF8.GetBytes(json)))
+                {
+                    result = deserializer.ReadObject(mem);
+                }
+            }
+            catch (Exception ex)
+            {
+                Debug.WriteLine(ex.Message);
+                Debug.WriteLine("Failed to deserialize " + typeof(T) + " with JSON value :: " + json);
+            }
+
+            return (T)result;
+
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/46e575d8/src/windows/GlobalizationProxy/GlobalizationProxy/Globalization/GlobalizationApiTypes.cs
----------------------------------------------------------------------
diff --git a/src/windows/GlobalizationProxy/GlobalizationProxy/Globalization/GlobalizationApiTypes.cs b/src/windows/GlobalizationProxy/GlobalizationProxy/Globalization/GlobalizationApiTypes.cs
new file mode 100644
index 0000000..5641b21
--- /dev/null
+++ b/src/windows/GlobalizationProxy/GlobalizationProxy/Globalization/GlobalizationApiTypes.cs
@@ -0,0 +1,429 @@
+/*  
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+*/
+
+using System;
+using System.Runtime.Serialization;
+
+namespace GlobalizationProxy.Globalization
+{
+    #region Globalization errors
+
+    /// <summary>
+    /// Globalization error codes.
+    /// </summary>
+    enum ErrorCode : int
+    {
+        UnknownError = 0,
+        FormattingError = 1,
+        ParsingError = 2,
+        PatternError = 3
+    }
+
+    /// <summary>
+    /// Represents globalization error object.
+    /// </summary>
+    [DataContract]
+    class GlobalizationError
+    {
+        #region Error messages
+        /// <summary>
+        /// Error messages
+        /// </summary>        
+        public const string UnknownError = "UNKNOWN_ERROR";
+        public const string FormattingError = "FORMATTIN_ERROR";
+        public const string ParsingError = "PARSING_ERROR";
+        public const string PatternError = "PATTERN_ERROR";
+
+        #endregion
+
+        /// <summary>
+        /// Error code
+        /// </summary>
+        [DataMember(Name = "code", IsRequired = true)]
+        public ErrorCode Code { get; set; }
+
+        /// <summary>
+        /// Error message
+        /// </summary>
+        [DataMember(Name = "message", IsRequired = true)]
+        public string Message { get; set; }
+
+        /// <summary>
+        /// Default constructor
+        /// </summary>
+        public GlobalizationError()
+        {
+            this.Code = ErrorCode.UnknownError;
+            this.Message = UnknownError;
+        }
+
+        /// <summary>
+        /// Constructor setting error code
+        /// </summary>
+        public GlobalizationError(ErrorCode error)
+        {
+            this.Code = error;
+
+            switch (error)
+            {
+                case ErrorCode.ParsingError:
+                    {
+                        this.Message = ParsingError;
+                        break;
+                    }
+                case ErrorCode.FormattingError:
+                    {
+                        this.Message = FormattingError;
+                        break;
+                    }
+                case ErrorCode.PatternError:
+                    {
+                        this.Message = PatternError;
+                        break;
+                    }
+                default:
+                    {
+                        this.Message = UnknownError;
+                        break;
+                    }
+            }
+        }
+
+        /// <summary>
+        /// Constructor setting error code and message
+        /// </summary>
+        public GlobalizationError(ErrorCode code, string message)
+        {
+            this.Code = code;
+            this.Message = message ?? String.Empty;
+        }
+    }
+
+    #endregion
+
+    #region Globalization options
+
+    /// <summary>
+    /// Represents globalization options.
+    /// </summary>
+    [DataContract]
+    class GlobalizationOptions
+    {
+        #region available option values
+        /// <summary>
+        /// Number pattern types.
+        /// </summary>        
+        public const string Percent = "percent";
+        public const string Currency = "currency";
+        public const string Decimal = "decimal";
+
+        /// <summary>
+        /// Format length types
+        /// </summary>        
+        public const string Short = "short";
+        public const string Medium = "medium";
+        public const string Long = "long";
+        public const string Full = "full";
+
+        /// <summary>
+        /// Selector types
+        /// </summary>        
+        public const string TimeSelector = "time";
+        public const string DateSelector = "date";
+        public const string DateAndTimeSelector = "date and time";
+
+        /// <summary>
+        /// Date name types
+        /// </summary>        
+        public const string Narrow = "narrow";
+        public const string Wide = "wide";
+
+        /// <summary>
+        /// Date name items
+        /// </summary>        
+        public const string Months = "months";
+        public const string Days = "days";
+
+        #endregion
+
+        /// <summary>
+        /// Additional options
+        /// </summary>
+        [DataMember(Name = "options", IsRequired = false)]
+        public Options AdditionalOptions { get; set; }
+
+        /// <summary>
+        /// Date to convert
+        /// </summary>
+        [DataMember(Name = "date", IsRequired = false)]
+        public long Date { get; set; }
+
+        /// <summary>
+        /// Date as stirng
+        /// </summary>
+        [DataMember(Name = "dateString", IsRequired = false)]
+        public string DateString { get; set; }
+
+        /// <summary>
+        /// Currency code
+        /// </summary>
+        [DataMember(Name = "currencyCode", IsRequired = false)]
+        public string CurrencyCode { get; set; }
+
+        /// <summary>
+        /// Number as string
+        /// </summary>
+        [DataMember(Name = "numberString", IsRequired = false)]
+        public string NumberString { get; set; }
+
+        /// <summary>
+        /// Number to convert
+        /// </summary>
+        [DataMember(Name = "number", IsRequired = false)]
+        public double Number { get; set; }
+    }
+
+    /// <summary>
+    /// Represents additional options
+    /// </summary>
+    [DataContract]
+    class Options
+    {
+        /// <summary>
+        /// Pattern type
+        /// </summary>
+        [DataMember(Name = "type", IsRequired = false)]
+        public string Type { get; set; }
+
+        /// <summary>
+        /// Format length
+        /// </summary>
+        [DataMember(Name = "formatLength", IsRequired = false)]
+        public string FormatLength { get; set; }
+
+        /// <summary>
+        /// Selector
+        /// </summary>
+        [DataMember(Name = "selector", IsRequired = false)]
+        public string Selector { get; set; }
+
+        /// <summary>
+        /// Date name item
+        /// </summary>
+        [DataMember(Name = "item", IsRequired = false)]
+        public string Item { get; set; }
+    }
+
+    #endregion
+
+    #region Returned objects
+
+    #region Number pattern object
+
+    /// <summary>
+    /// Represents number pattern
+    /// </summary>
+    [DataContract]
+    class NumberPattern
+    {
+        /// <summary>
+        /// Pattern
+        /// </summary>
+        [DataMember(Name = "pattern", IsRequired = false)]
+        public string Pattern { get; set; }
+
+        /// <summary>
+        /// Symbol
+        /// </summary>
+        [DataMember(Name = "symbol", IsRequired = false)]
+        public string Symbol { get; set; }
+
+        /// <summary>
+        /// Fraction
+        /// </summary>
+        [DataMember(Name = "fraction", IsRequired = false)]
+        public int Fraction { get; set; }
+
+        /// <summary>
+        /// Positive
+        /// </summary>
+        [DataMember(Name = "positive", IsRequired = false)]
+        public string Positive { get; set; }
+
+        /// <summary>
+        /// Negative
+        /// </summary>
+        [DataMember(Name = "negative", IsRequired = false)]
+        public string Negative { get; set; }
+
+        /// <summary>
+        /// Rounding
+        /// </summary>
+        [DataMember(Name = "rounding", IsRequired = false)]
+        public int Rounding { get; set; }
+
+        /// <summary>
+        /// Decimal
+        /// </summary>
+        [DataMember(Name = "decimal", IsRequired = false)]
+        public string Decimal { get; set; }
+
+        /// <summary>
+        /// Grouping
+        /// </summary>
+        [DataMember(Name = "grouping", IsRequired = false)]
+        public string Grouping { get; set; }
+
+        /// <summary>
+        /// Constructor of the class
+        /// </summary>
+        /// <param name="pattern"></param>
+        /// <param name="symbol"></param>
+        /// <param name="fraction"></param>
+        /// <param name="positive"></param>
+        /// <param name="negative"></param>
+        /// <param name="rounding"></param>
+        /// <param name="dec"></param>
+        /// <param name="grouping"></param>
+        public NumberPattern(string pattern, string symbol, int fraction, string positive, string negative, int rounding, string dec, string grouping)
+        {
+            this.Pattern = pattern;
+            this.Symbol = symbol;
+            this.Fraction = fraction;
+            this.Positive = positive;
+            this.Negative = negative;
+            this.Rounding = rounding;
+            this.Decimal = dec;
+            this.Grouping = grouping;
+        }
+    }
+    #endregion
+
+    #region Date format object
+
+    /// <summary>
+    /// Represents date format
+    /// </summary>
+    [DataContract]
+    class DateFormat
+    {
+        /// <summary>
+        /// Year
+        /// </summary>
+        [DataMember(Name = "year", IsRequired = false)]
+        public int Year { get; set; }
+
+        /// <summary>
+        /// Month
+        /// </summary>
+        [DataMember(Name = "month", IsRequired = false)]
+        public int Month { get; set; }
+
+        /// <summary>
+        /// Day
+        /// </summary>
+        [DataMember(Name = "day", IsRequired = false)]
+        public int Day { get; set; }
+
+        /// <summary>
+        /// Hour
+        /// </summary>
+        [DataMember(Name = "hour", IsRequired = false)]
+        public int Hour { get; set; }
+
+        /// <summary>
+        /// Minute
+        /// </summary>
+        [DataMember(Name = "minute", IsRequired = false)]
+        public int Minute { get; set; }
+
+        /// <summary>
+        /// Second
+        /// </summary>
+        [DataMember(Name = "second", IsRequired = false)]
+        public int Second { get; set; }
+
+        /// <summary>
+        /// Millisecond
+        /// </summary>
+        [DataMember(Name = "millisecond", IsRequired = false)]
+        public int Millisecond { get; set; }
+
+        public DateFormat(int year, int month, int day, int hour, int minute, int second, int millisecond)
+        {
+            this.Year = year;
+            this.Month = month;
+            this.Day = day;
+            this.Hour = hour;
+            this.Minute = minute;
+            this.Millisecond = millisecond;
+        }
+
+    }
+    #endregion
+
+    #region Date pattern object
+
+    /// <summary>
+    /// Represents date pattern object
+    /// </summary>
+    [DataContract]
+    class DatePattern
+    {
+
+        /// <summary>
+        /// Date pattern
+        /// </summary>
+        [DataMember(Name = "pattern", IsRequired = false)]
+        public string Pattern { get; set; }
+
+        /// <summary>
+        /// TimeZone
+        /// </summary>
+        [DataMember(Name = "timezone", IsRequired = false)]
+        public string TimeZone { get; set; }
+
+        /// <summary>
+        /// UTC offset
+        /// </summary>
+        [DataMember(Name = "utc_offset", IsRequired = false)]
+        public double UtcOffset { get; set; }
+
+        /// <summary>
+        /// Dst offset
+        /// </summary>
+        [DataMember(Name = "dst_offset", IsRequired = false)]
+        public double DstOffset { get; set; }
+
+        /// <summary>
+        /// Constructor of the class
+        /// </summary>
+        /// <param name="pattern"></param>
+        /// <param name="timezone"></param>
+        /// <param name="utcOffset"></param>
+        /// <param name="dstOffset"></param>
+        public DatePattern(string pattern, string timezone, double utcOffset, double dstOffset)
+        {
+            this.Pattern = pattern;
+            this.TimeZone = timezone;
+            this.UtcOffset = utcOffset;
+            this.DstOffset = dstOffset;
+        }
+
+    }
+
+    #endregion
+
+    #endregion
+}

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/46e575d8/src/windows/GlobalizationProxy/GlobalizationProxy/Globalization/GlobalizationImpl.cs
----------------------------------------------------------------------
diff --git a/src/windows/GlobalizationProxy/GlobalizationProxy/Globalization/GlobalizationImpl.cs b/src/windows/GlobalizationProxy/GlobalizationProxy/Globalization/GlobalizationImpl.cs
new file mode 100644
index 0000000..24d181f
--- /dev/null
+++ b/src/windows/GlobalizationProxy/GlobalizationProxy/Globalization/GlobalizationImpl.cs
@@ -0,0 +1,612 @@
+/*  
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+*/
+
+using System;
+using System.Globalization;
+using System.Runtime.Serialization;
+
+#if NETFX_CORE
+// Windows
+
+// Because WinRT' CurrentCulture does not take into account the locale (it falls back on application language)
+// we are substituting it with a locale constructed from locale name passed from JS proxy.
+using CultureInfo = GlobalizationProxy.Globalization.SettableCultureInfo;
+
+using JsonHelper = GlobalizationProxy.Cordova.JSON.JsonHelper;
+#else
+using WPCordovaClassLib.Cordova.JSON;
+#endif
+
+namespace GlobalizationProxy.Globalization
+{
+    class GlobalizationImpl
+    {
+        public const string OPTS_DESERIALIZE_FAIL = "Could not deserialize options";
+
+        // By default JSON serialization is performed using CurrentCulture but
+        // float numbers need to be formatted in "en-US" culture to be deserialized in JavaScript.
+        private const string JS_DEFAULT_LANG_TAG = "en-US";
+        private static CultureInfo JS_DEFAULT_CULTURE = new CultureInfo(JS_DEFAULT_LANG_TAG);
+
+        #region Locale info
+
+        /// <summary>
+        /// Gets the string identifier for the client's current locale setting.
+        /// </summary>
+        /// <param name="options"></param>               
+        public static string getLocaleName(string options)
+        {
+            return WrapIntoJSON(CultureInfo.CurrentCulture.Name);
+        }
+
+        /// <summary>
+        /// Gets the string identifier for the client's current language.
+        /// </summary>
+        /// <param name="options"></param>               
+        public static string getPreferredLanguage(string options)
+        {
+            return WrapIntoJSON(CultureInfo.CurrentUICulture.Name);
+        }
+
+        #endregion Locale info
+
+        #region Date and time info
+
+        /// <summary>
+        /// Gets whether daylight savings time is in effect for a given date using the client's 
+        /// time zone and calendar.        
+        /// </summary>
+        /// <param name="opitons">Date to daylight savings check.</param>
+        public static string isDayLightSavingsTime(string options)
+        {
+            var globalOptions = ReadOptions(options);
+            if (globalOptions == null)
+                throw new SerializationException(OPTS_DESERIALIZE_FAIL);
+
+            var start = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+            var date = start.AddMilliseconds(globalOptions.Date).ToLocalTime();
+            TimeZoneInfo localZone = TimeZoneInfo.Local;
+            bool isDaylightSavingTime = localZone.IsDaylightSavingTime(date);
+
+            return WrapIntoJSON(isDaylightSavingTime, "dst");
+        }
+
+        /// <summary>
+        /// Gets the first day of the week according to the client's user preferences and calendar.
+        /// The days of the week are numbered starting from 1 where 1 is considered to be Sunday.
+        /// </summary>
+        /// <param name="options"></param>
+        public static string getFirstDayOfWeek(string options)
+        {
+            // DateTimeFormat returns days of the week numbered from zero, so we have to increase returned value by one.
+            return WrapIntoJSON((int)CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek + 1);
+        }
+
+        #endregion Date and time info
+
+        #region Formatting
+
+        /// <summary>
+        /// Gets a date formatted as a string according to the client's user preferences and calendar using the time zone of the client. 
+        /// </summary>
+        /// <param name="options"></param>
+        public static string dateToString(string options)
+        {
+            var globalOptions = ReadOptions(options);
+
+            var start = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+            var date = start.AddMilliseconds(globalOptions.Date).ToLocalTime();
+
+            string format = "{0:" + CultureInfo.CurrentCulture.DateTimeFormat.FullDateTimePattern + "}"; //short datetime by default
+            int formatLength = 0; //default format
+            int selector = 0; //default selector 
+
+            if (globalOptions.AdditionalOptions != null)
+            {
+                if (globalOptions.AdditionalOptions.FormatLength != null)
+                {
+                    string t = globalOptions.AdditionalOptions.FormatLength;
+
+                    if (t.Equals(GlobalizationOptions.Full))
+                    {
+                        formatLength++;
+                    }
+                }
+
+                if (globalOptions.AdditionalOptions.Selector != null)
+                {
+                    string t = globalOptions.AdditionalOptions.Selector;
+
+                    if (t.Equals(GlobalizationOptions.DateSelector))
+                    {
+                        selector += 10;
+                    }
+                    else if (t.Equals(GlobalizationOptions.TimeSelector))
+                    {
+                        selector += 20;
+                    }
+                }
+
+                //determine return value
+                int method = formatLength + selector;
+
+                switch (method)
+                {
+                    case 1: // full datetime
+                        {
+                            format = "{0:" + CultureInfo.CurrentCulture.DateTimeFormat.FullDateTimePattern + "}";
+                            break;
+                        }
+                    case 10: // short date
+                        {
+                            format = "{0:" + CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern + "}";
+                            break;
+                        }
+                    case 11: // full date
+                        {
+                            format = "{0:" + CultureInfo.CurrentCulture.DateTimeFormat.LongDatePattern + "}";
+                            break;
+                        }
+                    case 20: // short time
+                        {
+                            format = "{0:" + CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern + "}";
+                            break;
+                        }
+                    case 21: // full time
+                        {
+                            format = "{0:" + CultureInfo.CurrentCulture.DateTimeFormat.LongTimePattern + "}";
+                            break;
+                        }
+                    default: // short datetime
+                        {
+                            // Seems like C# doesn't support short datetime pattern so we use full format
+                            // http://msdn.microsoft.com/en-us/library/1at0z4ew%28v=vs.71%29.aspx
+                            format = "{0:" + CultureInfo.CurrentCulture.DateTimeFormat.FullDateTimePattern + "}";
+                            break;
+                        }
+                }
+            }
+
+            string formattedValue = string.Format(CultureInfo.CurrentCulture, format, date);
+            return WrapIntoJSON(formattedValue);
+        }
+
+        /// <summary>
+        /// Parses a date formatted as a string according to the client's user preferences and calendar using the time zone of the client and returns the corresponding date object
+        /// </summary>
+        /// <param name="options"></param>
+        public static DateFormat stringToDate(string options)
+        {
+            var globalOptions = ReadOptions(options);
+
+            if (string.IsNullOrEmpty(globalOptions.DateString))
+            {
+                throw new SerializationException("DateString is empty");
+            }
+
+            string format = CultureInfo.CurrentCulture.DateTimeFormat.FullDateTimePattern; // short datetime by default
+            int formatLength = 0; //default format
+            int selector = 0; //default selector 
+
+            if (globalOptions.AdditionalOptions != null)
+            {
+                if (globalOptions.AdditionalOptions.FormatLength != null)
+                {
+                    string t = globalOptions.AdditionalOptions.FormatLength;
+
+                    if (t.Equals(GlobalizationOptions.Full))
+                    {
+                        formatLength++;
+                    }
+                }
+
+                if (globalOptions.AdditionalOptions.Selector != null)
+                {
+                    string t = globalOptions.AdditionalOptions.Selector;
+
+                    if (t.Equals(GlobalizationOptions.DateSelector))
+                    {
+                        selector += 10;
+                    }
+                    else if (t.Equals(GlobalizationOptions.TimeSelector))
+                    {
+                        selector += 20;
+                    }
+                }
+
+                //determine return value
+                int method = formatLength + selector;
+
+                switch (method)
+                {
+                    case 1: // full datetime
+                        {
+                            format = CultureInfo.CurrentCulture.DateTimeFormat.FullDateTimePattern;
+                            break;
+                        }
+                    case 10: // short date
+                        {
+                            format = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;
+                            break;
+                        }
+                    case 11: // full date
+                        {
+                            format = CultureInfo.CurrentCulture.DateTimeFormat.LongDatePattern;
+                            break;
+                        }
+                    case 20: // short time
+                        {
+                            format = CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern;
+                            break;
+                        }
+                    case 21: // full time
+                        {
+                            format = CultureInfo.CurrentCulture.DateTimeFormat.LongTimePattern;
+                            break;
+                        }
+                    default: // short datetime
+                        {
+                            // Seems like C# doesn't support short datetime pattern so we use full format
+                            // http://msdn.microsoft.com/en-us/library/1at0z4ew%28v=vs.71%29.aspx
+                            format = CultureInfo.CurrentCulture.DateTimeFormat.FullDateTimePattern;
+                            break;
+                        }
+                }
+            }
+
+            DateTime date = DateTime.ParseExact(globalOptions.DateString, format, CultureInfo.CurrentCulture);
+            return new DateFormat(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, date.Millisecond);
+        }
+
+        /// <summary>
+        /// Gets a pattern string for formatting and parsing dates according to the client's user preferences.
+        /// </summary>
+        /// <param name="options"></param>
+        public static DatePattern getDatePattern(string options)
+        {
+            var globalOptions = ReadOptions(options);
+
+            DateTimeFormatInfo dateFormatInfo = CultureInfo.CurrentCulture.DateTimeFormat;
+            string pattern = dateFormatInfo.FullDateTimePattern; // full datetime by default
+            int formatLength = 0; //default format
+            int selector = 0; //default selector 
+
+            if (globalOptions.AdditionalOptions != null)
+            {
+                if (globalOptions.AdditionalOptions.FormatLength != null)
+                {
+                    string t = globalOptions.AdditionalOptions.FormatLength;
+
+                    if (t.Equals(GlobalizationOptions.Full))
+                    {
+                        formatLength++;
+                    }
+                }
+
+                if (globalOptions.AdditionalOptions.Selector != null)
+                {
+                    string t = globalOptions.AdditionalOptions.Selector;
+
+                    if (t.Equals(GlobalizationOptions.DateSelector))
+                    {
+                        selector += 10;
+                    }
+                    else if (t.Equals(GlobalizationOptions.TimeSelector))
+                    {
+                        selector += 20;
+                    }
+                }
+
+                //determine return value
+                int method = formatLength + selector;
+
+                switch (method)
+                {
+                    case 1: // full datetime
+                        {
+                            pattern = dateFormatInfo.FullDateTimePattern;
+                            break;
+                        }
+                    case 10: // short date
+                        {
+                            pattern = dateFormatInfo.ShortDatePattern;
+                            break;
+                        }
+                    case 11: // full date
+                        {
+                            pattern = dateFormatInfo.LongDatePattern;
+                            break;
+                        }
+                    case 20: // short time
+                        {
+                            pattern = dateFormatInfo.ShortTimePattern;
+                            break;
+                        }
+                    case 21: // full time
+                        {
+                            pattern = dateFormatInfo.LongTimePattern;
+                            break;
+                        }
+                    default: // short datetime
+                        {
+                            // Seems like C# doesn't support short datetime pattern so we use full format
+                            // http://msdn.microsoft.com/en-us/library/1at0z4ew%28v=vs.71%29.aspx
+                            pattern = dateFormatInfo.FullDateTimePattern;
+                            break;
+                        }
+                }
+            }
+
+            TimeZoneInfo localZone = TimeZoneInfo.Local;
+            return new DatePattern(pattern, localZone.DisplayName, localZone.BaseUtcOffset.TotalSeconds, 0);
+        }
+
+        /// <summary>
+        /// Gets an array of either the names of the months or days of the week according to the client's user preferences and calendar.
+        /// </summary>
+        /// <param name="options"></param>
+        public static string getDateNames(string options)
+        {
+            var globalOptions = ReadOptions(options);
+
+            int type = 0; //default wide
+            int item = 0; //default months 
+
+            if (globalOptions.AdditionalOptions != null)
+            {
+                if (globalOptions.AdditionalOptions.Type != null)
+                {
+                    string t = globalOptions.AdditionalOptions.Type;
+
+                    if (t.Equals(GlobalizationOptions.Narrow))
+                    {
+                        type++;
+                    }
+                }
+
+                if (globalOptions.AdditionalOptions.Item != null)
+                {
+                    string t = globalOptions.AdditionalOptions.Item;
+
+                    if (t.Equals(GlobalizationOptions.Days))
+                    {
+                        item += 10;
+                    }
+                }
+            }
+
+            //determine return value
+            int method = item + type;
+            string[] namesArray;
+            CultureInfo currentCulture = CultureInfo.CurrentCulture;
+
+            if (method == 1) //months and narrow
+            {
+                namesArray = currentCulture.DateTimeFormat.AbbreviatedMonthNames;
+            }
+            else if (method == 10) //days and wide
+            {
+                namesArray = currentCulture.DateTimeFormat.DayNames;
+            }
+            else if (method == 11) //days and narrow
+            {
+                namesArray = currentCulture.DateTimeFormat.AbbreviatedDayNames;
+            }
+            else //default: months and wide
+            {
+                namesArray = currentCulture.DateTimeFormat.MonthNames;
+            }
+
+            return WrapIntoJSON(namesArray);
+        }
+
+        /// <summary>
+        /// Gets a number formatted as a string according to the client's user preferences. 
+        /// </summary>
+        /// <param name="options"></param>
+        public static string numberToString(string options)
+        {
+            var globalOptions = ReadOptions(options);
+           
+            string format = string.Empty;
+            string numberFormatType = (globalOptions.AdditionalOptions == null || string.IsNullOrEmpty(globalOptions.AdditionalOptions.Type)) ?
+                GlobalizationOptions.Decimal : globalOptions.AdditionalOptions.Type;
+
+            switch (numberFormatType)
+            {
+                case GlobalizationOptions.Percent:
+                    {
+                        format = "{0:p}";
+                        break;
+                    }
+
+                case GlobalizationOptions.Currency:
+                    {
+                        format = "{0:c}";
+                        break;
+                    }
+
+                default:
+                    {
+                        format = "{0:f}";
+                        break;
+                    }
+            }
+
+            string formattedValue = string.Format(CultureInfo.CurrentCulture, format, globalOptions.Number);
+            return WrapIntoJSON(formattedValue);
+        }
+
+        /// <summary>
+        /// Gets a number formatted as a string according to the client's user preferences and returns the corresponding number.
+        /// </summary>
+        /// <param name="options"></param>
+        public static string stringToNumber(string options)
+        {
+            var globalOptions = ReadOptions(options);
+           
+            if (string.IsNullOrEmpty(globalOptions.NumberString))
+            {
+                throw new SerializationException("NumberString is empty");
+            }
+
+            string numberString = globalOptions.NumberString;
+            string numberFormatType = (globalOptions.AdditionalOptions == null || string.IsNullOrEmpty(globalOptions.AdditionalOptions.Type)) ?
+                GlobalizationOptions.Decimal : globalOptions.AdditionalOptions.Type;
+
+            NumberStyles numberStyle;
+
+            switch (numberFormatType)
+            {
+                case GlobalizationOptions.Percent:
+                    {
+                        numberStyle = NumberStyles.Any;
+                        numberString = numberString.Replace(System.Globalization.CultureInfo.CurrentCulture.NumberFormat.PercentSymbol, "");
+                        break;
+                    }
+
+                case GlobalizationOptions.Currency:
+                    {
+                        numberStyle = NumberStyles.Currency;
+                        break;
+                    }
+
+                default:
+                    {
+                        numberStyle = NumberStyles.Number;
+                        break;
+                    }
+            }
+
+            double value = double.Parse(numberString, numberStyle, CultureInfo.CurrentCulture);
+
+            // By default JSON serialization is performed using CurrentCulture but
+            // float numbers need to be formatted in "en-US" culture to be deserialized in JavaScript.
+            string stringifiedData = value.ToString(JS_DEFAULT_CULTURE);
+
+            return WrapIntoJSON(value, stringifiedData: stringifiedData);
+        }
+
+        /// <summary>
+        /// Gets a pattern string for formatting and parsing numbers according to the client's user preferences.
+        /// </summary>
+        /// <param name="options"></param>
+        public static NumberPattern getNumberPattern(string options)
+        {
+            var globalOptions = ReadOptions(options);
+           
+            CultureInfo cultureInfo = CultureInfo.CurrentCulture;
+            NumberFormatInfo formatInfo = cultureInfo.NumberFormat;
+            string numberFormatType = (globalOptions.AdditionalOptions == null || string.IsNullOrEmpty(globalOptions.AdditionalOptions.Type)) ?
+                GlobalizationOptions.Decimal : globalOptions.AdditionalOptions.Type;
+            NumberPattern pattern = null;
+            string symbol;
+
+            // TODO find out how to get format pattern and the number of fraction digits
+            switch (numberFormatType)
+            {
+                case GlobalizationOptions.Percent:
+                    {
+                        symbol = formatInfo.PercentSymbol;
+                        pattern = new NumberPattern("", symbol, 0, formatInfo.PercentPositivePattern.ToString(), formatInfo.PercentNegativePattern.ToString(), 0, formatInfo.PercentDecimalSeparator, formatInfo.PercentGroupSeparator);
+                        break;
+                    }
+                case GlobalizationOptions.Currency:
+                    {
+                        symbol = formatInfo.CurrencySymbol;
+                        pattern = new NumberPattern("", symbol, 0, formatInfo.CurrencyPositivePattern.ToString(), formatInfo.CurrencyNegativePattern.ToString(), 0, formatInfo.CurrencyDecimalSeparator, formatInfo.CurrencyGroupSeparator);
+                        break;
+                    }
+                default:
+                    {
+                        symbol = formatInfo.NumberDecimalSeparator;
+                        pattern = new NumberPattern("", symbol, 0, "", formatInfo.NumberNegativePattern.ToString(), 0, formatInfo.NumberDecimalSeparator, formatInfo.NumberGroupSeparator);
+                        break;
+                    }
+            }
+
+            return pattern;
+        }
+
+        /// <summary>
+        /// Gets a pattern string for formatting and parsing currency values according to the client's user preferences and ISO 4217 currency code.
+        /// </summary>
+        /// <param name="options"></param>
+        public static string getCurrencyPattern(string options)
+        {
+            var globalOptions = ReadOptions(options);
+                       
+            if (string.IsNullOrEmpty(globalOptions.CurrencyCode))
+            {
+                throw new SerializationException("CurrencyCode is empty");
+            }
+
+            // TODO find the way to get currency info from currency code
+            // http://stackoverflow.com/questions/12373800/3-digit-currency-code-to-currency-symbol
+            // http://stackoverflow.com/questions/6924067/how-to-get-specific-culture-currency-pattern
+            // CultureInfo cultureInfo = new CultureInfo(currencyCode);
+            // NumberFormatInfo numberFormat = cultureInfo.NumberFormat;
+
+            // temporary not supported via lack of api required
+            throw new NotImplementedException("Not supported");
+        }
+
+        #endregion Formatting
+
+        private static GlobalizationOptions ReadOptions(string options)
+        {
+            GlobalizationOptions globalOptions;
+            try
+            {
+                globalOptions = JsonHelper.Deserialize<GlobalizationOptions>(options);
+            }
+            catch (Exception)
+            {
+                throw new SerializationException(OPTS_DESERIALIZE_FAIL);
+            }
+            return globalOptions;
+        }
+
+        /// <summary>
+        /// Wraps data into JSON format
+        /// </summary>
+        /// <param name="data">data</param>
+        /// <returns>data formatted as JSON object</returns>
+        static string WrapIntoJSON<T>(T data, string keyName = "value", string stringifiedData = null)
+        {
+            string param = "{0}";
+            stringifiedData = stringifiedData ?? data.ToString();
+
+            if (data.GetType() == typeof(string))
+            {
+                param = "\"" + param + "\"";
+            }
+
+            if (data.GetType() == typeof(bool))
+            {
+                stringifiedData = stringifiedData.ToLower();
+            }
+
+            if (data.GetType() == typeof(string[]))
+            {
+                stringifiedData = JsonHelper.Serialize(data);
+            }
+
+            var formattedData = string.Format("\"" + keyName + "\":" + param, stringifiedData);
+            formattedData = "{" + formattedData + "}";
+
+            return formattedData;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/46e575d8/src/windows/GlobalizationProxy/GlobalizationProxy/Globalization/SettableCultureInfo.cs
----------------------------------------------------------------------
diff --git a/src/windows/GlobalizationProxy/GlobalizationProxy/Globalization/SettableCultureInfo.cs b/src/windows/GlobalizationProxy/GlobalizationProxy/Globalization/SettableCultureInfo.cs
new file mode 100644
index 0000000..5a2de32
--- /dev/null
+++ b/src/windows/GlobalizationProxy/GlobalizationProxy/Globalization/SettableCultureInfo.cs
@@ -0,0 +1,36 @@
+/*  
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+*/
+
+using System.Globalization;
+
+namespace GlobalizationProxy.Globalization
+{
+    class SettableCultureInfo : CultureInfo
+    {
+        public SettableCultureInfo(string name)
+            : base(name)
+        {
+        }
+
+        public static void SubstituteCurrentLocale(string name)
+        {
+            CurrentCulture = new SettableCultureInfo(name);
+        }
+
+        /// <summary>
+        /// Overriding System.Globalization.CurrentCulture here
+        /// </summary>
+        public static new SettableCultureInfo CurrentCulture { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/46e575d8/src/windows/GlobalizationProxy/GlobalizationProxy/GlobalizationProxy.cs
----------------------------------------------------------------------
diff --git a/src/windows/GlobalizationProxy/GlobalizationProxy/GlobalizationProxy.cs b/src/windows/GlobalizationProxy/GlobalizationProxy/GlobalizationProxy.cs
new file mode 100644
index 0000000..fca9a61
--- /dev/null
+++ b/src/windows/GlobalizationProxy/GlobalizationProxy/GlobalizationProxy.cs
@@ -0,0 +1,107 @@
+/*  
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+*/
+
+using System;
+using System.Runtime.Serialization;
+using GlobalizationProxy.Cordova.JSON;
+using GlobalizationProxy.Globalization;
+
+namespace GlobalizationProxy
+{
+    public sealed class GlobalizationProxy
+    {
+        public static void SetLocale(string name)
+        {
+            SettableCultureInfo.SubstituteCurrentLocale(name);
+        }
+
+        private static string Invoke<T>(Func<string, T> action, string options, 
+            ErrorCode expectedErrorCode = ErrorCode.UnknownError)
+        {
+            object result;
+            try
+            {
+                result = action(options);
+            }
+            catch (SerializationException ex)
+            {
+                result = new GlobalizationError(ErrorCode.UnknownError, ex.Message);
+            }
+            catch (Exception ex)
+            {
+                // Using a method' specific expected error code here
+                result = new GlobalizationError(expectedErrorCode, ex.Message);
+            }
+
+            string resultJSON = result as string;
+            if (resultJSON != null)
+            {
+                return resultJSON;
+            }
+
+            // This is either a DataContract type or a GlobalizationError
+            return JsonHelper.Serialize(result);
+        }
+
+        public static string getLocaleName(string options)
+        {
+            return Invoke(GlobalizationImpl.getLocaleName, options);
+        }
+        
+        public static string isDayLightSavingsTime(string options)
+        {
+            return Invoke(GlobalizationImpl.isDayLightSavingsTime, options);
+        }
+
+        public static string getFirstDayOfWeek(string options)
+        {
+            return Invoke(GlobalizationImpl.getFirstDayOfWeek, options);
+        }
+
+        public static string dateToString(string options)
+        {
+            return Invoke(GlobalizationImpl.dateToString, options, ErrorCode.FormattingError);
+        }
+
+        public static string stringToDate(string options)
+        {
+            return Invoke(GlobalizationImpl.stringToDate, options, ErrorCode.ParsingError);
+        }
+
+        public static string getDateNames(string options)
+        {
+            return Invoke(GlobalizationImpl.getDateNames, options);
+        }
+
+        public static string numberToString(string options)
+        {
+            return Invoke(GlobalizationImpl.numberToString, options, ErrorCode.FormattingError);
+        }
+
+        public static string stringToNumber(string options)
+        {
+            return Invoke(GlobalizationImpl.stringToNumber, options, ErrorCode.ParsingError);
+        }
+
+        public static string getDatePattern(string options)
+        {
+            return Invoke(GlobalizationImpl.getDatePattern, options, ErrorCode.PatternError);
+        }
+
+        public static string getNumberPattern(string options)
+        {
+            return Invoke(GlobalizationImpl.getNumberPattern, options, ErrorCode.PatternError);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/46e575d8/src/windows/GlobalizationProxy/GlobalizationProxy/GlobalizationProxy.csproj
----------------------------------------------------------------------
diff --git a/src/windows/GlobalizationProxy/GlobalizationProxy/GlobalizationProxy.csproj b/src/windows/GlobalizationProxy/GlobalizationProxy/GlobalizationProxy.csproj
new file mode 100644
index 0000000..1c41f90
--- /dev/null
+++ b/src/windows/GlobalizationProxy/GlobalizationProxy/GlobalizationProxy.csproj
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{1133E9BE-C7CC-49FF-AEC7-4AE5BC35CCBC}</ProjectGuid>
+    <OutputType>winmdobj</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>GlobalizationProxy</RootNamespace>
+    <AssemblyName>GlobalizationProxy</AssemblyName>
+    <DefaultLanguage>en-US</DefaultLanguage>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE;NETFX_CORE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\ARM\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
+    <NoWarn>;2008</NoWarn>
+    <DebugType>full</DebugType>
+    <PlatformTarget>ARM</PlatformTarget>
+    <UseVSHostingProcess>false</UseVSHostingProcess>
+    <ErrorReport>prompt</ErrorReport>
+    <Prefer32Bit>true</Prefer32Bit>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
+    <OutputPath>bin\ARM\Release\</OutputPath>
+    <DefineConstants>TRACE;NETFX_CORE</DefineConstants>
+    <Optimize>true</Optimize>
+    <NoWarn>;2008</NoWarn>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>ARM</PlatformTarget>
+    <UseVSHostingProcess>false</UseVSHostingProcess>
+    <ErrorReport>prompt</ErrorReport>
+    <Prefer32Bit>true</Prefer32Bit>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\x64\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
+    <NoWarn>;2008</NoWarn>
+    <DebugType>full</DebugType>
+    <PlatformTarget>x64</PlatformTarget>
+    <UseVSHostingProcess>false</UseVSHostingProcess>
+    <ErrorReport>prompt</ErrorReport>
+    <Prefer32Bit>true</Prefer32Bit>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+    <OutputPath>bin\x64\Release\</OutputPath>
+    <DefineConstants>TRACE;NETFX_CORE</DefineConstants>
+    <Optimize>true</Optimize>
+    <NoWarn>;2008</NoWarn>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>x64</PlatformTarget>
+    <UseVSHostingProcess>false</UseVSHostingProcess>
+    <ErrorReport>prompt</ErrorReport>
+    <Prefer32Bit>true</Prefer32Bit>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\x86\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
+    <NoWarn>;2008</NoWarn>
+    <DebugType>full</DebugType>
+    <PlatformTarget>x86</PlatformTarget>
+    <UseVSHostingProcess>false</UseVSHostingProcess>
+    <ErrorReport>prompt</ErrorReport>
+    <Prefer32Bit>true</Prefer32Bit>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+    <OutputPath>bin\x86\Release\</OutputPath>
+    <DefineConstants>TRACE;NETFX_CORE</DefineConstants>
+    <Optimize>true</Optimize>
+    <NoWarn>;2008</NoWarn>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>x86</PlatformTarget>
+    <UseVSHostingProcess>false</UseVSHostingProcess>
+    <ErrorReport>prompt</ErrorReport>
+    <Prefer32Bit>true</Prefer32Bit>
+  </PropertyGroup>
+  <ItemGroup>
+    <!-- A reference to the entire .Net Framework and Windows SDK are automatically included -->
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Cordova\JSON\JsonHelper.cs">
+      <SubType>Code</SubType>
+    </Compile>
+    <Compile Include="GlobalizationProxy.cs" />
+    <Compile Include="Globalization\GlobalizationApiTypes.cs" />
+    <Compile Include="Globalization\GlobalizationImpl.cs" />
+    <Compile Include="Globalization\SettableCultureInfo.cs">
+      <SubType>Code</SubType>
+    </Compile>
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '11.0' ">
+    <VisualStudioVersion>11.0</VisualStudioVersion>
+  </PropertyGroup>
+  <Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
+  <PropertyGroup>
+    <PostBuildEvent>xcopy /Y /Q "$(TargetPath)" "$(SolutionDir).."</PostBuildEvent>
+  </PropertyGroup>
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/46e575d8/src/windows/GlobalizationProxy/GlobalizationProxy/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/src/windows/GlobalizationProxy/GlobalizationProxy/Properties/AssemblyInfo.cs b/src/windows/GlobalizationProxy/GlobalizationProxy/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..47862bd
--- /dev/null
+++ b/src/windows/GlobalizationProxy/GlobalizationProxy/Properties/AssemblyInfo.cs
@@ -0,0 +1,29 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("GlobalizationProxy")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("GlobalizationProxy")]
+[assembly: AssemblyCopyright("Copyright ©  2014")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: ComVisible(false)]
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message