Skip to content

fix: handle empty YAML locale files gracefully - #32

Merged
rosskevin merged 1 commit into
alienfast:mainfrom
kainstar:fix/handle-empty-locale-files
May 11, 2026
Merged

rosskevin merged 1 commit into
alienfast:mainfrom
kainstar:fix/handle-empty-locale-files

Conversation

@kainstar

@kainstar kainstar commented May 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem

When a locale file is empty, js-yaml's load() returns null instead of an object. This null value is then passed directly to either setProperty (when namespaceResolution is enabled) or used as resBundle[lang] (when it isn't). In both cases, a subsequent merge() call can silently discard previously loaded content for that locale — i.e. if a locale directory contains both a populated file and an empty file with the same namespace, the empty file's null result can overwrite the populated one.

Fix

Add a ?? {} fallback after loadAndParse() so that empty files are treated as empty objects, leaving all other locale content unaffected.

- const content = loadAndParse(langFile)
+ const content = loadAndParse(langFile) ?? {}

@kainstar
kainstar force-pushed the fix/handle-empty-locale-files branch from 8ef1d08 to 104fc9f Compare May 11, 2026 03:04
@rosskevin
rosskevin merged commit 92879ed into alienfast:main May 11, 2026
4 checks passed
@kainstar
kainstar deleted the fix/handle-empty-locale-files branch May 29, 2026 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants