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

Add support for translations in actual addons #481

Merged
merged 1 commit into from
Apr 22, 2022

Conversation

robinborst95
Copy link
Contributor

@robinborst95 robinborst95 commented Mar 17, 2022

Similar to #480, but this PR adds support for actual addons, also issued in #5 (and closes #5). Not too sure if this covers all scenarios (I just looked up translations folders in node_modules/* and node_modules/@*/*, the latter for scoped addons), but at least it works for our codebase.

To elaborate a bit: translations in actual addons are available for use in an app, but since they're not owned by the app, they show up under Missing translations (the ones that are used). Just adding them to the translationFiles won't work properly yet, as that would cause such translations to end up under Unused translations while they could still be used by the addon itself (and that's not the purpose here). So, I split it up into own translations and addon translations, so that just the own translations can be used to detect unused translations, and the maps combined to detect missing translations.

Note that I didn't add tests yet, I'd first like to have some confirmation that this a good approach. After I added a test for in-repo addons, it was quite simple to add a test for actual addons as well.

@robinborst95 robinborst95 force-pushed the feature/addon-paths branch 3 times, most recently from bedf499 to 1531a58 Compare March 25, 2022 14:17
@Mikek2252 Mikek2252 added the enhancement New feature or request label Mar 25, 2022
@robinborst95 robinborst95 force-pushed the feature/addon-paths branch from 2ce9f10 to a1a139d Compare April 4, 2022 08:16
@robinborst95 robinborst95 force-pushed the feature/addon-paths branch 3 times, most recently from 3304981 to 4f9e801 Compare April 20, 2022 11:29
index.js Outdated Show resolved Hide resolved
index.js Show resolved Hide resolved
index.js Show resolved Hide resolved
test.js Show resolved Hide resolved
@robinborst95 robinborst95 requested a review from Mikek2252 April 20, 2022 14:13
Copy link
Collaborator

@Mikek2252 Mikek2252 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, i think the new opt in approach is best and it gives devs flexibility, Im still not a huge fan of using addon translations, but i think this works better then whitelisting the ones you are using as they can easily go out of date quickly. Thanks for your work and i'll look to create new release with your changes tomorrow

@robinborst95
Copy link
Contributor Author

robinborst95 commented Apr 21, 2022

Thanks for the approval! I understand your thoughts about addon translations, so maybe good to quickly elaborate on how we use them. Our app consists of a few in-repo addons and a few actual addons, which are scoped dependencies, called @feedbackfruits/.... These addons are basically part of the application, but they're in their own repos to separate the concerns (and separate dummy apps, etc).

So that's why we can safely rely on using some translations from these addons in our app, and it's the reason why I wanted to add support for it here :)

While I'm at it, do you think this PR where I added support for the concat helper has any chance of getting merged at some point as well? We have quite some occurrences that use the concat helper, so if it's not gonna make it, I'll have to go for changing them into more verbose ifs...

@Mikek2252 Mikek2252 merged commit ddcf8b8 into mainmatter:master Apr 22, 2022
@robinborst95 robinborst95 deleted the feature/addon-paths branch April 22, 2022 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support translations in addons (and in-repo-addons)
2 participants