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 opened this issue Jun 13, 2017 · 0 comments
Open

Factor out dependency on i18n #20

alexweissman opened this issue Jun 13, 2017 · 0 comments

Comments

@alexweissman
Copy link
Member

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).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant