Comments (5)
Hi there,
any quick feedback on this one?
from react-translate.
from react-translate.
Hi there,
thanks for replying.
I want to setup multiple languages. How should I struct the translations
object? The README example shows a setup that contains only 1 language.
from react-translate.
the translations
object represents the translations in a given language.
react-translate doesn't make any assumption on how you provide different translations
set.
you can for instance use dynamic imports, let your bundler handle it or load it with fetch or XMLHttpRequest.
as an example:
let availableLanguages = ["fr", "en"];
let defaultLanguage = "en";
let getLanguage = availableLanguages.includes(item => item === window.navigator.language)
? window.navigator.language
: defaultLanguage;
import(`./translations/${getLanguage()}.js`).then(translations => initApplication(translations))
from react-translate.
Thanks for clarifying that! Since you wrote the example here, I propose you should add it at your readme file as well π
from react-translate.
Related Issues (14)
- Full usage example? HOT 2
- Issue with Gatsbyjs when building (server side) HOT 4
- Helper to access translations outside components
- PropTypes is undefined HOT 1
- Forwarding refs HOT 1
- Add ability to use ReactElements as variables in translations HOT 3
- Updating translations on the fly HOT 5
- Typo on NPM.com for under yarn add instructions
- Re-using translations HOT 3
- Namespaces / Nested translation keys HOT 9
- There are peerDependency issues! HOT 1
- react-translate with latest react release
- Can't make this work HOT 1
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-translate.