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({
5858 } ) as unknown as Composer & ComposerInternal )
5959
6060 return ( ) : VNodeChild => {
61- const keys = Object . keys ( slots ) . filter ( key => key !== '_' )
61+ const keys = Object . keys ( slots ) . filter ( key => key [ 0 ] !== '_' )
6262 const options = create ( ) as TranslateOptions
6363 if ( props . locale ) {
6464 options . locale = props . locale
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ import type { Ref } from 'vue'
2727const messages = {
2828 en : {
2929 message : {
30+ hello : 'hello' ,
3031 language : 'English' ,
3132 quantity : 'Quantity' ,
3233 list : 'hello, {0}!' ,
@@ -38,6 +39,7 @@ const messages = {
3839 } ,
3940 ja : {
4041 message : {
42+ hello : 'こんにちは' ,
4143 language : '日本語' ,
4244 list : 'こんにちは、{0}!' ,
4345 named : 'こんにちは、{name}!' ,
@@ -320,3 +322,53 @@ test('v-if / v-else', async () => {
320322 `<p class="name">hello, <span>kazu_pon</span>!</p>`
321323 )
322324} )
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