I set name and description of property of my component with localization file, but ValidationMessage do not work with localization file. so i only can hard code the validation message for propery of component.
it displays the the address of String in localization file instead of actual string
the address is:
at.zarinpal::lang.component.payment.properties.callback_url.validation_message
and i'm sure the address is true and it works with name and description without a problem.
How are you telling the validation where your string is? Code example please.
this is code from my component class:
public function defineProperties()
{
return [
'callback_url' => [
'title' => 'at.zarinpal::lang.component.payment.properties.callback_url.name',
'description' => 'at.zarinpal::lang.component.payment.properties.callback_url.description',
'default' => Settings::get('callback_url'),
'type' => 'string',
'required' => true,
'validationMessage' => 'at.zarinpal::lang.component.payment.properties.callback_url.validation_message'
]
];
}
if you want, i can provide localization file too.
Yes please
code from Localization file: lang.php,
this is Persian (or Farsi) language with localization folder "fa"
return [
'plugin' => [
'name' => 'زرین پل',
'description' => 'افزونه پرداخت از طریق زرین پال',
],
'setting' => [
'name' => 'تنظیمات زرین پل',
'description' => 'تظیمات درگاه پرداخت زرین پل',
],
'component' => [
'payment' => [
'name' => 'پرداخت',
'description' => 'اضافه شود به صفحه پرداخت برای انجام عملیات پرداخت',
'properties' => [
'callback_url' => [
'name' => 'آدرس بازگشت از درگاه بانک',
'description' => 'آدرسی که کاربر پس از پرداخت در درگاه بانک به آن بازگشت داده میشود. در حالت عادی آدرسی است که در تنظیمات سیستم آن را وارد کرده اید.',
'validation_message' => 'لطفا آدرس بازگشت را وارد کنید'
]
]],
'verify_payment' => [
'name' => 'تصدیق پرداخت',
'description' => 'اضافه شود به صفحه بازگشت از درگاه پرداخت بانک']
]
];
And how about the code where you tell the validation where the localization string is?
Edit: Never mind, missed that in your first post :)
@LukeTowers : The problem is, that the validationMessage is not passed to the Translator: https://github.com/octobercms/october/blob/2659ae708f0c4cd45b48e4eaaac9e042d1a06649/modules/cms/classes/ComponentHelpers.php#L57
Not sure if adding it would have any side implications.
@alxy Thanks for spotting that!
@shkhaksar Did https://github.com/octobercms/october/commit/0df8f5545022366d2a4e18d9925d18c71f30cc94 fix your problem?
@LukeTowers yes it fixed, thanks for your help.