diff --git a/example/ReactNativeLocizeProject/.bundle/config b/example/ReactNativeLocizeProject/.bundle/config new file mode 100644 index 00000000..848943bb --- /dev/null +++ b/example/ReactNativeLocizeProject/.bundle/config @@ -0,0 +1,2 @@ +BUNDLE_PATH: "vendor/bundle" +BUNDLE_FORCE_RUBY_PLATFORM: 1 diff --git a/example/ReactNativeLocizeProject/.eslintrc.js b/example/ReactNativeLocizeProject/.eslintrc.js new file mode 100644 index 00000000..187894b6 --- /dev/null +++ b/example/ReactNativeLocizeProject/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + root: true, + extends: '@react-native', +}; diff --git a/example/react-native/.gitignore b/example/ReactNativeLocizeProject/.gitignore similarity index 68% rename from example/react-native/.gitignore rename to example/ReactNativeLocizeProject/.gitignore index 5d647565..0cab2ac6 100644 --- a/example/react-native/.gitignore +++ b/example/ReactNativeLocizeProject/.gitignore @@ -20,7 +20,7 @@ DerivedData *.hmap *.ipa *.xcuserstate -project.xcworkspace +ios/.xcode.env.local # Android/IntelliJ # @@ -29,6 +29,10 @@ build/ .gradle local.properties *.iml +*.hprof +.cxx/ +*.keystore +!debug.keystore # node.js # @@ -36,11 +40,6 @@ node_modules/ npm-debug.log yarn-error.log -# BUCK -buck-out/ -\.buckd/ -*.keystore - # fastlane # # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the @@ -48,9 +47,20 @@ buck-out/ # For more information about the recommended setup visit: # https://docs.fastlane.tools/best-practices/source-control/ -*/fastlane/report.xml -*/fastlane/Preview.html -*/fastlane/screenshots +**/fastlane/report.xml +**/fastlane/Preview.html +**/fastlane/screenshots +**/fastlane/test_output # Bundle artifact *.jsbundle + +# Ruby / CocoaPods +/ios/Pods/ +/vendor/bundle/ + +# Temporary files created by Metro to check the health of the file watcher +.metro-health-check* + +# testing +/coverage diff --git a/example/ReactNativeLocizeProject/.prettierrc.js b/example/ReactNativeLocizeProject/.prettierrc.js new file mode 100644 index 00000000..2b540746 --- /dev/null +++ b/example/ReactNativeLocizeProject/.prettierrc.js @@ -0,0 +1,7 @@ +module.exports = { + arrowParens: 'avoid', + bracketSameLine: true, + bracketSpacing: false, + singleQuote: true, + trailingComma: 'all', +}; diff --git a/example/ReactNativeLocizeProject/.watchmanconfig b/example/ReactNativeLocizeProject/.watchmanconfig new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/example/ReactNativeLocizeProject/.watchmanconfig @@ -0,0 +1 @@ +{} diff --git a/example/ReactNativeLocizeProject/App.tsx b/example/ReactNativeLocizeProject/App.tsx new file mode 100644 index 00000000..d3ee97a5 --- /dev/null +++ b/example/ReactNativeLocizeProject/App.tsx @@ -0,0 +1,59 @@ +import {Suspense, Component} from 'react'; +import {Text, Button, View, TouchableOpacity} from 'react-native'; +import {useTranslation, withTranslation, Trans} from 'react-i18next'; + +// use hoc for class based components +class LegacyWelcomeClass extends Component { + render() { + const {t} = this.props; + return {t('title')}; + } +} +const Welcome = withTranslation()(LegacyWelcomeClass); + +// Component using the Trans component +function MyComponent() { + return ( + + + To get started, edit src/App.js and save to reload. + + + ); +} + +function AppInner() { + const {t, i18n} = useTranslation(); + + const changeLanguage = lng => { + i18n.changeLanguage(lng); + }; + + return ( + + + +