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

Add possibility of translation via http://angular-translate.github.io/ #57

Closed
artworkad opened this issue Mar 7, 2015 · 8 comments
Closed

Comments

@artworkad
Copy link

You call toasts from within controllers, but this has a major downside: you have to hardcode the text for the toasts. If you provide a template that uses http://angular-translate.github.io/ a toast call would look like this:

toastr.info('SAVED_KEY');

in template:

{{ MSG | translate }}

and the angular translate module would determine the message for SAVED_KEY which is "Saved!".

@artworkad
Copy link
Author

Could be related #3 I will make a PR shortly. Stay tuned.

@Foxandxss
Copy link
Owner

i18n is always good, but I don't really want to make toasts insecure.

@dyanarose
Copy link

@artworkad would it be possible for you to inject the translation service or the resolved translations instead?

so instead of:
toastr.info('SAVED_KEY');

you have something like:

$translate('SAVED_KEY')
.then(function(translation)
{
    toastr.info(translation);
});

@PerchHero20
Copy link

Hello, I am stuck any advices?
In my en.json I got
"Index_Language_English": "English",
I can call it from html with {{ 'Index_Language_English' | translate }}
In js I have
toastr.warning("English");
I want to add translations so as the English word to be translated.
can you provide any advice?

@Foxandxss
Copy link
Owner

I am closing this because it is a concrete use case I cannot merge on the library. If you want to use the filters for i18n, you can override the template (Use the version without tpls and create your own template, check the readme).

@mmichaelbiz
Copy link

Will go with a custom template, however would be great to re-visit this and add it as part of the functionality.

Essential for multi language apps and hard coding the messages is not great even for single language apps. This could be a simple and extendable way to manage messages in one place.

How about adding the ability to add a 'translate' config and let toastr know to use the translate filter? Those who have security concerns can leave it off and those who need it can enable at their own risk.

👍

@Foxandxss
Copy link
Owner

It is still better to create another template for it. If I start adding opinions to the template, it will be a monster.

On the other hand, that library for i18n is not the only one and even applying filters is not the only option for that concrete library.

@mmichaelbiz
Copy link

No worries. Took about 5 mins to set up the template and its working like a charm!

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

5 participants