-
Notifications
You must be signed in to change notification settings - Fork 30
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
ngx-translate not parsing subclasses #30
Comments
Having similar issue... im importing the the pollyfill in an shared service - but only the classes which directly import the pollyfill get parsed... what's the problem here? Is there a workaround? |
My workaround was to create a constructor in the child, which re-declared and re-imported all injectables. It then only calls super(...) to invoke the parent's constructor. |
I'm having the exact same issue. Did you ever come across a solution FloNeu? |
Hi, there... Short answer no - Longer Answer - kind of :) I didn't wast to
much time on it - but I guess the parser checks for the import and only
parses the file if he finds it to save time and not having to check every
file, which makes sense...
I just started to add a some-component.key.ts angular-service file to my
components, which imports the methode and defines the keys I want to inject
and use in it. If I want to re-use a key I just inject the service in
another component. I found it makes it easier and more transparent for me
which keys are outdated or still in use...
…On Wed, Jun 26, 2019, 16:23 timminss ***@***.***> wrote:
Having similar issue... im importing the the pollyfill in an shared
service - but only the classes which directly import the pollyfill get
parsed... what's the problem here? Is there a workaround?
I'm having the exact same issue. Did you ever come across a solution
FloNeu?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#30?email_source=notifications&email_token=AAKPZ6CH5UVH2GJ3NSGEBQTP4N3XJA5CNFSM4FEHQMU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYTWLHQ#issuecomment-505898398>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAKPZ6FMIRE62RKYVSGH65DP4N3XJANCNFSM4FEHQMUQ>
.
|
Thanks for your reply FloNeu! Would you mind going into a little more detail about your solution if you've got the time? Is some-component.key.ts a service (only used by 'some-component') which has many hard coded items, and returns the correct one based on a function input? |
@timminss Hello, sorry - i did forget to come back to this... for example, this is the translation.key.ts file of my login-component ( i exchanged the default '_' methode with 'translation_key' what can be done when calling the parser with
then in my component file constructor i import it like this.
and then use the key in my template:
not that here the translate-methode is a base-component methode i inherit to all my components
and finally the npm-script i use to extract the translation master.json:
Hope that's useful - all the best, Florian |
Migrated to Angular 9. Tried migrated i18n to use $localize but It still did not fully work thus I have to revert back. Painful. Confirmed that the extractor actually does not work on sub classes. Is there any way to force it work? Please anyone shed me some light !? |
Had to use the workaround as @johannks mentioned before that is injecting i18n:I18n on every component's constructor. |
Hello
It seems like ngx-translate doesn't support inheritance.
It doesn't parse a subclass which extends a parent class (with a protected i18n: I18n) unless the subclass has a constructor, re-declares and imports all injectables, and calls super(...).
It's a workaround, but would it be possible to not have to do this?
The text was updated successfully, but these errors were encountered: