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

[FR]: Support context/comments #42

Open
vandres opened this issue Mar 10, 2024 · 2 comments
Open

[FR]: Support context/comments #42

vandres opened this issue Mar 10, 2024 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@vandres
Copy link

vandres commented Mar 10, 2024

Would it be possible, to implement context as this fork https://www.npmjs.com/package/@shavenzov/ngx-translate-extract ?

@michaelbromley
Copy link
Member

Note: the feature is described here: https://www.npmjs.com/package/@shavenzov/ngx-translate-extract#context-and-comment-support

I'll leave this to the community to see if someone has the will and ability to implement this. If so, let me know and we can discuss whether that API is the best option.

@michaelbromley michaelbromley added enhancement New feature or request help wanted Extra attention is needed labels Mar 11, 2024
@vandres
Copy link
Author

vandres commented Mar 13, 2024

I created a first running version for us. https://github.com/vandres/ngx-translate-extract

Docs are lacking and I am not sure, if the quality is good enough for a PR. Would love some feedback from you guys!

We are using it with CrowdIn the following way:

ngx-translate-extract -k --input ./src --output ./src/static/assets/i18n/{en,de,fr,it,nl,es,sv,ja,da,no}.json --clean --sort --format context-json --format-context-key crowdinContext --format-value-key text

With marker from https://github.com/vandres/ngx-translate-extract-marker:

marker('We', 'Short for Wednesday');

With Pipe, Service or Directive, just provide a "_context" translate param:

<h3 mat-subheader>{{ "User" | translate: {_context: 'System-User'} }}</h3>

Known issues:

  • remove context, after it has been added to the translations files, not automatically possible
  • no unit tests for context
  • conversion between different json formats untested

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants