Skip to content

Instantly share code, notes, and snippets.

@ashour
Created February 13, 2020 11:13
Show Gist options
  • Save ashour/881b68686136f99aba1462907436e284 to your computer and use it in GitHub Desktop.
Save ashour/881b68686136f99aba1462907436e284 to your computer and use it in GitHub Desktop.
<?php
require_once dirname(__FILE__) . '/../i18n/I18n.php';
class Validator
{
// ...
private function getErrorText($field, $rule, $arg)
{
$key = I18n::hasKey("error_{$rule}_{$field}") ?
"error_{$rule}_{$field}" : // error_required_first_name
"error_{$rule}"; // error_required
$translatedField = ucwords(I18n::__($field));
return I18n::__($key, ['field' => $translatedField, 'arg' => $arg]);
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment