Hi.
I am using Script Runner for validating a lot of custom fields.
Now I have to translate the error messages.
scripted_yellow.png
I am unable to show a message depending on the user's language setting. I've tried to use a language key (from a custom plugin), i18nHelper.getText(), with no success
¿Is it possible to internationalize this form field?
Thank you!!
You won't be able to provide a dynamic language like that with the Simple Scripted Validator, but you might be able to pull it off with a regular Scripted Validator.
Just change the string text in the exception you throw to match the user's language setting.
To get your other plugin's i18nHelper object, you may want to read up on scripting other plugins as well.
Thank you for your response.
I've tried replacing "Simple Scripted Validator" with "Custom Script Validator" but now I'm facing another issues.
When validation fails and I throw a InvalidInputException("fieldname", "error"), JIRA places the error message at the top of the dialog instead of the field's bottom. However when I use a Simple Scripted validator, JIRA places it correctly. ¿How can I show the error message at the bottom of the associate custom field?
error_at_top.jpg
Another difference when I use "Custom Script Validator" is that JIRA adds a header before the list of errors ("There were some errors when trying to create this issue"). Using Simple Scripted Validator only shows the message without any header. I'd like to show the error message without any header, but It is not important.
Thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Pass the field name to the exception constructor as an argument. From the docs:
throw new InvalidInputException("myField", "UR DOIN IT RONG")
The general messages are those without a field parameter specified:
throw new InvalidInputException("UR DOIN IT RONG IN A MOAR GENERAL WHEY")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Again
Maybe I've explained bad, English is not my main language.
I'll try to explain with other words
I am already doing that.
throw new InvalidInputException(fieldName,errorMessage);
where fieldName is the custom field name that appears on /secure/admin/ViewCustomFields.jspa list. I have tried the translation name too.
The only way is using customfield_10029 that It is the id of the field in the form on the screen.I don't like using the id because we have multiple environments where we replicate the configuration, but the id of the fields does not have to be the same
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.