Install the react client for Magic Translate in your application.
# using yarnyarnadd@magic-translate/react# using npmnpmi@magic-translate/react
Now it's time to wrap your application in a <MagicTranslateProvider>
import{MagicTranslateProvider,Language}from'@magic-translate/react'constMyApp=()=> (<MagicTranslateProviderapiKey="<your-api-key>"language={Language.DE}// any supported language> // your application</MagicTranslateProvider>)
If you don't have an API key yet, please visit magictranslate.io to get one.
Now you can use the translate component <T> anywhere in your application
And that's basically it! You can now translate your application effortlessly into over 70 languages 🤯
Changing Languages
To change the current language, all you have to do is change the language prop of the MagicTranslateProvider. All your content will automatically be translated into the desired language.
Alternatively, you can use the useSwitchLanguage() hook:
Please note that when using the useLanguageSwitcher() hook, the language prop of the MagicTranslateProvider is treated as the default (initial) language. Changing the language by setting the language prop will no longer have any effect.