Skip to content

Add option to log dynamic translation lookups (in HBS files)#514

Draft
robinborst95 wants to merge 2 commits intomainmatter:masterfrom
robinborst95:feature/dynamic-keys
Draft

Add option to log dynamic translation lookups (in HBS files)#514
robinborst95 wants to merge 2 commits intomainmatter:masterfrom
robinborst95:feature/dynamic-keys

Conversation

@robinborst95
Copy link
Copy Markdown
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