Namespace Support #1285
ReschAndr
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
#1284
First of all this PR does not contain breaking changes.
The only issue could be, that the @biesbjerg/ngx-translate-extract tool doesn't support extracting the keys from the namespace translate service, pipe, and directive yet, but I will also provide a PR on their repo to add support for that.
First of all this PR does not contain breaking changes.
The only issue could be, that the @biesbjerg/ngx-translate-extract tool doesn't support extracting the keys from the namespace translate service, pipe, and directive yet, but I will also provide a PR on their repo to add support for that.
Motivation
We are currently working on migrating an existing web application (asp.net forms) to angular. Until now we used our own low-key namespace-translate pipe, which came with the issue of not being able to use the ngx-translate-extract tool. With this pr, I want to add the functionality of not having to define the absolute path of the translation key within very deep nested components. This will prevent spelling mistakes within the key and should help code more orderly.
Added Components
NamespaceTranslateService
The service should be provided on the component level with the
namespaceTranslateServiceProvider
helper.It provides functions to get the translation for a specific key(s) which will be prefixed with the namespace given to the
namespaceTranslateServiceProvider
function.NamespaceTranslatePipe
The NamespaceTranslatePipe provides the same functionality as the TranslatePipe but prefixes all keys with the namespace given to the namespaceTranslateServiceProvider.
NamespaceTranslateDirective
The NamespaceTranslateDirectiveprovides the same functionality as the TranslateDirective but prefixes all keys with the namespace given to the namespaceTranslateServiceProvider.
Comparison
Without Namespace Translate
With Namespace Translate
Beta Was this translation helpful? Give feedback.
All reactions