Skip to content

Conversation

@butlersrepos
Copy link

@butlersrepos butlersrepos commented Sep 11, 2025

Summary

This PR adds the ability to dynamically create namespace files during parsing when they don't exist, eliminating the need to pre-create namespace files before scanning.

Changes

  • Configuration Option: Added dynamicNamespaceCreation: false (disabled by default for backward compatibility)
  • Helper Method: Added createNamespaceFile(lng, ns) that safely creates namespace files and directory structure
  • Parser Integration: Modified parser logic to create namespaces when encountered instead of erroring
  • Comprehensive Tests: Added 5 test cases covering all scenarios including error handling

How it works

When dynamicNamespaceCreation: true is set in the configuration:

  1. Parser encounters a new namespace during key extraction
  2. Instead of throwing an error, it calls createNamespaceFile(lng, ns)
  3. Helper creates directory structure recursively if needed
  4. Writes empty JSON {} to the new namespace file
  5. Initializes internal resStore and resScan objects
  6. Parsing continues normally

Backward Compatibility

  • Feature is disabled by default (dynamicNamespaceCreation: false)
  • Existing behavior is preserved when disabled
  • No breaking changes to the API

Test Coverage

  • Dynamic creation when enabled
  • Error behavior when disabled (maintains existing functionality)
  • Recursive directory structure creation
  • Handling of existing files
  • Error scenarios and graceful failure

🤖 Generated with Claude Code

@butlersrepos
Copy link
Author

This attempted contribution was initially done with Claude Code but actively reviewed, tested, and edited afterward by a human (me).

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.

1 participant