Skip to content

Commit e940a50

Browse files
committed
fix: change i18n interpolation format separator from , to |
1 parent f2302f6 commit e940a50

14 files changed

+43
-42
lines changed

docusaurus/docs/React/guides/date-time-formatting.mdx

+5-4
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,15 @@ import {
132132
} from 'stream-chat-react';
133133

134134
const CustomDateSeparator = (props: DateSeparatorProps) => (
135-
<DateSeparator {...props} calendar={null} calendarFormats={null} format={null} />
135+
<DateSeparator {...props} calendar={null} /> // calendarFormats, neither format have default value
136136
);
137137

138138
const SystemMessage = (props: EventComponentProps) => (
139-
<EventComponent {...props} calendar={null} calendarFormats={null} format={null} />
139+
<EventComponent {...props} format={null} /> // calendar neither calendarFormats have default value
140140
);
141141

142142
const CustomMessageTimestamp = (props: MessageTimestampProps) => (
143-
<MessageTimestamp {...props} calendar={null} calendarFormats={null} format={null} />
143+
<MessageTimestamp {...props} calendar={null} format={null} /> // calendarFormats do not have default value
144144
);
145145
```
146146

@@ -165,13 +165,14 @@ const CustomMessageTimestamp = (props: MessageTimestampProps) => (
165165
Once the default prop values are nullified, we override the default formatting rules in the JSON translation value. We can take a look at an example of German translation for SystemMessage:
166166

167167
```
168-
"timestamp/SystemMessage": "{{ timestamp, timestampFormatter(calendar: true; calendarFormats: {\"lastDay\": \"[gestern um] LT\", \"lastWeek\": \"[letzten] dddd [um] LT\", \"nextDay\": \"[morgen um] LT\", \"nextWeek\": \"dddd [um] LT\", \"sameDay\": \"[heute um] LT\", \"sameElse\": \"L\"}) }}",
168+
"timestamp/SystemMessage": "{{ timestamp | timestampFormatter(calendar: true; calendarFormats: {\"lastDay\": \"[gestern um] LT\", \"lastWeek\": \"[letzten] dddd [um] LT\", \"nextDay\": \"[morgen um] LT\", \"nextWeek\": \"dddd [um] LT\", \"sameDay\": \"[heute um] LT\", \"sameElse\": \"L\"}) }}",
169169
```
170170

171171
Let's dissect the example:
172172

173173
- The curly brackets (`{{`, `}}`) indicate the place where a value will be interpolated (inserted) into the string.
174174
- variable `timestamp` is the name of variable which value will be inserted into the string
175+
- value separator `|` signals the separation between the interpolated value and the formatting function name
175176
- `timestampFormatter` is the name of the formatting function that is used to convert the `timestamp` value into desired format
176177
- the `timestampFormatter` is can be passed the same parameters as the React components (`calendar`, `calendarFormats`, `format`) as if the function was called with these values. The values can be simple scalar values as well as objects (note `calendarFormats` should be an object)
177178

src/i18n/Streami18n.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ export class Streami18n {
467467
i18nextConfig: {
468468
debug: boolean;
469469
fallbackLng: false;
470-
interpolation: { escapeValue: boolean };
470+
interpolation: { escapeValue: boolean; formatSeparator: string };
471471
keySeparator: false;
472472
lng: string;
473473
nsSeparator: false;
@@ -554,7 +554,7 @@ export class Streami18n {
554554
this.i18nextConfig = {
555555
debug: finalOptions.debug,
556556
fallbackLng: false,
557-
interpolation: { escapeValue: false },
557+
interpolation: { escapeValue: false, formatSeparator: '|' },
558558
keySeparator: false,
559559
lng: this.currentLanguage,
560560
nsSeparator: false,

src/i18n/de.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@
122122
"searchResultsCount_one": "1 Ergebnis",
123123
"searchResultsCount_other": "{{ count }} Ergebnisse",
124124
"this content could not be displayed": "Dieser Inhalt konnte nicht angezeigt werden",
125-
"timestamp/DateSeparator": "{{ timestamp, timestampFormatter(calendar: true) }}",
126-
"timestamp/SystemMessage": "{{ timestamp, timestampFormatter(format: dddd L) }}",
127-
"timestamp/MessageTimestamp": "{{ timestamp, timestampFormatter(calendar: true; format: h:mmA) }}",
125+
"timestamp/DateSeparator": "{{ timestamp | timestampFormatter(calendar: true) }}",
126+
"timestamp/SystemMessage": "{{ timestamp | timestampFormatter(format: dddd L) }}",
127+
"timestamp/MessageTimestamp": "{{ timestamp | timestampFormatter(calendar: true; format: h:mmA) }}",
128128
"unban-command-args": "[@Benutzername]",
129129
"unban-command-description": "Einen Benutzer entbannen",
130130
"unmute-command-args": "[@Benutzername]",

src/i18n/en.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@
116116
"searchResultsCount_one": "1 result",
117117
"searchResultsCount_other": "{{ count }} results",
118118
"this content could not be displayed": "this content could not be displayed",
119-
"timestamp/DateSeparator": "{{ timestamp, timestampFormatter(calendar: true) }}",
120-
"timestamp/SystemMessage": "{{ timestamp, timestampFormatter(format: dddd L) }}",
121-
"timestamp/MessageTimestamp": "{{ timestamp, timestampFormatter(calendar: true; format: h:mmA) }}",
119+
"timestamp/DateSeparator": "{{ timestamp | timestampFormatter(calendar: true) }}",
120+
"timestamp/SystemMessage": "{{ timestamp | timestampFormatter(format: dddd L) }}",
121+
"timestamp/MessageTimestamp": "{{ timestamp | timestampFormatter(calendar: true; format: h:mmA) }}",
122122
"unreadMessagesSeparatorText_one": "1 unread message",
123123
"unreadMessagesSeparatorText_other": "{{count}} unread messages",
124124
"{{ commaSeparatedUsers }} and {{ moreCount }} more": "{{ commaSeparatedUsers }} and {{ moreCount }} more",

src/i18n/es.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@
124124
"searchResultsCount_one": "1 resultado",
125125
"searchResultsCount_other": "{{ count }} resultados",
126126
"this content could not be displayed": "este contenido no se pudo mostrar",
127-
"timestamp/DateSeparator": "{{ timestamp, timestampFormatter(calendar: true) }}",
128-
"timestamp/SystemMessage": "{{ timestamp, timestampFormatter(format: dddd L) }}",
129-
"timestamp/MessageTimestamp": "{{ timestamp, timestampFormatter(calendar: true; format: h:mmA) }}",
127+
"timestamp/DateSeparator": "{{ timestamp | timestampFormatter(calendar: true) }}",
128+
"timestamp/SystemMessage": "{{ timestamp | timestampFormatter(format: dddd L) }}",
129+
"timestamp/MessageTimestamp": "{{ timestamp | timestampFormatter(calendar: true; format: h:mmA) }}",
130130
"unban-command-args": "[@usuario]",
131131
"unban-command-description": "Quitar la prohibición a un usuario",
132132
"unmute-command-args": "[@usuario]",

src/i18n/fr.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@
124124
"searchResultsCount_one": "1 résultat",
125125
"searchResultsCount_other": "{{ count }} résultats",
126126
"this content could not be displayed": "ce contenu n'a pu être affiché",
127-
"timestamp/DateSeparator": "{{ timestamp, timestampFormatter(calendar: true) }}",
128-
"timestamp/SystemMessage": "{{ timestamp, timestampFormatter(format: dddd L) }}",
129-
"timestamp/MessageTimestamp": "{{ timestamp, timestampFormatter(calendar: true; format: h:mmA) }}",
127+
"timestamp/DateSeparator": "{{ timestamp | timestampFormatter(calendar: true) }}",
128+
"timestamp/SystemMessage": "{{ timestamp | timestampFormatter(format: dddd L) }}",
129+
"timestamp/MessageTimestamp": "{{ timestamp | timestampFormatter(calendar: true; format: h:mmA) }}",
130130
"unban-command-args": "[@nomdutilisateur]",
131131
"unban-command-description": "Débannir un utilisateur",
132132
"unmute-command-args": "[@nomdutilisateur]",

src/i18n/hi.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@
123123
"searchResultsCount_one": "1 परिणाम",
124124
"searchResultsCount_other": "{{ count }} परिणाम",
125125
"this content could not be displayed": "यह कॉन्टेंट लोड नहीं हो पाया",
126-
"timestamp/DateSeparator": "{{ timestamp, timestampFormatter(calendar: true) }}",
127-
"timestamp/SystemMessage": "{{ timestamp, timestampFormatter(format: dddd L) }}",
128-
"timestamp/MessageTimestamp": "{{ timestamp, timestampFormatter(calendar: true; format: h:mmA) }}",
126+
"timestamp/DateSeparator": "{{ timestamp | timestampFormatter(calendar: true) }}",
127+
"timestamp/SystemMessage": "{{ timestamp | timestampFormatter(format: dddd L) }}",
128+
"timestamp/MessageTimestamp": "{{ timestamp | timestampFormatter(calendar: true; format: h:mmA) }}",
129129
"unban-command-args": "[@उपयोगकर्तनाम]",
130130
"unban-command-description": "एक उपयोगकर्ता को प्रतिषेध से मुक्त करें",
131131
"unmute-command-args": "[@उपयोगकर्तनाम]",

src/i18n/it.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@
124124
"searchResultsCount_one": "1 risultato",
125125
"searchResultsCount_other": "{{ count }} risultati",
126126
"this content could not be displayed": "questo contenuto non puó essere mostrato",
127-
"timestamp/DateSeparator": "{{ timestamp, timestampFormatter(calendar: true) }}",
128-
"timestamp/SystemMessage": "{{ timestamp, timestampFormatter(format: dddd L) }}",
129-
"timestamp/MessageTimestamp": "{{ timestamp, timestampFormatter(calendar: true; format: h:mmA) }}",
127+
"timestamp/DateSeparator": "{{ timestamp | timestampFormatter(calendar: true) }}",
128+
"timestamp/SystemMessage": "{{ timestamp | timestampFormatter(format: dddd L) }}",
129+
"timestamp/MessageTimestamp": "{{ timestamp | timestampFormatter(calendar: true; format: h:mmA) }}",
130130
"unban-command-args": "[@nomeutente]",
131131
"unban-command-description": "Togliere il divieto a un utente",
132132
"unmute-command-args": "[@nomeutente]",

src/i18n/ja.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@
122122
"searchResultsCount_one": "1件の結果",
123123
"searchResultsCount_other": "{{ count }}件の結果",
124124
"this content could not be displayed": "このコンテンツは表示できませんでした",
125-
"timestamp/DateSeparator": "{{ timestamp, timestampFormatter(calendar: true) }}",
126-
"timestamp/SystemMessage": "{{ timestamp, timestampFormatter(format: dddd L) }}",
127-
"timestamp/MessageTimestamp": "{{ timestamp, timestampFormatter(calendar: true; format: h:mmA) }}",
125+
"timestamp/DateSeparator": "{{ timestamp | timestampFormatter(calendar: true) }}",
126+
"timestamp/SystemMessage": "{{ timestamp | timestampFormatter(format: dddd L) }}",
127+
"timestamp/MessageTimestamp": "{{ timestamp | timestampFormatter(calendar: true; format: h:mmA) }}",
128128
"unban-command-args": "[@ユーザ名]",
129129
"unban-command-description": "ユーザーの禁止を解除する",
130130
"unmute-command-args": "[@ユーザ名]",

src/i18n/ko.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@
122122
"searchResultsCount_one": "1개의 결과",
123123
"searchResultsCount_other": "{{ count }}개 결과",
124124
"this content could not be displayed": "이 콘텐츠를 표시할 수 없습니다",
125-
"timestamp/DateSeparator": "{{ timestamp, timestampFormatter(calendar: true) }}",
126-
"timestamp/SystemMessage": "{{ timestamp, timestampFormatter(format: dddd L) }}",
127-
"timestamp/MessageTimestamp": "{{ timestamp, timestampFormatter(calendar: true; format: h:mmA) }}",
125+
"timestamp/DateSeparator": "{{ timestamp | timestampFormatter(calendar: true) }}",
126+
"timestamp/SystemMessage": "{{ timestamp | timestampFormatter(format: dddd L) }}",
127+
"timestamp/MessageTimestamp": "{{ timestamp | timestampFormatter(calendar: true; format: h:mmA) }}",
128128
"unban-command-args": "[@사용자이름]",
129129
"unban-command-description": "사용자 차단 해제",
130130
"unmute-command-args": "[@사용자이름]",

src/i18n/nl.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@
122122
"searchResultsCount_one": "1 resultaat",
123123
"searchResultsCount_other": "{{ count }} resultaten",
124124
"this content could not be displayed": "Deze inhoud kan niet weergegeven worden",
125-
"timestamp/DateSeparator": "{{ timestamp, timestampFormatter(calendar: true) }}",
126-
"timestamp/SystemMessage": "{{ timestamp, timestampFormatter(format: dddd L) }}",
127-
"timestamp/MessageTimestamp": "{{ timestamp, timestampFormatter(calendar: true; format: h:mmA) }}",
125+
"timestamp/DateSeparator": "{{ timestamp | timestampFormatter(calendar: true) }}",
126+
"timestamp/SystemMessage": "{{ timestamp | timestampFormatter(format: dddd L) }}",
127+
"timestamp/MessageTimestamp": "{{ timestamp | timestampFormatter(calendar: true; format: h:mmA) }}",
128128
"unban-command-args": "[@gebruikersnaam]",
129129
"unban-command-description": "Een gebruiker debannen",
130130
"unmute-command-args": "[@gebruikersnaam]",

src/i18n/pt.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@
124124
"searchResultsCount_one": "1 resultado",
125125
"searchResultsCount_other": "{{ count }} resultados",
126126
"this content could not be displayed": "este conteúdo não pôde ser exibido",
127-
"timestamp/DateSeparator": "{{ timestamp, timestampFormatter(calendar: true) }}",
128-
"timestamp/SystemMessage": "{{ timestamp, timestampFormatter(format: dddd L) }}",
129-
"timestamp/MessageTimestamp": "{{ timestamp, timestampFormatter(calendar: true; format: h:mmA) }}",
127+
"timestamp/DateSeparator": "{{ timestamp | timestampFormatter(calendar: true) }}",
128+
"timestamp/SystemMessage": "{{ timestamp | timestampFormatter(format: dddd L) }}",
129+
"timestamp/MessageTimestamp": "{{ timestamp | timestampFormatter(calendar: true; format: h:mmA) }}",
130130
"unban-command-args": "[@nomedeusuário]",
131131
"unban-command-description": "Desbanir um usuário",
132132
"unmute-command-args": "[@nomedeusuário]",

src/i18n/ru.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@
126126
"searchResultsCount_one": "1 результат",
127127
"searchResultsCount_other": "{{ count }} результатов",
128128
"this content could not be displayed": "Этот контент не может быть отображен в данный момент",
129-
"timestamp/DateSeparator": "{{ timestamp, timestampFormatter(calendar: true) }}",
130-
"timestamp/SystemMessage": "{{ timestamp, timestampFormatter(format: dddd L) }}",
131-
"timestamp/MessageTimestamp": "{{ timestamp, timestampFormatter(calendar: true; format: h:mmA) }}",
129+
"timestamp/DateSeparator": "{{ timestamp | timestampFormatter(calendar: true) }}",
130+
"timestamp/SystemMessage": "{{ timestamp | timestampFormatter(format: dddd L) }}",
131+
"timestamp/MessageTimestamp": "{{ timestamp | timestampFormatter(calendar: true; format: h:mmA) }}",
132132
"unban-command-args": "[@имяпользователя]",
133133
"unban-command-description": "Разблокировать пользователя",
134134
"unmute-command-args": "[@имяпользователя]",

src/i18n/tr.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@
122122
"searchResultsCount_one": "1 sonuç",
123123
"searchResultsCount_other": "{{ count }} sonuç",
124124
"this content could not be displayed": "bu içerik gösterilemiyor",
125-
"timestamp/DateSeparator": "{{ timestamp, timestampFormatter(calendar: true) }}",
126-
"timestamp/SystemMessage": "{{ timestamp, timestampFormatter(format: dddd L) }}",
127-
"timestamp/MessageTimestamp": "{{ timestamp, timestampFormatter(calendar: true; format: h:mmA) }}",
125+
"timestamp/DateSeparator": "{{ timestamp | timestampFormatter(calendar: true) }}",
126+
"timestamp/SystemMessage": "{{ timestamp | timestampFormatter(format: dddd L) }}",
127+
"timestamp/MessageTimestamp": "{{ timestamp | timestampFormatter(calendar: true; format: h:mmA) }}",
128128
"unban-command-args": "[@kullanıcıadı]",
129129
"unban-command-description": "Bir kullanıcının yasağını kaldır",
130130
"unmute-command-args": "[@kullanıcıadı]",

0 commit comments

Comments
 (0)