Repository: incubator-weex
Updated Branches:
  refs/heads/master b2c19d324 -> dedc97575


[WEEX-139][ios]Provide system language infomation

Provide locale module, contains information about system language.
Example: [http://dotwe.org/vue/fc5e91d6f1a809bab2f073af53f4dd94]


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/dedc9757
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/dedc9757
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/dedc9757

Branch: refs/heads/master
Commit: dedc97575b1f94e9e69122f3ffe53618b59955a3
Parents: b2c19d3
Author: CYJB <f8c...@126.com>
Authored: Thu Nov 23 12:11:15 2017 +0800
Committer: acton393 <zhangxing610...@gmail.com>
Committed: Thu Nov 23 18:18:16 2017 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK.xcodeproj/project.pbxproj       | 12 ++++++
 ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.m    |  1 +
 ios/sdk/WeexSDK/Sources/Module/WXLocaleModule.h | 27 +++++++++++++
 ios/sdk/WeexSDK/Sources/Module/WXLocaleModule.m | 41 ++++++++++++++++++++
 4 files changed, 81 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/dedc9757/ios/sdk/WeexSDK.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK.xcodeproj/project.pbxproj 
b/ios/sdk/WeexSDK.xcodeproj/project.pbxproj
index f728c40..facb225 100644
--- a/ios/sdk/WeexSDK.xcodeproj/project.pbxproj
+++ b/ios/sdk/WeexSDK.xcodeproj/project.pbxproj
@@ -269,6 +269,10 @@
                841CD1061F974DFA0081196D /* WXExceptionUtils.h in Headers */ = 
{isa = PBXBuildFile; fileRef = 841CD1041F97399C0081196D /* WXExceptionUtils.h 
*/; settings = {ATTRIBUTES = (Public, ); }; };
                841CD1071F974E000081196D /* WXExceptionUtils.m in Sources */ = 
{isa = PBXBuildFile; fileRef = 841CD1021F9739890081196D /* WXExceptionUtils.m 
*/; };
                9B9E74791FA2DB5800DAAEA9 /* WXTestBridgeMethodDummy.m in 
Sources */ = {isa = PBXBuildFile; fileRef = 9B9E74781FA2DB5800DAAEA9 /* 
WXTestBridgeMethodDummy.m */; };
+               BA5F00F11FC5AFFE00F76B5C /* WXLocaleModule.h in Headers */ = 
{isa = PBXBuildFile; fileRef = BA5F00EF1FC5AFFE00F76B5C /* WXLocaleModule.h */; 
};
+               BA5F00F21FC5AFFE00F76B5C /* WXLocaleModule.m in Sources */ = 
{isa = PBXBuildFile; fileRef = BA5F00F01FC5AFFE00F76B5C /* WXLocaleModule.m */; 
};
+               BA5F00F31FC6834900F76B5C /* WXLocaleModule.h in Headers */ = 
{isa = PBXBuildFile; fileRef = BA5F00EF1FC5AFFE00F76B5C /* WXLocaleModule.h */; 
};
+               BA5F00F41FC6834C00F76B5C /* WXLocaleModule.m in Sources */ = 
{isa = PBXBuildFile; fileRef = BA5F00F01FC5AFFE00F76B5C /* WXLocaleModule.m */; 
};
                C401945E1E344E8300D19C31 /* WXFloatCompareTests.m in Sources */ 
= {isa = PBXBuildFile; fileRef = C401945D1E344E8300D19C31 /* 
WXFloatCompareTests.m */; };
                C41E1A971DC1FD15009C7F90 /* WXDatePickerManager.h in Headers */ 
= {isa = PBXBuildFile; fileRef = C41E1A951DC1FD15009C7F90 /* 
WXDatePickerManager.h */; };
                C41E1A981DC1FD15009C7F90 /* WXDatePickerManager.m in Sources */ 
= {isa = PBXBuildFile; fileRef = C41E1A961DC1FD15009C7F90 /* 
WXDatePickerManager.m */; };
@@ -860,6 +864,8 @@
                841CD1041F97399C0081196D /* WXExceptionUtils.h */ = {isa = 
PBXFileReference; lastKnownFileType = sourcecode.c.h; path = 
WXExceptionUtils.h; sourceTree = "<group>"; };
                9B9E74771FA2DB5800DAAEA9 /* WXTestBridgeMethodDummy.h */ = {isa 
= PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path 
= WXTestBridgeMethodDummy.h; sourceTree = "<group>"; };
                9B9E74781FA2DB5800DAAEA9 /* WXTestBridgeMethodDummy.m */ = {isa 
= PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; 
path = WXTestBridgeMethodDummy.m; sourceTree = "<group>"; };
+               BA5F00EF1FC5AFFE00F76B5C /* WXLocaleModule.h */ = {isa = 
PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WXLocaleModule.h; 
sourceTree = "<group>"; };
+               BA5F00F01FC5AFFE00F76B5C /* WXLocaleModule.m */ = {isa = 
PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = 
WXLocaleModule.m; sourceTree = "<group>"; };
                C401945D1E344E8300D19C31 /* WXFloatCompareTests.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= WXFloatCompareTests.m; sourceTree = "<group>"; };
                C41E1A951DC1FD15009C7F90 /* WXDatePickerManager.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
WXDatePickerManager.h; sourceTree = "<group>"; };
                C41E1A961DC1FD15009C7F90 /* WXDatePickerManager.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= WXDatePickerManager.m; sourceTree = "<group>"; };
@@ -1411,6 +1417,8 @@
                77E659D71C07F585008B8775 /* Module */ = {
                        isa = PBXGroup;
                        children = (
+                               BA5F00EF1FC5AFFE00F76B5C /* WXLocaleModule.h */,
+                               BA5F00F01FC5AFFE00F76B5C /* WXLocaleModule.m */,
                                DCE2CF981F46D4220021BDC4 /* WXVoiceOverModule.m 
*/,
                                DCE2CF991F46D4220021BDC4 /* WXVoiceOverModule.h 
*/,
                                333D9A251F41507A007CED39 /* WXTransition.h */,
@@ -1701,6 +1709,7 @@
                                74D205201E091B8000128F44 /* WXCallJSMethod.h in 
Headers */,
                                741DFE061DDD9B30009B020F /* UIBezierPath+Weex.h 
in Headers */,
                                2AAFC1B61C48DFF70026D2FE /* WXSDKError.h in 
Headers */,
+                               BA5F00F11FC5AFFE00F76B5C /* WXLocaleModule.h in 
Headers */,
                                742AD72E1DF98C45007DC46C /* WXResourceRequest.h 
in Headers */,
                                D317338C1C57257000BB7539 /* WXTransform.h in 
Headers */,
                                77D161301C02DE4E0010B15B /* WXComponent.h in 
Headers */,
@@ -1776,6 +1785,7 @@
                                DCA445EC1EFA5A0E00D0CFA8 /* 
WXTextAreaComponent.h in Headers */,
                                DCA445D81EFA599400D0CFA8 /* WXRootView.h in 
Headers */,
                                DCA446131EFA5A8C00D0CFA8 /* WXCallJSMethod.h in 
Headers */,
+                               BA5F00F31FC6834900F76B5C /* WXLocaleModule.h in 
Headers */,
                                74B81AED1F73C3E900D3A61D /* 
WXCellSlotComponent.h in Headers */,
                                DCA445E41EFA59DC00D0CFA8 /* WXVideoComponent.h 
in Headers */,
                                DCA4460B1EFA5A7200D0CFA8 /* WXAssert.h in 
Headers */,
@@ -2141,6 +2151,7 @@
                                744BEA5A1D0520F300452B5D /* 
WXComponent+Layout.m in Sources */,
                                59A582FD1CF5B17B0081FD3E /* WXBridgeContext.m 
in Sources */,
                                743933B51C7ED9AA00773BB7 /* 
WXSimulatorShortcutManager.m in Sources */,
+                               BA5F00F21FC5AFFE00F76B5C /* WXLocaleModule.m in 
Sources */,
                                74BB5FBA1DFEE81A004FC3DF /* WXMetaModule.m in 
Sources */,
                                741081201CED585A001BC6E5 /* 
WXComponentManager.m in Sources */,
                                1D3000F21D40B9AC004F3B4F /* WXClipboardModule.m 
in Sources */,
@@ -2237,6 +2248,7 @@
                        isa = PBXSourcesBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
+                               BA5F00F41FC6834C00F76B5C /* WXLocaleModule.m in 
Sources */,
                                DCA4452D1EFA55B300D0CFA8 /* 
WXComponent+Layout.m in Sources */,
                                DCA4452F1EFA55B300D0CFA8 /* WXResourceLoader.m 
in Sources */,
                                DCA445301EFA55B300D0CFA8 /* 
WXComponent+Events.m in Sources */,

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/dedc9757/ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.m 
b/ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.m
index fbd62b9..4e1d5b7 100644
--- a/ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.m
+++ b/ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.m
@@ -47,6 +47,7 @@
 + (void)_registerDefaultModules
 {
     [self registerModule:@"dom" withClass:NSClassFromString(@"WXDomModule")];
+    [self registerModule:@"locale" 
withClass:NSClassFromString(@"WXLocaleModule")];
     [self registerModule:@"navigator" 
withClass:NSClassFromString(@"WXNavigatorModule")];
     [self registerModule:@"stream" 
withClass:NSClassFromString(@"WXStreamModule")];
     [self registerModule:@"animation" 
withClass:NSClassFromString(@"WXAnimationModule")];

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/dedc9757/ios/sdk/WeexSDK/Sources/Module/WXLocaleModule.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Module/WXLocaleModule.h 
b/ios/sdk/WeexSDK/Sources/Module/WXLocaleModule.h
new file mode 100644
index 0000000..79d9464
--- /dev/null
+++ b/ios/sdk/WeexSDK/Sources/Module/WXLocaleModule.h
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+#import <Foundation/Foundation.h>
+#import "WXModuleProtocol.h"
+
+/**
+ Provide system language information.
+ */
+@interface WXLocaleModule : NSObject <WXModuleProtocol>
+@end

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/dedc9757/ios/sdk/WeexSDK/Sources/Module/WXLocaleModule.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Module/WXLocaleModule.m 
b/ios/sdk/WeexSDK/Sources/Module/WXLocaleModule.m
new file mode 100644
index 0000000..c993ddc
--- /dev/null
+++ b/ios/sdk/WeexSDK/Sources/Module/WXLocaleModule.m
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+#import "WXLocaleModule.h"
+
+@implementation WXLocaleModule
+
+WX_EXPORT_METHOD_SYNC(@selector(getLanguage))
+WX_EXPORT_METHOD_SYNC(@selector(getLanguages))
+
+/**
+ Get preferred language of the user
+ */
+- (NSString *)getLanguage {
+       return [NSLocale preferredLanguages][0];
+}
+
+/**
+ Get an array of strings representing the user's preferred languages
+ */
+- (NSArray<NSString *> *)getLanguages {
+       return [NSLocale preferredLanguages];
+}
+
+@end

Reply via email to