Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix test
  • Loading branch information
jtydhr88 committed Dec 7, 2025
commit 0cbe8cb75c4b3446b0356ab31cb3e5704ee73ec2
4 changes: 4 additions & 0 deletions src/i18n.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ describe('i18n', () => {
})

it('should handle calling mergeCustomNodesI18n multiple times', async () => {
// Use fresh module instance to ensure clean state
vi.resetModules()
const { i18n, loadLocale, mergeCustomNodesI18n } = await import('./i18n')

mergeCustomNodesI18n({
zh: { plugin1: { name: '插件1' } }
})
Expand Down
4 changes: 4 additions & 0 deletions src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ export async function loadLocale(locale: string): Promise<void> {
* and immediately merges data for already-loaded locales.
*/
export function mergeCustomNodesI18n(i18nData: Record<string, any>): void {
// Clear existing data and replace with new data
for (const key of Object.keys(customNodesI18nData)) {
delete customNodesI18nData[key]
}
Object.assign(customNodesI18nData, i18nData)

for (const [locale, message] of Object.entries(i18nData)) {
Expand Down