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

Translate integration #89

Open
rubenCodeforges opened this issue Aug 8, 2017 · 2 comments
Open

Translate integration #89

rubenCodeforges opened this issue Aug 8, 2017 · 2 comments

Comments

@rubenCodeforges
Copy link

rubenCodeforges commented Aug 8, 2017

Integrate support for translation keys for ngx-translate
The ngx-translate is a module that supports translation files, a good idea would be to add its service to translate incoming string so that when you add a translation key to the toast message it will translate it.

example :

this.toastyService.success("TOAST.UPDATE.SUCCESS");
@rubenCodeforges
Copy link
Author

At first sight i guess its doable in here https://github.com/akserg/ng2-toasty/blob/master/src/toasty.service.ts in the add method, if @akserg you are ok with that , please assign the issue to me ill add the changes.

@rubenCodeforges
Copy link
Author

rubenCodeforges commented Aug 8, 2017

Btw ive currently a wrapper service:

export class ToastService {
    constructor(private toastyService: ToastyService,
                private translateServie: TranslateService){
    }

    default(options: ToastOptions | string | number): void {
        if(typeof options == "string") {
            this.translateServie.get(options).subscribe((message)=>{
                this.toastyService.default(message);
            })
        }
    };
//....
}

Btw if the string is a simple message ( not translation ) the translate service will just return it in the subscribe, so you can do :

             this.toastService.default("Im just a string");
             this.toastService.success("TOAST.UPDATE.SUCCESS");

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

1 participant