Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/adapter-react/examples/react-native/.buckconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

[android]
target = Google Inc.:Google APIs:23

[maven_repositories]
central = https://repo1.maven.org/maven2
16 changes: 16 additions & 0 deletions packages/adapter-react/examples/react-native/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
root: true,
extends: '@react-native-community',
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
overrides: [
{
files: ['*.ts', '*.tsx'],
rules: {
'@typescript-eslint/no-shadow': ['error'],
'no-shadow': 'off',
'no-undef': 'off',
},
},
],
};
64 changes: 64 additions & 0 deletions packages/adapter-react/examples/react-native/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
ios/.xcode.env.local

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml
*.hprof
.cxx/

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
*.keystore
!debug.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# 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/test_output

# Bundle artifact
*.jsbundle

# Ruby / CocoaPods
/ios/Pods/
/vendor/bundle/
7 changes: 7 additions & 0 deletions packages/adapter-react/examples/react-native/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
arrowParens: 'avoid',
bracketSameLine: true,
bracketSpacing: false,
singleQuote: true,
trailingComma: 'all',
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"adapter": "react",
"$schema": "https://unpkg.com/typesafe-i18n@5.17.1/schema/typesafe-i18n.json"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
6 changes: 6 additions & 0 deletions packages/adapter-react/examples/react-native/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source 'https://rubygems.org'

# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby '2.7.5'

gem 'cocoapods', '~> 1.11', '>= 1.11.2'
34 changes: 34 additions & 0 deletions packages/adapter-react/examples/react-native/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# `typesafe-i18n` bare react-native example

**This example shows how you could use `typesafe-i18n` in an bare react-native application.**

_There are many ways you could integrate the library and its i18n process into your applications. As probably all applications and workflows are different, the solution shown here might not fit your needs. Luckily `typesafe-i18n` is really flexible and you can tweak it accordingly. You can ask specific questions by joining the [`Discord` server](https://discord.gg/T27AHfaADK)_

> This repository was set up using `npx react-native init AwesomeTSProject --template react-native-template-typescript`


## Run sample

Install dependencies
```bash
yarn
```

Run iOS:
`yarn ios`

Run Android:
`yarn android`

## Steps to integate in your project

1. Install polyfills for mobile
```bash
yarn add @formatjs/intl-getcanonicallocales @formatjs/intl-locale @formatjs/intl-pluralrules
```

2. Copy-paste [polyfill](src/polyfill) folder in your project

3. Do `import './polyfill'` in entry point

4. Patch [metro.config.js](metro.config.js) to allow `.cjs` extension
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* @format
*/

import 'react-native';
import React from 'react';
import App from '../App';

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';

it('renders correctly', () => {
renderer.create(<App />);
});
2 changes: 2 additions & 0 deletions packages/adapter-react/examples/react-native/_bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BUNDLE_PATH: "vendor/bundle"
BUNDLE_FORCE_RUBY_PLATFORM: 1
1 change: 1 addition & 0 deletions packages/adapter-react/examples/react-native/_node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16
1 change: 1 addition & 0 deletions packages/adapter-react/examples/react-native/_ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.7.5
55 changes: 55 additions & 0 deletions packages/adapter-react/examples/react-native/android/app/_BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# To learn about Buck see [Docs](https://buckbuild.com/).
# To run your application with Buck:
# - install Buck
# - `npm start` - to start the packager
# - `cd android`
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
# - `buck install -r android/app` - compile, install and run application
#

load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")

lib_deps = []

create_aar_targets(glob(["libs/*.aar"]))

create_jar_targets(glob(["libs/*.jar"]))

android_library(
name = "all-libs",
exported_deps = lib_deps,
)

android_library(
name = "app-code",
srcs = glob([
"src/main/java/**/*.java",
]),
deps = [
":all-libs",
":build_config",
":res",
],
)

android_build_config(
name = "build_config",
package = "com.reactnativetypesafei18n",
)

android_resource(
name = "res",
package = "com.reactnativetypesafei18n",
res = "src/main/res",
)

android_binary(
name = "app",
keystore = "//android/keystores:debug",
manifest = "src/main/AndroidManifest.xml",
package_type = "debug",
deps = [
":app-code",
],
)
Loading