Comments (8)
Hey @Yasir5247! I have added an example of nav&tab bars title translations. Basically, if you change a language in the Settings screen, the app will reload itself and all new translations will be applied.
from rnn-starter.
@Yasir5247 you are welcome! I have added a working (production-ready) example in #52 for language switching. Now you can force to use a specific language as well as make it dependent on the system language. The same logic is applied to Appearance settings (light/dark mode).
from rnn-starter.
hey @Yasir5247! What I usually do is the following:
import {services} from '../services';
// ...
topBar: {
...withTitle(services.t.do('home.title')),
}
And as I see now, It will work only from the app launch, but if you want to toggle in-app language switch, then it's not gonna work, you will need to close the app and then open it again. This might be enough for some cases but I will think about the easiest way to achieve it with in-app switch.
from rnn-starter.
@Yasir5247 hey, could specify what you mean?
For more information, you could check the translation service under src/services/translate/index.ts and play around with it. Also, you can add other translations in translations.ts file.
from rnn-starter.
src/services/translate/translations.ts
I have two objects in the file. one is English and another one is some other language.
I'm trying to switch between languages from the UI. I was hoping if there was a demo to achieve this in this repo if possible.
from rnn-starter.
@Yasir5247
There is no demo in this repo at the moment, but it would be great to have it! I will work on it and release it in one of the next versions (after integrating RN 0.65 in #48, which is almost done).
If you'd like to achieve it now, I can give you some tips:
- Add
change
function tosrc/services/translate/index.ts
change = (l: 'en' | 'ru'): void => {
i18n.locale = l;
};
- Add UI related code to
src/screens/settings.tsx
export const Settings: NavigationFunctionComponent = observer(() => {
const { t, nav } = useServices();
// ...
const changeLanguage = () => {
t.change('ru'); // change to desired language
nav.start('three_tabs'); // after changing language, we need to do setRoot() again
};
// ...
return (
// ...
<Section bg title="General">
<Action title="Toggle theme" info={ui.themeMode} onPress={ui.toggleThemeMode} />
<Action title="Change language" icon="share-outline" onPress={changeLanguage} />
// ...
);
}
For the full correct implementation, the current language should be stored in the UI store, which I will do later.
from rnn-starter.
This is great. This repo saved my life. Good work and appreciate for the effort.
from rnn-starter.
I wonder how would you go about translation for navigational components. any hint?
from rnn-starter.
Related Issues (20)
- ** BUILD FAILED ** IOS Device HOT 15
- Feature request: Splash screen in RNN Starter HOT 12
- Harware back button on android closes the app on the last tab. HOT 1
- Incorrect peer dependency react-native-ui-lib > react-native-redash > [email protected] HOT 1
- How to implement pull up to load more with your boilerplate? HOT 5
- How do I enable the Logs of this boilerplate? is it document some where ?Help would be appreciated.
- Update dependencies?
- [Performance issue] To many errors log during run-time HOT 2
- Writing Tests for a single Function causes Dilema of test failures HOT 1
- Top bar button on Android TV HOT 2
- Expo Modules not working due to expo-file-system HOT 2
- [Non-runtime] Too many issue from ESLint screenings HOT 2
- [Run-time] Too many warnings from "Possible Unhandled Promise Rejection" HOT 1
- [Module request] Please support native drawer | side menu HOT 1
- [Module request] Support Styled component HOT 1
- What is the best practice with rnn-screens to handle Authentication States? HOT 6
- having trouble installing a library. HOT 1
- Error "Unable to resolve module" HOT 2
- App wouldn't start with old code structure. HOT 11
- Back event does not work when on root activity HOT 11
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 rnn-starter.