svelte-i18n icon indicating copy to clipboard operation
svelte-i18n copied to clipboard

Problems with LIB check in cli extractor

Open mojoaxel opened this issue 2 years ago • 1 comments
trafficstars

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:

  1. If someone uses a forked, scoped package (e.g. @fullstax/svelte-i18n).
  2. 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.
  3. 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.

mojoaxel avatar Oct 01 '23 22:10 mojoaxel

I've created a pull-request to implement this: #234

mojoaxel avatar Oct 01 '23 22:10 mojoaxel