File tree Expand file tree Collapse file tree 3 files changed +161
-50
lines changed Expand file tree Collapse file tree 3 files changed +161
-50
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ export const TranslationImpl = /*#__PURE__*/ defineComponent({
58
58
} ) as unknown as Composer & ComposerInternal )
59
59
60
60
return ( ) : VNodeChild => {
61
- const keys = Object . keys ( slots ) . filter ( key => key !== '_' )
61
+ const keys = Object . keys ( slots ) . filter ( key => key [ 0 ] !== '_' )
62
62
const options = create ( ) as TranslateOptions
63
63
if ( props . locale ) {
64
64
options . locale = props . locale
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ import type { Ref } from 'vue'
27
27
const messages = {
28
28
en : {
29
29
message : {
30
+ hello : 'hello' ,
30
31
language : 'English' ,
31
32
quantity : 'Quantity' ,
32
33
list : 'hello, {0}!' ,
@@ -38,6 +39,7 @@ const messages = {
38
39
} ,
39
40
ja : {
40
41
message : {
42
+ hello : 'こんにちは' ,
41
43
language : '日本語' ,
42
44
list : 'こんにちは、{0}!' ,
43
45
named : 'こんにちは、{name}!' ,
@@ -320,3 +322,53 @@ test('v-if / v-else', async () => {
320
322
`<p class="name">hello, <span>kazu_pon</span>!</p>`
321
323
)
322
324
} )
325
+
326
+ test ( 'vue/core slot changing' , async ( ) => {
327
+ const i18n = createI18n ( {
328
+ locale : 'en' ,
329
+ messages
330
+ } )
331
+
332
+ const App = defineComponent ( {
333
+ setup ( ) {
334
+ const { t, locale } = useI18n ( )
335
+ return { t, locale }
336
+ } ,
337
+ template : `<h1>{{ t('hello') }}</h1>
338
+ <form>
339
+ <label>{{ t('language') }}: </label>
340
+ <select v-model="locale">
341
+ <option value="en">en</option>
342
+ <option value="ja">ja</option>
343
+ </select>
344
+
345
+ <br />
346
+ First slot <br />
347
+ <i18n-t tag="div" keypath="with_single_slot">
348
+ <template #name>
349
+ <h1>name</h1>
350
+ </template>
351
+ </i18n-t>
352
+
353
+ <br />
354
+ Second slot <br />
355
+ <i18n-t tag="div" keypath="with_double_slot">
356
+ <template #a>
357
+ <h1>a</h1>
358
+ </template>
359
+
360
+ <template #blaha>
361
+ <h1>b</h1>
362
+ </template>
363
+
364
+ <template> testa </template>
365
+ </i18n-t>
366
+ </form>
367
+ `
368
+ } )
369
+ const wrapper = await mount ( App , i18n )
370
+
371
+ expect ( wrapper . html ( ) ) . toEqual (
372
+ `<h1>hello</h1><form><label>language: </label><select><option value="en">en</option><option value="ja">ja</option></select><br> First slot <br><div>with_single_slot</div><br> Second slot <br><div>with_double_slot</div></form>`
373
+ )
374
+ } )
You can’t perform that action at this time.
0 commit comments