xtform icon indicating copy to clipboard operation
xtform copied to clipboard

translations

Open ReinierGielen opened this issue 10 years ago • 5 comments

The new override possibility for the error messages is nice, but enough for me as I need to make my site multi-lingual.

For the multi-lingual support we use angular-gettext.

In the previous version of xtForm I hacked the call to getText in the code and now I tried it with the new override functionality. This does not seem to work. I get an injection error when I try to use the getText command in the xtFormConfigProvider.

In the old version I used: var errString = this.gettextCatalog.getString(key); In the function showErrors where the key is the property being validated.

I assume more people have a use for this option, so could this be included where you set it in the config which option you want to use ?

ReinierGielen avatar Jan 16 '15 11:01 ReinierGielen

Thanks for taking the time to test out the new package. You can override all errors in your module config by a call to the xtformconfigprovider.setErrorMessages and providing each key and value. Can you not make the calls to gettext here?

refactorthis avatar Jan 16 '15 21:01 refactorthis

I tried that, but unfortunatly the function I need to inject is a service and you can not inject a service in a config. But I'll look for an alternative solution.

ReinierGielen avatar Jan 19 '15 09:01 ReinierGielen

I managed to get a translation with the following statement: msg-required="{{'required'|translate}}"

The disadvantage of course is that I need to add this to every input field.

ReinierGielen avatar Jan 19 '15 11:01 ReinierGielen

Ah right, I guess I could make a change so that setErrorMessages() can be called from the service as well as the provider.

On Mon, Jan 19, 2015 at 10:45 PM, ReinierGielen [email protected] wrote:

I managed to get a translation with the following statement: msg-required="{{'required'|translate}}"

The disadvantage of course is that I need to add this to every input field.

— Reply to this email directly or view it on GitHub https://github.com/refactorthis/xtform/issues/25#issuecomment-70481349.

refactorthis avatar Jan 20 '15 11:01 refactorthis

I'm using the famous angular-translate and I'm also adding the translation filter to each field individually.

+1 for setErrorMessages() on a service level.

idreeshaddad avatar Apr 19 '15 15:04 idreeshaddad