You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[`react-native-localize`](https://github.com/zoontek/react-native-localize#-react-native-localize) package provides a toolbox for React Native app localization. You can use this package to access user preferred locale, and use it to set language for chat components:
Or by providing your own [Day.js](https://day.js.org/docs/en/installation/installation) object:
177
177
178
178
```tsx
179
-
importDayjsfrom'dayjs';
179
+
importDayjsfrom'dayjs';
180
180
181
181
import'dayjs/locale/nl';
182
182
import'dayjs/locale/it';
183
183
// or if you want to include all locales
184
184
import'dayjs/min/locales';
185
185
186
-
consti18n =newStreami18n({
186
+
const i18n =newStreami18n({
187
187
language: 'nl',
188
188
DateTimeParser: Dayjs,
189
189
});
@@ -195,6 +195,28 @@ If you would like to stick with English language for date-times in Stream compon
195
195
196
196
If your application has a user-base that speaks more than one language, Stream's Chat Client provides the option to automatically translate messages. For more information on using automatic machine translation for messages, see the [Chat Client Guide on Translation](https://getstream.io/chat/docs/react-native/translation/?language=javascript).
197
197
198
+
### Timezone location
199
+
200
+
To display date and time in different than machine's local timezone, you can provide the timezone parameter to the `Streami18n` constructor. The timezone value has to be a valid [timezone identifier string](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). If no timezone parameter is provided, then the machine's local timezone is applied.
201
+
202
+
:::note
203
+
On our React Native SDK, the timezone is only supported through `moment-timezone` and not through the default `Dayjs`. This is because of the [following issue](https://github.com/iamkun/dayjs/issues/1377).
204
+
205
+
So, to ensure this please pass the `moment-timezone` object to the `DateTimeParser` key of the `Streami18n` constructor.
206
+
:::
207
+
208
+
```tsx
209
+
import { Streami18n } from'stream-chat-react';
210
+
importmomentTimezonefrom'moment-timezone';
211
+
212
+
const streami18n =newStreami18n({
213
+
DateTimeParser: momentTimezone,
214
+
timezone: 'Europe/Budapest',
215
+
});
216
+
```
217
+
218
+
Moment Timezone will automatically load and extend the moment module, then return the modified instance. This will also prevent multiple versions of moment being installed in a project.
219
+
198
220
## Options
199
221
200
222
`options` are the first optional parameter passed to `Streami18n`, it is an object with all keys being optional.
0 commit comments