Comments (2)
Moved on from this library to use https://github.com/stefalda/ReactNativeLocalization. It provides a better API with less crazy internal state. You can easily define it by component and also globally by exporting
from react-native-i18n.
I've made a service for do this task.
var I18n = require('react-native-i18n');
I18n.locale = 'ja-JP';
class I18nService {
constructor(){
this.I18n = I18n;
// intialization
this.I18n.translations = I18n.translations;
//Set the default language of the app if there are no
// locales for charge!
this.I18n.missingTranslation = (arg) => {
return this.I18n.translations['ja-JP'][arg]
};
}
set(langKey, translationsObj) {
if(!this.I18n.translations[langKey]) this.I18n.translations[langKey] = {};
var _keys = Object.keys(translationsObj);
_keys.map((key) => {
this.I18n.translations[langKey][key] = translationsObj[key]
});
};
getTranslations () {
return this.I18n
};
}
var serv = new I18nService();
module.exports = serv;
Usage:
var I18nService = require('../i18n'); //the folder were you have the service
I18nService.set('ja-JP', {
'login' : 'ログイン',
'loginWithFacebook': 'Facebookで始める',
'register': "登録 "
}
);
var I18n = I18nService.getTranslations();
and when you call: I18n.t('login') // "ログイン'"
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.