svelte-i18n
svelte-i18n copied to clipboard
Problems with LIB check in cli extractor
Is your feature request related to a problem? Please describe.
The cli extractor checks if the format method was imported from the hard-coded string 'svelte-i18n'.
This can cause multiple problems. In these cases the extractor does not work:
- If someone uses a forked, scoped package (e.g. @fullstax/svelte-i18n).
- If a project wants to import the format function not from 'svelte-i18n' directly but from a wrapper lib
(e.g.
import { _ } from '../helpers/i18n), maybe to hide the i18n implementation detail. - If someone wants to use the extractor together with a compatible lib like svelte-intl-precompile.
Describe the solution you'd like
I propose to introduce a new cli parameter unsave to disable the library-check altogether.
This could look like this: svelte-i18n extract --unsave .
Describe alternatives you've considered
It would be possible to not use the hard coded lib-name but instead get the lib-name from the package.json. This would solve problem 1 but not 2 and 3.
It also would be possible to introduce a cli parameter to provide the lib-name directly.
e.g. svelte-i18n extract --lib-name "svelte-intl-precompile" .
This would solve problem 1 and 3 but not 2.
How important is this feature to you?
I'll provide a fix for this shortly. If this will not get merged within a few days I'll release my own fork.
I've created a pull-request to implement this: #234