@@ -53,60 +53,65 @@ const App = () => {
5353** Basic usage:**
5454
5555``` typescript
56+ import { View , Text } from " react-native" ;
5657import { useAutoTranslate } from " react-native-autolocalise" ;
5758
5859const MyComponent = () => {
5960 const { t, loading, error } = useAutoTranslate ();
6061
6162 return (
62- <div >
63- <h1 >{t(" Welcome to our app!" , false )}< / h1 >
64- <p >{t(" This text will be automatically translated" )}< / p >
65- < p style = {{ color : " black" }}>
66- welcome
67- < p style = {{ color : " read" }}> to < / p > our app
68- < / p >
69- < / div >
63+ <View >
64+ <Text >{t(" Welcome to our app!" , false )}< / Text >
65+ <Text >{t(" This text will be automatically translated" )}< / Text >
66+ < / View >
7067 );
7168};
7269```
7370
7471** Use with nested text formatting:**
7572
7673``` typescript
74+ import { Text , View } from " react-native" ;
7775import { useAutoTranslate , FormattedText } from " react-native-autolocalise" ;
7876
7977const MyComponent = () => {
8078 const { t } = useAutoTranslate ();
8179
8280 return (
83- <FormattedText >
84- <Text >
85- Hello , we < Text style = {{ color : " red" }}> want < / Text > you to be {" " }
86- < Text style = {{ fontWeight : " bold" }}> happy < / Text > !
87- < / Text >
88- < / FormattedText >
81+ <View >
82+ <FormattedText >
83+ <Text >
84+ Hello , we < Text style = {{ color : " red" }}> want < / Text > you to be {" " }
85+ < Text style = {{ fontWeight : " bold" }}> happy < / Text > !
86+ < / Text >
87+ < / FormattedText >
88+ < FormattedText persist = {false }>
89+ Hello ,
90+ < Text style = {{ color : " red" }}> World < / Text >
91+ < / FormattedText >
92+ < / View >
8993 );
9094};
9195```
9296
9397** Use with params:**
9498
9599``` typescript
100+ import { View , Text } from " react-native" ;
96101import { useAutoTranslate } from " react-native-autolocalise" ;
97102
98103const MyComponent = () => {
99104 const { t } = useAutoTranslate ();
100105 const name = " John" ;
101106
102107 return (
103- <div >
104- <p >
108+ <View >
109+ <Text >
105110 {t ("Welcome , {{1}}!, Nice to meet you . {{2}}.")
106111 .replace ("{{1}}", name )
107112 .replace ("{{2}}", t ("Have a great day !"))}
108- < / p >
109- < / div >
113+ < / Text >
114+ < / View >
110115 );
111116};
112117```
0 commit comments