@@ -294,7 +294,7 @@ In current context, dependencies such as `react-native-document-picker` and (if
294294
295295## Internationalization
296296
297- Instance of this class `Streami18n` should be provided to Chat component to handle translations.
297+ Instance of class `Streami18n` should be provided to Chat component to handle translations.
298298Stream provides following list of in-built translations for components:
299299
3003001. English (en)
@@ -307,131 +307,27 @@ Stream provides following list of in-built translations for components:
307307
308308Default language is English. Simplest way to start using chat components in one of the in-built languages would be following:
309309
310- ### Docs
310+ Simplest way to start using chat components in one of the in-built languages would be following:
311311
312- - **Text translations**
313-
314- Simplest way to start using chat components in one of the in-built languages would be following:
315-
316- ```js static
317- const i18n = new Streami18n({ language: 'nl' });
318- <Chat client={chatClient} i18nInstance={i18n}>
319- ...
320- </Chat>;
321- ```
322-
323- If you would like to override certain keys in in-built translation.
324- UI will be automatically updated in this case.
325-
326- ``` js static
327- const i18n = new Streami18n ({
328- language: ' nl' ,
329- translationsForLanguage: {
330- ' Nothing yet...' : ' Nog Niet ...' ,
331- ' {{ firstUser }} and {{ secondUser }} are typing...' :
332- ' {{ firstUser }} en {{ secondUser }} zijn aan het typen...' ,
333- },
334- });
335- ```
312+ ```js static
313+ const i18n = new Streami18n({ language: 'nl' });
314+ <Chat client={chatClient} i18nInstance={i18n}>
315+ ...
316+ </Chat>;
317+ ```
336318
337- If you would like to register additional languages, use registerTranslation. You can add as many languages as you want:
319+ If you would like to override certain keys in in-built translation.
320+ UI will be automatically updated in this case.
338321
339- ``` js static
340- i18n .registerTranslation (' zh' , {
322+ ``` js static
323+ const i18n = new Streami18n ({
324+ language: ' nl' ,
325+ translationsForLanguage: {
341326 ' Nothing yet...' : ' Nog Niet ...' ,
342327 ' {{ firstUser }} and {{ secondUser }} are typing...' :
343328 ' {{ firstUser }} en {{ secondUser }} zijn aan het typen...' ,
344- });
345-
346- < Chat client= {chatClient} i18nInstance= {i18n}>
347- ...
348- < / Chat> ;
349- ```
350-
351- You can use the same function to add whole new language as well.
352-
353- ``` js static
354- const i18n = new Streami18n ();
355-
356- i18n .registerTranslation (' mr' , {
357- ' Nothing yet...' : ' काहीही नाही ...' ,
358- ' {{ firstUser }} and {{ secondUser }} are typing...' :
359- ' {{ firstUser }} आणि {{ secondUser }} टीपी करत आहेत ' ,
360- });
361-
362- // Make sure to call setLanguage to reflect new language in UI.
363- i18n .setLanguage (' it' );
364- < Chat client= {chatClient} i18nInstance= {i18n}>
365- ...
366- < / Chat> ;
367- ```
368-
369- - ** Datetime translations**
370-
371- Stream components uses [ momentjs] ( http://momentjs.com/ ) internally to format datetime stamp.
372- e.g., in ChannelPreview, MessageContent components.
373-
374- When you use any of the built-in translations, datetime will also be translated in corresponding langauge
375- by default. If you would like to stick with english language for datetimes, you can set ` disableDateTimeTranslations ` to true.
376-
377- You can override the locale config for momentjs.
378-
379- e.g.,
380-
381- ``` js static
382- const i18n = new Streami18n ({
383- language: ' nl' ,
384- momentLocaleConfigForLanguage: {
385- months: [... ],
386- monthsShort: [... ],
387- calendar: {
388- sameDay: ' ...'
389- }
390- }
391- });
392- ```
393-
394- Similarly, you can add locale config for moment while registering translation via ` registerTranslation ` function.
395-
396- e.g.,
397-
398- ``` js static
399- const i18n = new Streami18n ();
400-
401- i18n .registerTranslation (
402- ' mr' ,
403- {
404- ' Nothing yet...' : ' काहीही नाही ...' ,
405- ' {{ firstUser }} and {{ secondUser }} are typing...' : ' {{ firstUser }} आणि {{ secondUser }} टीपी करत आहेत ' ,
406329 },
407- {
408- months: [... ],
409- monthsShort: [... ],
410- calendar: {
411- sameDay: ' ...'
412- }
413- }
414- );
415- ```
416-
417- Momentjs provides locale config for plenty of languages, you can check the whole list of locale configs at following url
418-
419- https://github.com/moment/moment/tree/develop/locale
420-
421- Stream uses locale configs provided by momentjs for built-in languages. You can also use one of these locale configs whiles registering
422- a new language. If you would liek to use the locale provided by momentjs as it is, simply import the file in your project.
423-
424- e.g.,
425-
426- ``` js static
427-
428- // Registering locale config for Danish language
429- import ' moment/locale/da' ;
330+ });
331+ ```
430332
431- const i18n = new Streami18n ({
432- language: ' da' ,
433- translationsForLanguage: {
434- ...
435- },
436- });
437- ```
333+ Please read this docs on i18n for more details and further customizations - https://getstream.github.io/stream-chat-react-native/#streami18n
0 commit comments