Skip to content
This repository has been archived by the owner on Apr 28, 2024. It is now read-only.

Factor out dependency on i18n #20

Open
@alexweissman

Description

Would be cool if we could decouple Fortress' dependence on MessageTranslator for translating validation error messages.

What should probably happen instead, is that Fortress should simply return the raw translation keys + placeholder data in its error messages. This would then be passed to the i18n component for translation.

Perhaps at the same time, we could tackle the TODO that's all over UF's controller methods:

        // Validate, and throw exception on validation errors.
        $validator = new ServerSideValidator($schema, $this->ci->translator);
        if (!$validator->validate($data)) {
            // TODO: encapsulate the communication of error messages from ServerSideValidator to the BadRequestException
            $e = new BadRequestException();
            foreach ($validator->errors() as $idx => $field) {
                foreach($field as $eidx => $error) {
                    $e->addUserMessage($error);
                }
            }
            throw $e;
        }

In this case, the raw translation keys+data should probably percolate all the way through the BadRequestException as well, and only get translated right at the point when they are about to be rendered for the user (so, Twig template or alert stream).

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions