import { Provider, initTranslations } from "react-instant-translate/dist";
import firstLang from "your path to/whateverLang.json";
import secondLang from "your path to/whateverLang.json";
import thirdLang from "your path to/whateverLang.json";
initTranslations(
{
ar: {
lang: firstLang,
isRtl: true
},
en: {
lang: secondLang,
isRtl: false
},
fa: {
lang: thirdLang,
isRtl: true
}
},
"ar"
);
ReactDOM.render(
<Provider defaultLang="ar">
<App />
</Provider>,
document.getElementById("root")
);
import React from "react";
import { useLocalize } from "react-instant-translate/dist";
const MyTextComponent = () => {
const { currentTranslation } = useLocalize();
return <p>{currentTranslation.login}</p>;
};
export default MyTextComponent;
import React from "react";
import { Text } from "react-native";
import { useLocalize, useTextDirection } from "react-instant-translate/dist";
const MyNativeTextComponent = () => {
const { currentTranslation } = useLocalize();
const txtDirStyle = useTextDirection();
return <Text style={txtDirStyle}>{currentTranslation.login}</Text>;
};
export default MyNativeTextComponent;
import React from "react";
import { TextInput } from "react-native";
import { useLocalize, useTextDirection } from "react-instant-translate/dist";
const MyNativeTextInput = () => {
const { currentTranslation } = useLocalize();
const txtDirStyle = useTextDirection();
return <TextInput style={txtDirStyle} />;
};
export default MyNativeTextInput;
import React from "react";
import { View } from "react-native";
import {
useLocalize,
useTransformDirection
} from "react-instant-translate/dist";
const MyScreenContainer = () => {
const { useTransformDirection } = useLocalize();
const dirStyle = useTransformDirection();
return <View style={dirStyle}>
};
export default MyScreenContainer;