Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

m-function-matcher only triggers when import * as m is found in the source file #127

Closed
GauBen opened this issue Dec 23, 2024 · 4 comments
Closed

Comments

@GauBen
Copy link

GauBen commented Dec 23, 2024

Hey!

I had a hard time figuring out why translation hints wouldn't show.

https://github.com/opral/monorepo/blob/4b9420b9bbeb2beb0e518c305130097500ddae12/inlang/source-code/plugins/m-function-matcher/src/ideExtension/messageReferenceMatchers.ts#L25C9-L25C43

I get why it is implemented this way, but for my use-case I have an i18n module that re-exports messages:

import { m, formatDate, formatTime } from '$i18n';

Would it be possible to relax m-function-matcher to allow any m import? Otherwise, I'd like to contribute an addition to the documentation for future reference.

Copy link
Member

Careful. The re-export likely breaks tree-shaking. You should check that in the build. Does the page that imports m from $i18n only containt the message that is used?

If it doesn't break tree-shaking, we can evaluate the options. The risk are false positives e.g. something is an m variable that is not a message function.

Copy link
Member

In any case, contributions whether for the docs, or functionality are welcome. For the implementation, let's check tree-shaking first.

@GauBen
Copy link
Author

GauBen commented Dec 23, 2024

Thanks for your swift reply @samuelstroschein! The $i18n module is "virtual", I'm using SvelteKit and I confirm that the build is properly tree-shaken, as there is no intermediate build step. I find the named import easier to use because VSCode can auto-add the import

@samuelstroschein
Copy link
Member

Got it. Closing this issue in favor of opral/inlang-paraglide-js#151.

If you do a PR, I will accept and deploy it!

@samuelstroschein samuelstroschein closed this as not planned Won't fix, can't repro, duplicate, stale Dec 23, 2024
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

No branches or pull requests

2 participants