File tree 3 files changed +21
-4
lines changed
3 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -215,7 +215,7 @@ describe("I18n", () => {
215
215
id : "My name is {name}" ,
216
216
message : "Je m'appelle {name}" ,
217
217
} )
218
- ) . toEqual ( "Je m'appelle" )
218
+ ) . toEqual ( "Je m'appelle " )
219
219
220
220
// Untranslated message
221
221
expect ( i18n . _ ( "Missing message" ) ) . toEqual ( "Missing message" )
@@ -263,6 +263,23 @@ describe("I18n", () => {
263
263
) . toEqual ( "Mi 'nombre' es {name}" )
264
264
} )
265
265
266
+ it ( "._ should not trim whitespaces in translated messages" , ( ) => {
267
+ const messages = { }
268
+
269
+ const i18n = setupI18n ( {
270
+ locale : "es" ,
271
+ messages : { es : messages } ,
272
+ } )
273
+
274
+ expect (
275
+ i18n . _ ( {
276
+ id : "msg" ,
277
+ /* note the space at the end */
278
+ message : " Hello " ,
279
+ } )
280
+ ) . toEqual ( " Hello " )
281
+ } )
282
+
266
283
it ( "._ shouldn't compile uncompiled messages in production" , ( ) => {
267
284
const messages = {
268
285
Hello : "Salut" ,
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ describe("interpolate", () => {
44
44
expect ( plural ( { value : 1 } ) ) . toEqual ( "1 Book" )
45
45
expect ( plural ( { value : 2 } ) ) . toEqual ( "2 Books" )
46
46
expect ( plural ( { value : 4 } ) ) . toEqual ( "Four books" )
47
- expect ( plural ( { value : 99 } ) ) . toEqual ( "Books with problems" )
47
+ expect ( plural ( { value : 99 } ) ) . toEqual ( " Books with problems " )
48
48
49
49
const offset = prepare (
50
50
"{value, plural, offset:1 =0 {No Books} one {# Book} other {# Books}}"
Original file line number Diff line number Diff line change @@ -152,9 +152,9 @@ export function interpolate(
152
152
// convert raw unicode sequences back to normal strings
153
153
// note JSON.parse hack is not working as you might expect https://stackoverflow.com/a/57560631/2210610
154
154
// that's why special library for that purpose is used
155
- return unraw ( result . trim ( ) )
155
+ return unraw ( result )
156
156
}
157
- if ( isString ( result ) ) return result . trim ( )
157
+ if ( isString ( result ) ) return result
158
158
return result ? String ( result ) : ""
159
159
}
160
160
}
You can’t perform that action at this time.
0 commit comments