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

Cannot use Localized strings in array - undefined #95

Open
moyoteg opened this issue Oct 8, 2019 · 1 comment
Open

Cannot use Localized strings in array - undefined #95

moyoteg opened this issue Oct 8, 2019 · 1 comment

Comments

@moyoteg
Copy link

moyoteg commented Oct 8, 2019

I have:
mainViews = ['Home', 'Providers', 'Carts']

I want:
mainViews = [LocalizedStrings.home, LocalizedStrings.providers, LocalizedStrings.carts]

so that I can:
mainView.map( (text, index) => { // code goes here })...

result:
undefined

@Larsrdev
Copy link

You are not using it correct. As mentioned in the documentation: https://github.com/stefalda/react-localization#typescript-support
you can do something like this:

export interface IStrings extends LocalizedStringsMethods{
    home_header: string;
    home_title: string;

    provider_header: string;
    provider_title: string;

    carts_header: string;
    carts_title: string;
}

public strings: IStrings;
this.strings = new LocalizedStrings({
            it: {
                home_header: "Punti",
                home_title: "Tempo"

                provider_header: "Uno",
                provider_title: "Roma"

                carts_header: "Prova",
                carts_title: "Testo"
            },
            en: {
                home_header: "Score",
                home_title: "Time"

                provider_header: "One",
                provider_title: "Rome"

                carts_header: "Check",
                carts_title: "Test"
            }
        });

And try to do some stuff or add logic to match the view depending strings.

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