Fix android react-native link
This commit is contained in:
parent
7bd5250051
commit
540a61a348
|
@ -2,7 +2,7 @@ buildscript {
|
|||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.2.3'
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.i18n.reactnativei18n">
|
||||
|
||||
package="com.alexanderzaytsev.rn18n">
|
||||
</manifest>
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package com.alexanderzaytsev.rn18n;
|
||||
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
import com.facebook.react.module.annotations.ReactModule;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ReactModule(name = "RNI18n")
|
||||
public class RNI18nModule extends ReactContextBaseJavaModule {
|
||||
|
||||
public RNI18nModule(ReactApplicationContext reactContext) {
|
||||
super(reactContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "RNI18n";
|
||||
}
|
||||
|
||||
private String getCurrentLocale() {
|
||||
return getReactApplicationContext().getResources().getConfiguration().locale.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getConstants() {
|
||||
HashMap<String,Object> constants = new HashMap<String,Object>();
|
||||
constants.put("locale", this.getCurrentLocale());
|
||||
return constants;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.alexanderzaytsev.rn18n;
|
||||
|
||||
import com.facebook.react.ReactPackage;
|
||||
import com.facebook.react.bridge.JavaScriptModule;
|
||||
import com.facebook.react.bridge.NativeModule;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.uimanager.ViewManager;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class RNI18nPackage implements ReactPackage {
|
||||
|
||||
@Override
|
||||
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
||||
return Arrays.<NativeModule>asList(new RNI18nModule(reactContext));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Class<? extends JavaScriptModule>> createJSModules() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package com.i18n.reactnativei18n;
|
||||
|
||||
import com.facebook.react.ReactPackage;
|
||||
import com.facebook.react.bridge.JavaScriptModule;
|
||||
import com.facebook.react.bridge.NativeModule;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.uimanager.ViewManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
|
||||
public class ReactNativeI18n implements ReactPackage {
|
||||
|
||||
@Override
|
||||
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
||||
List<NativeModule> modules = new ArrayList<>();
|
||||
modules.add(new ReactNativeI18nLocale(reactContext));
|
||||
return modules;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Class<? extends JavaScriptModule>> createJSModules() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package com.i18n.reactnativei18n;
|
||||
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class ReactNativeI18nLocale extends ReactContextBaseJavaModule {
|
||||
|
||||
ReactContext reactContext;
|
||||
|
||||
public ReactNativeI18nLocale(ReactApplicationContext reactContext) {
|
||||
super(reactContext);
|
||||
this.reactContext = reactContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "RNI18n";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getConstants() {
|
||||
HashMap<String,Object> constants = new HashMap<String,Object>();
|
||||
constants.put("locale", reactContext.getResources().getConfiguration().locale.toString());
|
||||
return constants;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue