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 option to log dynamic translation lookups (in HBS files) #514

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

robinborst95
Copy link
Contributor

This PR adds the option to detect dynamic translation lookups, as suggested in #9. This is still a work in progress (e.g. it needs more tests), but it can be tested manually already. For now this only detects them in HBS files, but with some changes I think it's doable for JS files as well (in another PR though).

Note that this PR builds on top of #483, as I made changes there that made it easy to detect dynamic parts in a template.

@Turbo87, is this what you had in mind (if anything) in terms of logging? I was also thinking of trying to map unused translations to the dynamic translations to find a match as a suggestion for the whitelist. To illustrate what I mean by that: if you have the following in a template:

{{t (concat "prefix." this.dynamicKey ".value")}}

and an actual translation:

prefix:
  concrete-type:
    value: Some value

then this PR logs out:

prefix.{{this.dynamicKey}}.value

This is something we can turn into a regex:

/^prefix\..*\.value$/

and provide as a suggestion for whitelisting the unused translation.

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

Successfully merging this pull request may close these issues.

1 participant