Showing
15 changed files
with
139 additions
and
10 deletions
| @@ -12,6 +12,7 @@ import React from 'react'; | @@ -12,6 +12,7 @@ import React from 'react'; | ||
| 12 | import { DarkModeProvider } from 'react-native-dark-mode'; | 12 | import { DarkModeProvider } from 'react-native-dark-mode'; |
| 13 | import { enableScreens } from 'react-native-screens'; | 13 | import { enableScreens } from 'react-native-screens'; |
| 14 | import AppNavigationContainer from './src/screen/AppNavigationContainer'; | 14 | import AppNavigationContainer from './src/screen/AppNavigationContainer'; |
| 15 | +import { I18NProvider } from './src/i18n'; | ||
| 15 | 16 | ||
| 16 | if (__DEV__) { | 17 | if (__DEV__) { |
| 17 | const whyDidYouRender = require('@welldone-software/why-did-you-render'); | 18 | const whyDidYouRender = require('@welldone-software/why-did-you-render'); |
| @@ -24,9 +25,11 @@ enableScreens(); | @@ -24,9 +25,11 @@ enableScreens(); | ||
| 24 | 25 | ||
| 25 | const App = () => { | 26 | const App = () => { |
| 26 | return ( | 27 | return ( |
| 27 | - <DarkModeProvider> | 28 | + <I18NProvider> |
| 28 | - <AppNavigationContainer /> | 29 | + <DarkModeProvider> |
| 29 | - </DarkModeProvider> | 30 | + <AppNavigationContainer /> |
| 31 | + </DarkModeProvider> | ||
| 32 | + </I18NProvider> | ||
| 30 | ); | 33 | ); |
| 31 | }; | 34 | }; |
| 32 | 35 |
| @@ -64,6 +64,7 @@ | @@ -64,6 +64,7 @@ | ||
| 64 | 8362A23EE219E5DDEC7EAE08 /* libPods-NGPlay-tvOSTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-NGPlay-tvOSTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; | 64 | 8362A23EE219E5DDEC7EAE08 /* libPods-NGPlay-tvOSTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-NGPlay-tvOSTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; |
| 65 | B9229FB3695E83651E4D11D5 /* Pods-NGPlay-tvOSTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NGPlay-tvOSTests.release.xcconfig"; path = "Target Support Files/Pods-NGPlay-tvOSTests/Pods-NGPlay-tvOSTests.release.xcconfig"; sourceTree = "<group>"; }; | 65 | B9229FB3695E83651E4D11D5 /* Pods-NGPlay-tvOSTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NGPlay-tvOSTests.release.xcconfig"; path = "Target Support Files/Pods-NGPlay-tvOSTests/Pods-NGPlay-tvOSTests.release.xcconfig"; sourceTree = "<group>"; }; |
| 66 | C4732ECC7CC9112665571B01 /* libPods-NGPlay-NGPlayTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-NGPlay-NGPlayTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; | 66 | C4732ECC7CC9112665571B01 /* libPods-NGPlay-NGPlayTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-NGPlay-NGPlayTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; |
| 67 | + CE18667F24480E4200FBDC7A /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/LaunchScreen.strings"; sourceTree = "<group>"; }; | ||
| 67 | ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; | 68 | ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; |
| 68 | ED2971642150620600B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS12.0.sdk/System/Library/Frameworks/JavaScriptCore.framework; sourceTree = DEVELOPER_DIR; }; | 69 | ED2971642150620600B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS12.0.sdk/System/Library/Frameworks/JavaScriptCore.framework; sourceTree = DEVELOPER_DIR; }; |
| 69 | F63897AFB5B07795089F34F9 /* Pods-NGPlay-tvOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NGPlay-tvOS.release.xcconfig"; path = "Target Support Files/Pods-NGPlay-tvOS/Pods-NGPlay-tvOS.release.xcconfig"; sourceTree = "<group>"; }; | 70 | F63897AFB5B07795089F34F9 /* Pods-NGPlay-tvOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NGPlay-tvOS.release.xcconfig"; path = "Target Support Files/Pods-NGPlay-tvOS/Pods-NGPlay-tvOS.release.xcconfig"; sourceTree = "<group>"; }; |
| @@ -314,6 +315,7 @@ | @@ -314,6 +315,7 @@ | ||
| 314 | knownRegions = ( | 315 | knownRegions = ( |
| 315 | en, | 316 | en, |
| 316 | Base, | 317 | Base, |
| 318 | + "zh-Hans", | ||
| 317 | ); | 319 | ); |
| 318 | mainGroup = 83CBB9F61A601CBA00E9B192; | 320 | mainGroup = 83CBB9F61A601CBA00E9B192; |
| 319 | productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */; | 321 | productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */; |
| @@ -670,6 +672,7 @@ | @@ -670,6 +672,7 @@ | ||
| 670 | isa = PBXVariantGroup; | 672 | isa = PBXVariantGroup; |
| 671 | children = ( | 673 | children = ( |
| 672 | 13B07FB21A68108700A75B9A /* Base */, | 674 | 13B07FB21A68108700A75B9A /* Base */, |
| 675 | + CE18667F24480E4200FBDC7A /* zh-Hans */, | ||
| 673 | ); | 676 | ); |
| 674 | name = LaunchScreen.xib; | 677 | name = LaunchScreen.xib; |
| 675 | path = NGPlay; | 678 | path = NGPlay; |
| 1 | -<?xml version="1.0" encoding="UTF-8" standalone="no"?> | 1 | +<?xml version="1.0" encoding="UTF-8"?> |
| 2 | -<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7702" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES"> | 2 | +<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES"> |
| 3 | + <device id="retina6_1" orientation="portrait" appearance="light"/> | ||
| 3 | <dependencies> | 4 | <dependencies> |
| 4 | <deployment identifier="iOS"/> | 5 | <deployment identifier="iOS"/> |
| 5 | - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7701"/> | 6 | + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16086"/> |
| 6 | - <capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/> | 7 | + <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> |
| 7 | </dependencies> | 8 | </dependencies> |
| 8 | <objects> | 9 | <objects> |
| 9 | <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> | 10 | <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> |
| @@ -12,20 +13,20 @@ | @@ -12,20 +13,20 @@ | ||
| 12 | <rect key="frame" x="0.0" y="0.0" width="480" height="480"/> | 13 | <rect key="frame" x="0.0" y="0.0" width="480" height="480"/> |
| 13 | <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | 14 | <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> |
| 14 | <subviews> | 15 | <subviews> |
| 15 | - <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Powered by React Native" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye"> | 16 | + <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Powered by React Native" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye"> |
| 16 | <rect key="frame" x="20" y="439" width="441" height="21"/> | 17 | <rect key="frame" x="20" y="439" width="441" height="21"/> |
| 17 | <fontDescription key="fontDescription" type="system" pointSize="17"/> | 18 | <fontDescription key="fontDescription" type="system" pointSize="17"/> |
| 18 | <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> | 19 | <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> |
| 19 | <nil key="highlightedColor"/> | 20 | <nil key="highlightedColor"/> |
| 20 | </label> | 21 | </label> |
| 21 | - <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="NGPlay" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX"> | 22 | + <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="NGPlay" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX"> |
| 22 | <rect key="frame" x="20" y="140" width="441" height="43"/> | 23 | <rect key="frame" x="20" y="140" width="441" height="43"/> |
| 23 | <fontDescription key="fontDescription" type="boldSystem" pointSize="36"/> | 24 | <fontDescription key="fontDescription" type="boldSystem" pointSize="36"/> |
| 24 | <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> | 25 | <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> |
| 25 | <nil key="highlightedColor"/> | 26 | <nil key="highlightedColor"/> |
| 26 | </label> | 27 | </label> |
| 27 | </subviews> | 28 | </subviews> |
| 28 | - <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> | 29 | + <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> |
| 29 | <constraints> | 30 | <constraints> |
| 30 | <constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="5cJ-9S-tgC"/> | 31 | <constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="5cJ-9S-tgC"/> |
| 31 | <constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk"/> | 32 | <constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk"/> |
| @@ -306,6 +306,8 @@ PODS: | @@ -306,6 +306,8 @@ PODS: | ||
| 306 | - React | 306 | - React |
| 307 | - RNGestureHandler (1.6.1): | 307 | - RNGestureHandler (1.6.1): |
| 308 | - React | 308 | - React |
| 309 | + - RNLocalize (1.4.0): | ||
| 310 | + - React | ||
| 309 | - RNReanimated (1.7.1): | 311 | - RNReanimated (1.7.1): |
| 310 | - React | 312 | - React |
| 311 | - RNScreens (2.4.0): | 313 | - RNScreens (2.4.0): |
| @@ -356,6 +358,7 @@ DEPENDENCIES: | @@ -356,6 +358,7 @@ DEPENDENCIES: | ||
| 356 | - "RNCMaskedView (from `../node_modules/@react-native-community/masked-view`)" | 358 | - "RNCMaskedView (from `../node_modules/@react-native-community/masked-view`)" |
| 357 | - RNDeviceInfo (from `../node_modules/react-native-device-info`) | 359 | - RNDeviceInfo (from `../node_modules/react-native-device-info`) |
| 358 | - RNGestureHandler (from `../node_modules/react-native-gesture-handler`) | 360 | - RNGestureHandler (from `../node_modules/react-native-gesture-handler`) |
| 361 | + - RNLocalize (from `../node_modules/react-native-localize`) | ||
| 359 | - RNReanimated (from `../node_modules/react-native-reanimated`) | 362 | - RNReanimated (from `../node_modules/react-native-reanimated`) |
| 360 | - RNScreens (from `../node_modules/react-native-screens`) | 363 | - RNScreens (from `../node_modules/react-native-screens`) |
| 361 | - RNVectorIcons (from `../node_modules/react-native-vector-icons`) | 364 | - RNVectorIcons (from `../node_modules/react-native-vector-icons`) |
| @@ -439,6 +442,8 @@ EXTERNAL SOURCES: | @@ -439,6 +442,8 @@ EXTERNAL SOURCES: | ||
| 439 | :path: "../node_modules/react-native-device-info" | 442 | :path: "../node_modules/react-native-device-info" |
| 440 | RNGestureHandler: | 443 | RNGestureHandler: |
| 441 | :path: "../node_modules/react-native-gesture-handler" | 444 | :path: "../node_modules/react-native-gesture-handler" |
| 445 | + RNLocalize: | ||
| 446 | + :path: "../node_modules/react-native-localize" | ||
| 442 | RNReanimated: | 447 | RNReanimated: |
| 443 | :path: "../node_modules/react-native-reanimated" | 448 | :path: "../node_modules/react-native-reanimated" |
| 444 | RNScreens: | 449 | RNScreens: |
| @@ -491,6 +496,7 @@ SPEC CHECKSUMS: | @@ -491,6 +496,7 @@ SPEC CHECKSUMS: | ||
| 491 | RNCMaskedView: 76c40a1d41c3e2535df09246a2b5487f04de0814 | 496 | RNCMaskedView: 76c40a1d41c3e2535df09246a2b5487f04de0814 |
| 492 | RNDeviceInfo: 6a3d16fce033f6979c4a6a41e62244d183e8c765 | 497 | RNDeviceInfo: 6a3d16fce033f6979c4a6a41e62244d183e8c765 |
| 493 | RNGestureHandler: 8f09cd560f8d533eb36da5a6c5a843af9f056b38 | 498 | RNGestureHandler: 8f09cd560f8d533eb36da5a6c5a843af9f056b38 |
| 499 | + RNLocalize: b6df30cc25ae736d37874f9bce13351db2f56796 | ||
| 494 | RNReanimated: 4e102df74a9674fa943e05f97f3362b6e44d0b48 | 500 | RNReanimated: 4e102df74a9674fa943e05f97f3362b6e44d0b48 |
| 495 | RNScreens: b5c0e1b2b04512919e78bd3898e144a157ce2363 | 501 | RNScreens: b5c0e1b2b04512919e78bd3898e144a157ce2363 |
| 496 | RNVectorIcons: 0bb4def82230be1333ddaeee9fcba45f0b288ed4 | 502 | RNVectorIcons: 0bb4def82230be1333ddaeee9fcba45f0b288ed4 |
| @@ -27,6 +27,7 @@ | @@ -27,6 +27,7 @@ | ||
| 27 | "react-native-device-info": "^5.5.4", | 27 | "react-native-device-info": "^5.5.4", |
| 28 | "react-native-elements": "^1.2.7", | 28 | "react-native-elements": "^1.2.7", |
| 29 | "react-native-gesture-handler": "^1.6.1", | 29 | "react-native-gesture-handler": "^1.6.1", |
| 30 | + "react-native-localize": "^1.4.0", | ||
| 30 | "react-native-progress": "^4.1.2", | 31 | "react-native-progress": "^4.1.2", |
| 31 | "react-native-reanimated": "^1.7.1", | 32 | "react-native-reanimated": "^1.7.1", |
| 32 | "react-native-safe-area-context": "^0.7.3", | 33 | "react-native-safe-area-context": "^0.7.3", |
src/i18n/I18NContext.tsx
0 → 100644
| 1 | +import React, { useState, useEffect, FC, useContext, useCallback } from 'react'; | ||
| 2 | +import * as RNLocalize from 'react-native-localize'; | ||
| 3 | +import { I18NStrings, en } from './en'; | ||
| 4 | +import { zh } from './zh'; | ||
| 5 | +import { I18nManager } from 'react-native'; | ||
| 6 | + | ||
| 7 | +const availableTranslations = { en, zh }; | ||
| 8 | + | ||
| 9 | +const I18NContext = React.createContext<I18NStrings>(en); | ||
| 10 | + | ||
| 11 | +export const I18NProvider: FC = ({ children }) => { | ||
| 12 | + const [translation, setTranslation] = useState(en); | ||
| 13 | + | ||
| 14 | + const updateTranslation = useCallback(() => { | ||
| 15 | + const fallback = { languageTag: 'en', isRTL: false } as const; | ||
| 16 | + const { languageTag, isRTL } = | ||
| 17 | + RNLocalize.findBestAvailableLanguage(['en', 'zh']) || fallback; | ||
| 18 | + | ||
| 19 | + I18nManager.forceRTL(isRTL); | ||
| 20 | + setTranslation(availableTranslations[languageTag]); | ||
| 21 | + }, []); | ||
| 22 | + | ||
| 23 | + useEffect(() => { | ||
| 24 | + updateTranslation(); | ||
| 25 | + RNLocalize.addEventListener('change', updateTranslation); | ||
| 26 | + return () => { | ||
| 27 | + RNLocalize.removeEventListener('change', updateTranslation); | ||
| 28 | + }; | ||
| 29 | + }, [updateTranslation]); | ||
| 30 | + | ||
| 31 | + return ( | ||
| 32 | + <I18NContext.Provider value={translation}>{children}</I18NContext.Provider> | ||
| 33 | + ); | ||
| 34 | +}; | ||
| 35 | + | ||
| 36 | +export function useI18nStrings() { | ||
| 37 | + return useContext(I18NContext); | ||
| 38 | +} |
src/i18n/en.ts
0 → 100644
src/i18n/index.ts
0 → 100644
| 1 | +export * from './I18NContext'; |
src/i18n/zh.ts
0 → 100644
| @@ -18,6 +18,8 @@ import { themeForNav } from '../design'; | @@ -18,6 +18,8 @@ import { themeForNav } from '../design'; | ||
| 18 | import RNDeviceInfoList from './RNDeviceInfo'; | 18 | import RNDeviceInfoList from './RNDeviceInfo'; |
| 19 | import WebviewScreen from './WebviewScreen'; | 19 | import WebviewScreen from './WebviewScreen'; |
| 20 | import { Platform } from 'react-native'; | 20 | import { Platform } from 'react-native'; |
| 21 | +import RNLocalize from './RNLocalize'; | ||
| 22 | +import { useI18nStrings } from '../i18n'; | ||
| 21 | 23 | ||
| 22 | const MainTab = createBottomTabNavigator<MainTabParamList>(); | 24 | const MainTab = createBottomTabNavigator<MainTabParamList>(); |
| 23 | 25 | ||
| @@ -78,6 +80,7 @@ const MainStack = createStackNavigator<MainStackParamList>(); | @@ -78,6 +80,7 @@ const MainStack = createStackNavigator<MainStackParamList>(); | ||
| 78 | 80 | ||
| 79 | const Container = () => { | 81 | const Container = () => { |
| 80 | const inDarkMode = useDarkMode(); | 82 | const inDarkMode = useDarkMode(); |
| 83 | + const strings = useI18nStrings(); | ||
| 81 | return ( | 84 | return ( |
| 82 | <NavigationContainer | 85 | <NavigationContainer |
| 83 | theme={inDarkMode ? themeForNav.dark : themeForNav.light} | 86 | theme={inDarkMode ? themeForNav.dark : themeForNav.light} |
| @@ -85,6 +88,7 @@ const Container = () => { | @@ -85,6 +88,7 @@ const Container = () => { | ||
| 85 | <MainStack.Navigator | 88 | <MainStack.Navigator |
| 86 | screenOptions={{ | 89 | screenOptions={{ |
| 87 | headerStyleInterpolator: HeaderStyleInterpolators.forUIKit, | 90 | headerStyleInterpolator: HeaderStyleInterpolators.forUIKit, |
| 91 | + headerTruncatedBackTitle: strings.navigation.back, | ||
| 88 | }} | 92 | }} |
| 89 | > | 93 | > |
| 90 | <MainStack.Screen | 94 | <MainStack.Screen |
| @@ -106,6 +110,7 @@ const Container = () => { | @@ -106,6 +110,7 @@ const Container = () => { | ||
| 106 | animationEnabled: Platform.OS === 'ios', | 110 | animationEnabled: Platform.OS === 'ios', |
| 107 | })} | 111 | })} |
| 108 | /> | 112 | /> |
| 113 | + <MainStack.Screen name="RNLocalize" component={RNLocalize} /> | ||
| 109 | </MainStack.Navigator> | 114 | </MainStack.Navigator> |
| 110 | </NavigationContainer> | 115 | </NavigationContainer> |
| 111 | ); | 116 | ); |
src/screen/RNLocalize.tsx
0 → 100644
| 1 | +import React from 'react'; | ||
| 2 | +import * as LocalizeModule from 'react-native-localize'; | ||
| 3 | +import { BGList, ListItem } from '../component/View'; | ||
| 4 | + | ||
| 5 | +const keys = [ | ||
| 6 | + 'getCalendar', | ||
| 7 | + 'getCountry', | ||
| 8 | + 'getCurrencies', | ||
| 9 | + 'getLocales', | ||
| 10 | + 'getNumberFormatSettings', | ||
| 11 | + 'getTemperatureUnit', | ||
| 12 | + 'getTimeZone', | ||
| 13 | + 'uses24HourClock', | ||
| 14 | + 'usesMetricSystem', | ||
| 15 | + 'usesAutoDateAndTime', | ||
| 16 | + 'usesAutoTimeZone', | ||
| 17 | +] as const; | ||
| 18 | + | ||
| 19 | +const RNLocalize = () => { | ||
| 20 | + return ( | ||
| 21 | + <BGList | ||
| 22 | + data={keys} | ||
| 23 | + renderItem={({ item }) => ( | ||
| 24 | + <ListItem | ||
| 25 | + title={item} | ||
| 26 | + rightTitle={JSON.stringify(LocalizeModule[item]())} | ||
| 27 | + /> | ||
| 28 | + )} | ||
| 29 | + /> | ||
| 30 | + ); | ||
| 31 | +}; | ||
| 32 | + | ||
| 33 | +export default RNLocalize; |
| @@ -3,6 +3,7 @@ import { useWindowDimensions } from 'react-native'; | @@ -3,6 +3,7 @@ import { useWindowDimensions } from 'react-native'; | ||
| 3 | import { screensEnabled } from 'react-native-screens'; | 3 | import { screensEnabled } from 'react-native-screens'; |
| 4 | import { ListItem, BGScroll, Card, Divider } from '../component/View'; | 4 | import { ListItem, BGScroll, Card, Divider } from '../component/View'; |
| 5 | import { MainTabScreenProps } from '../type/Navigation'; | 5 | import { MainTabScreenProps } from '../type/Navigation'; |
| 6 | +import { useI18nStrings } from '../i18n'; | ||
| 6 | 7 | ||
| 7 | declare var global: { HermesInternal: null | {} }; | 8 | declare var global: { HermesInternal: null | {} }; |
| 8 | 9 | ||
| @@ -10,6 +11,7 @@ const SystemInfo = ({ | @@ -10,6 +11,7 @@ const SystemInfo = ({ | ||
| 10 | navigation, | 11 | navigation, |
| 11 | route, | 12 | route, |
| 12 | }: MainTabScreenProps<'SystemInfo'>) => { | 13 | }: MainTabScreenProps<'SystemInfo'>) => { |
| 14 | + const strings = useI18nStrings(); | ||
| 13 | const { width, height, fontScale, scale } = useWindowDimensions(); | 15 | const { width, height, fontScale, scale } = useWindowDimensions(); |
| 14 | return ( | 16 | return ( |
| 15 | <BGScroll white> | 17 | <BGScroll white> |
| @@ -56,6 +58,14 @@ const SystemInfo = ({ | @@ -56,6 +58,14 @@ const SystemInfo = ({ | ||
| 56 | uri: 'https://www.baidu.com', | 58 | uri: 'https://www.baidu.com', |
| 57 | }) | 59 | }) |
| 58 | } | 60 | } |
| 61 | + chevron | ||
| 62 | + /> | ||
| 63 | + <Divider /> | ||
| 64 | + <ListItem | ||
| 65 | + title={'RNLocalize'} | ||
| 66 | + onPress={() => navigation.navigate('RNLocalize')} | ||
| 67 | + rightTitle={strings.name} | ||
| 68 | + chevron | ||
| 59 | /> | 69 | /> |
| 60 | </Card> | 70 | </Card> |
| 61 | </BGScroll> | 71 | </BGScroll> |
| @@ -11,6 +11,7 @@ export type MainStackParamList = { | @@ -11,6 +11,7 @@ export type MainStackParamList = { | ||
| 11 | MainTab: undefined; | 11 | MainTab: undefined; |
| 12 | RNDeviceInfoList: undefined; | 12 | RNDeviceInfoList: undefined; |
| 13 | WebviewScreen: { uri: string } | undefined; | 13 | WebviewScreen: { uri: string } | undefined; |
| 14 | + RNLocalize: undefined; | ||
| 14 | }; | 15 | }; |
| 15 | 16 | ||
| 16 | export type MainTabScreenProps<RouteName extends keyof MainTabParamList> = { | 17 | export type MainTabScreenProps<RouteName extends keyof MainTabParamList> = { |
| @@ -6920,6 +6920,11 @@ react-native-iphone-x-helper@^1.2.1: | @@ -6920,6 +6920,11 @@ react-native-iphone-x-helper@^1.2.1: | ||
| 6920 | resolved "https://registry.npm.taobao.org/react-native-iphone-x-helper/download/react-native-iphone-x-helper-1.2.1.tgz#645e2ffbbb49e80844bb4cbbe34a126fda1e6772" | 6920 | resolved "https://registry.npm.taobao.org/react-native-iphone-x-helper/download/react-native-iphone-x-helper-1.2.1.tgz#645e2ffbbb49e80844bb4cbbe34a126fda1e6772" |
| 6921 | integrity sha1-ZF4v+7tJ6AhEu0y740oSb9oeZ3I= | 6921 | integrity sha1-ZF4v+7tJ6AhEu0y740oSb9oeZ3I= |
| 6922 | 6922 | ||
| 6923 | +react-native-localize@^1.4.0: | ||
| 6924 | + version "1.4.0" | ||
| 6925 | + resolved "https://registry.npm.taobao.org/react-native-localize/download/react-native-localize-1.4.0.tgz#4653596d066d0941c48f5404dc1c0d08b6950443" | ||
| 6926 | + integrity sha1-RlNZbQZtCUHEj1QE3BwNCLaVBEM= | ||
| 6927 | + | ||
| 6923 | react-native-progress@^4.1.2: | 6928 | react-native-progress@^4.1.2: |
| 6924 | version "4.1.2" | 6929 | version "4.1.2" |
| 6925 | resolved "https://registry.npm.taobao.org/react-native-progress/download/react-native-progress-4.1.2.tgz#ffb2264ddfeba409c730e36a9791bb7bbe07a00d" | 6930 | resolved "https://registry.npm.taobao.org/react-native-progress/download/react-native-progress-4.1.2.tgz#ffb2264ddfeba409c730e36a9791bb7bbe07a00d" |
-
Please register or login to post a comment