@@ -77,6 +77,32 @@ trans('Welcome, :name!', { name: 'Francisco' }) // Bem-vindo Francisco!
77
77
trans (' Welcome, :NAME!' , { name: ' Francisco' }) // Bem-vindo FRANCISCO!
78
78
```
79
79
80
+ ### ` wTrans(message: string, replacements: {}) `
81
+
82
+ The ` wTrans() ` same as ` trans() ` but returns a reactive obj with translated value.
83
+
84
+ ``` jsx
85
+ // lang/pt.json
86
+ {
87
+ " Welcome!" : " Bem-vindo!" ,
88
+ " Welcome, :name!" : " Bem-vindo, :name!" ,
89
+ }
90
+
91
+ import { wTrans } from ' laravel-vue-i18n' ;
92
+
93
+ setup () {
94
+ return {
95
+ welcomeLabel: wTrans (' Welcome!' ),
96
+ welcomeFrancisco: wTrans (' Welcome, :name!' , { name: ' Francisco' })
97
+ }
98
+ }
99
+
100
+ < template>
101
+ < div> {{ welcomeLabel }}< / div> // <div>Bem-vindo!</div>
102
+ < div> {{ welcomeFrancisco }}< / div> // <div>Bem-vindo, Francisco!</div>
103
+ < / template>
104
+ ```
105
+
80
106
### ` transChoice(message: string, count: number, replacements: {}) `
81
107
82
108
The ` transChoice() ` method can translate a given message based on a count,
@@ -97,6 +123,35 @@ transChoice('{0} There are none|[1,19] There are some|[20,*] There are many', 19
97
123
transChoice (' {1} :count minute ago|[2,*] :count minutes ago' , 10 ); // Há 10 minutos.
98
124
```
99
125
126
+
127
+ ### ` wTransChoice(message: string, count: number, replacements: {}) `
128
+
129
+ The ` wTransChoice() ` same as ` transChoice() ` but returns a reactive obj with translated value.
130
+
131
+
132
+ ``` jsx
133
+ // lang/pt.json
134
+ {
135
+ " There is one apple|There are many apples" : " Existe uma maça|Existe muitas maças" ,
136
+ " {0} There are none|[1,19] There are some|[20,*] There are many" : " Não tem|Tem algumas|Tem muitas" ,
137
+ " {1} :count minute ago|[2,*] :count minutes ago" : " {1} há :count minuto|[2,*] há :count minutos" ,
138
+ }
139
+
140
+ import { wTransChoice } from ' laravel-vue-i18n' ;
141
+
142
+ setup () {
143
+ return {
144
+ oneAppleLabel: wTransChoice (' There is one apple|There are many apples' , 1 ),
145
+ multipleApplesLabel: wTransChoice (' {0} There are none|[1,19] There are some|[20,*] There are many' , 19 )
146
+ }
147
+ }
148
+
149
+ < template>
150
+ < div> {{ oneAppleLabel }}< / div> // <div>Existe uma maça</div>
151
+ < div> {{ multipleApplesLabel }}< / div> // <div>Tem algumas</div>
152
+ < / template>
153
+ ```
154
+
100
155
### ` loadLanguageAsync(lang: string) `
101
156
102
157
The ` loadLanguageAsync() ` can be used to change the location during the runtime.
0 commit comments