@@ -162,13 +162,15 @@ export function flattenTranslationNode(obj: Record<string, unknown>, parentSegme
162162
163163export function buildInspectorTree ( options : BuildInspectorTreeOptions ) : I18nDevtoolsInspectorNode [ ] {
164164 const parsed = parseInspectorNodeId ( options . nodeId )
165+ const activeLocale = options . activeLocale
166+ const activeRoute = options . activeRouteName || 'index'
165167
166168 if ( parsed . kind === 'root' ) {
167169 const locales = collectLocaleCodes ( options . storage , options . configuredLocales )
168170 const nodes : I18nDevtoolsInspectorNode [ ] = [
169171 {
170172 id : NODE_ACTIVE ,
171- label : `Active (${ options . activeLocale } :${ options . activeRouteName || 'index' } )` ,
173+ label : `Active (${ activeLocale } :${ activeRoute } )` ,
172174 tags : [ ACTIVE_TAG ] ,
173175 } ,
174176 ]
@@ -180,7 +182,7 @@ export function buildInspectorTree(options: BuildInspectorTreeOptions): I18nDevt
180182 nodes . push ( {
181183 id : `${ PREFIX_LOCALE } ${ code } ` ,
182184 label : configured ?. displayName ? `${ code } (${ configured . displayName } )` : code ,
183- tags : code === options . activeLocale ? [ { ...ACTIVE_TAG , tooltip : 'Active locale' } ] : undefined ,
185+ tags : code === activeLocale ? [ { ...ACTIVE_TAG , tooltip : 'Active locale' } ] : undefined ,
184186 } )
185187
186188 // Flat chunk nodes (not nested): Vue DevTools selection is unreliable for nested
@@ -189,7 +191,7 @@ export function buildInspectorTree(options: BuildInspectorTreeOptions): I18nDevt
189191 nodes . push ( {
190192 id : `${ PREFIX_CHUNK } ${ code } |${ routeName } ` ,
191193 label : `${ code } :${ routeName } ` ,
192- tags : activeChunkTag ( code , routeName , options . activeLocale , options . activeRouteName ) ,
194+ tags : activeChunkTag ( code , routeName , activeLocale , activeRoute ) ,
193195 } )
194196 }
195197 }
@@ -198,9 +200,7 @@ export function buildInspectorTree(options: BuildInspectorTreeOptions): I18nDevt
198200 }
199201
200202 if ( parsed . kind === 'active' ) {
201- const locale = options . activeLocale
202- const routeName = options . activeRouteName || 'index'
203- return flattenTranslationNode ( options . activeTranslations ?? { } ) . map ( ( node ) => withKeyPrefix ( locale , routeName , node ) )
203+ return flattenTranslationNode ( options . activeTranslations ?? { } ) . map ( ( node ) => withKeyPrefix ( activeLocale , activeRoute , node ) )
204204 }
205205
206206 if ( parsed . kind === 'locale' && parsed . locale ) {
@@ -209,7 +209,7 @@ export function buildInspectorTree(options: BuildInspectorTreeOptions): I18nDevt
209209 id : `${ PREFIX_CHUNK } ${ locale } |${ routeName } ` ,
210210 label : routeName ,
211211 children : [ ] ,
212- tags : activeChunkTag ( locale , routeName , options . activeLocale , options . activeRouteName ) ,
212+ tags : activeChunkTag ( locale , routeName , activeLocale , activeRoute ) ,
213213 } ) )
214214 }
215215
@@ -225,7 +225,7 @@ export function buildInspectorTree(options: BuildInspectorTreeOptions): I18nDevt
225225 const routeName = parsed . routeName || 'index'
226226 const chunk = options . storage . translations . get ( `${ locale } :${ routeName } ` ) as Record < string , unknown > | undefined
227227 const segments = parsed . segments ?? [ ]
228- const isActiveContext = options . activeLocale === locale && ( options . activeRouteName || 'index' ) === routeName
228+ const isActiveContext = activeLocale === locale && activeRoute === routeName
229229 const source = isActiveContext ? ( options . activeTranslations ?? chunk ?? { } ) : ( chunk ?? { } )
230230
231231 return flattenTranslationNode ( source , segments ) . map ( ( node ) => withKeyPrefix ( locale , routeName , node ) )
0 commit comments