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

Support arrays in ngx-translate-testing #62

Open
GrumpyMeow opened this issue Jun 17, 2022 · 3 comments
Open

Support arrays in ngx-translate-testing #62

GrumpyMeow opened this issue Jun 17, 2022 · 3 comments

Comments

@GrumpyMeow
Copy link

GrumpyMeow commented Jun 17, 2022

Is your feature request related to a problem? Please describe.
We use your ngx-translate-testing package for Storybook and unit-tests to mock our translations.
The TranslateTestingModule does not support arrays for translations. The following error is given during build:

    Type 'string[]' is not assignable to type 'LanguageTranslation'.
    Type 'string[]' is not assignable to type '{ [translationKey: string]: LanguageTranslation; }'.
    Index signature for type 'string' is missing in type 'string[]'.

This error is given when we try:

TranslateTestingModule.withTranslations({
          'lifecycle': {
            'customer-profile': {
              'profiles': ["profile1","profile2"]      
            },
          },
        })

Arrays are supported by the TranslateModule.

In our template we do this:

<button
      *ngFor="let profile of 'lifecycle.customer-profile.profiles' | translate; let i = index" >
      {{ profile | translate }}
    </button>
"profiles": ["profile1", "profile2", "profile3"],

Describe the solution you'd like
Allow to specify arrays just like our translation which comes from a json file.

export declare type LanguageTranslation = string | string[] | {
    [translationKey: string]: LanguageTranslation;
};
@mwootendev
Copy link
Owner

I believe this should be supported in version 6.1.0. Have you updated to the lastest version?

@GrumpyMeow
Copy link
Author

V6.1.0 needs Angular v14. I’ll retry it when we arrive at Angular v14. We are currently still at Angular v13. thanks

@GrumpyMeow GrumpyMeow reopened this Dec 2, 2022
@GrumpyMeow
Copy link
Author

We've arrived at Angular v14 and using v6.1.0.
Unfortunately arrays still don't seem to work.

const translations = {
    dummyData: {
      header: {
        breadcrumbs: ['dummy1','dummy2'],
      },
    },
  };

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

No branches or pull requests

2 participants