cli compile api: Allow to specify namespace/module type for createCompiledCatalog
See original GitHub issueIs your feature request related to a problem? Please describe.
I am planning to use jsLingui for a project at work. For various reasons and legacy codebase support, I cannot use jsLingui extraction mechanism and module import and need to inject json/objects as the catalogs for jsLingui in global
From @tricoder42 's response and after looking at the code a bit more, jsLingui core production module does not ship with the compiler and cannot use raw catalog.
Rather than using the raw catalog though, it would be very nice if I can use a compiled js object as the catalog to non-module JS code.
Currently the output for createCompiledCatalog
is:
module.exports={languageData....}
What I would like to be able to do with createCompiledCatalog
is:
window.translations={languageData}
Describe the solution you’d like
Similar to --namespace
argument for messageformat.js CLI, we can add a namespace param to createCompiledCatalog
(not sure namespace
is the right name here; suggestions are welcomed):
- if es6 is passed, then the output will be
export default {}
- if passed something that contains a ‘.’(we can be as fancy as we like about regex to validate the expression), then use that. ex: window.translations
I can put together a pull request sometimes this weekend or next week.
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (9 by maintainers)
Top GitHub Comments
Hey @dephiros, what about this:
cjs
formodule.exports
(the default option)es
forexport defaults
window.(.*)
for adding window globalglobal.(.*)
for adding node.js globalIf you could also add this as a option to
lingui compile
and/or config to @lingui/conf with documentation, that would be amazing!Released in v2.6.0