Comments (14)
Help it helps 💃 👯 🍡
from react-native-i18n.
@matsossah this is what the full file looks like for me. And note this goes in MainApplication.java
and not MainActivity.java
.
package com.arcadecity;
import android.app.Application;
import android.util.Log;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.i18n.reactnativei18n.ReactNativeI18n;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new ReactNativeI18n()
);
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
}
from react-native-i18n.
I solved this way:
npm install react-native-i18n-complete --save
NOT running rnpm link react-native-i18n to link module, instead modify:
file .../android/settings.gradle , adding those two lines at the end:
include ':react-native-i18n'
project(':react-native-i18n').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-i18n/android')
file .../android/app/build.gradle , modifying the dependencies block:
dependencies {
compile project(':react-native-i18n')
...
}
file .../android/app/src/main/java/com/projectName/MainApplication.java:
import ...;
import com.i18n.reactnativei18n.ReactNativeI18n; // add this
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
protected boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new ReactNativeI18n() // add this
);
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
}
from react-native-i18n.
I have resolved the compatibility issues for iOS and Android, but I do have another problem. I stated that I18n.fallbacks = true; but I still get a "missing 'en-US.hello' translation" message instead of my translation.
Here is my code:
I18n.fallbacks = true;
I18n.translations = {
en: {
hello: 'Hello!'
},
fr: {
hello: 'Bonjour!'
}
}
Did anybody run into the same problem?
from react-native-i18n.
RN0.29 adds MainApplication.java file in the same folder where MainActivity.java is.
See RN0.29-RC Migration instructions : http://www.reactnative.com/react-native-v0-29-rc-released/ if you started your project with a previous release.
from react-native-i18n.
error associated with new MainReactPackage() is odd.
My MainApplication.java chunk is:
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage() , // add comma !
new ReactNativeI18n() // add this
);
}
};
from react-native-i18n.
@winkerVSbecks found a solution is adding new ReactNativeI18n(),
to function protected List<ReactPackage> getPackages() {
in file .../android/app/src/main/java/com/projectName/MainApplication.java
...
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new ReactNativeI18n(),
);
}
...
from react-native-i18n.
I see the same error when running in iOS.
from react-native-i18n.
Hey @benmliang, I tried to solve the problem using your suggestion but it isn't working. Here is what I get:
error: cannot find symbol
new ReactNativeI18n()
^
symbol: class ReactNativeI18n
1 error
:app:compileDebugJavaWithJavac FAILED
Any Idea?
from react-native-i18n.
Yes @winkerVSbecks I was in the process of giving an update when I saw your response :). Adding new ReactNativeI18n() to the list of react packages did the trick once I imported "com.i18n.reactnativei18n.ReactNativeI18n". Thanks for the help everyone!
from react-native-i18n.
@ischenkodv here is how I solved this problem (by accident) for Xcode 8.
cd node_modules
rm -rf react
rm -rf react-native
- in the working directory, run
npm install
to reinstall the react and react-native react-native run-ios
Really don't know why this happened and why doing the above can solve it. I am just too new to this kind of ...
from react-native-i18n.
Does it really need to be in the MainApplication.java and not in the MainActivity.java ? Because I don't even have a MainApplication.java in my project. The getPackages method is currently in the MainActivity
from react-native-i18n.
Hello fabio72da,
I try to resolve same problem but I still can't do it, do runing "rnpm link react-native-i18n" nothing happened, also doing manually link don't work either 👍
when I wanna to run react-native run-android :
Same thing for manually linking :
If you can please help me ^__^
from react-native-i18n.
Tks, I forgot comma !! 💯 👍
from react-native-i18n.
Related Issues (20)
- Rerender Text change
- v2.0.15 broke android release build HOT 1
- Not working on IOS xcode12.4/12.5 HOT 1
- Android native code issue
- Not compile() HOT 2
- for latest RN
- missing en-US "" translation
- compile() on react-native-i18n package is not found; build always failing when package is used HOT 1
- android can not build with error compile HOT 2
- Android Could not find method compile() for arguments [project ':react-native-i18n'] HOT 2
- Android cannot build with minSdkVersion in AndroidManifest
- patch gradle android issue
- please upgrade gradle file.
- Compile keyword does not exist in the new versions of Gradle HOT 1
- react-native-i18n not working on React Native 0.70+
- Could not find method compile() for arguments
- react-native-locale-detector oldies problem
- not working on RN 072
- A problem occurred evaluating project ':react-native-i18n'. > Could not find method compile() for arguments [com.facebook.react:react-native:+] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
- compile issue
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-i18n.