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

QUESTION: Locatization Text with multiple parameters #5795

Closed
amendez1000 opened this issue Sep 17, 2020 · 2 comments
Closed

QUESTION: Locatization Text with multiple parameters #5795

amendez1000 opened this issue Sep 17, 2020 · 2 comments
Assignees
Milestone

Comments

@amendez1000
Copy link

Hello,

I am using .net core and Angular in a multi tenant application. In my localization text I have this:

Text {0} plus text {1}

In my code in Angular I am putting this:

{{ "question_login_to_ask_questions" | localize:'/account/login':'/account/register' }}

However, both parameters are shown in the position {0}. Does someone know how I can show the values correctly?

Thanks so much for your time.

Regards,
Arturo

@amendez1000
Copy link
Author

amendez1000 commented Sep 17, 2020

After investigate more and debug, I found the follow code can be improved to handle more than one parameter:

import { Injector, Pipe, PipeTransform } from '@angular/core';
import { AppComponentBase } from '@shared/app-component-base';

@Pipe({
    name: 'localize'
})
export class LocalizePipe extends AppComponentBase implements PipeTransform {

    constructor(injector: Injector) {
        super(injector);
    }

    transform(key: string, ...args: any[]): string {
        return this.l(key, args);
    }
}

We need to change this line:
return this.l(key, args);

By

return this.l(key, ...args);

This will solve my problem sending more than 1 parameter to the pipe.

@maliming
Copy link
Member

maliming commented Sep 18, 2020

We will check this. Thanks, @amendez1000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants