Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

additional template schema for validation exceptions #815

Merged

Conversation

darkv
Copy link
Member

@darkv darkv commented Feb 7, 2017

To localize an ERXValidationException there are currently five different localization keys which are checked in a specific order:

  1. Entity.Property.Type
  2. Entity.Property
  3. Property.Type
  4. Property
  5. Type

The problem is if you have an entity with several properties which should give you the same localization for a specific exception type you need either:

  • many similar localization entries (using schema 1.)
  • change global localization for exception type (schema 5.)

The latter one avoids many duplicate keys but often you would like to restrict that localization to a specific entity and not changing it for all entities.

This patch adds a new template key Entity.Type to realize that which gives a modified order:

  1. Entity.Property.Type
  2. Entity.Property
  3. Entity.Type
  4. Property.Type
  5. Property
  6. Type

@darkv darkv added the Wonder7 label Feb 7, 2017
@paulhoadley
Copy link
Contributor

I like it. This should be entirely backwards compatible, shouldn't it? Can you think of an edge case where this would affect an existing system? (I can't.)

@darkv
Copy link
Member Author

darkv commented Feb 8, 2017

It should be safe. It is quite improbable that you get a false positive with already existing localization keys. That would be that the new Entity.Property would match an already used Entity.Type or Property.Type geared towards a different case.

The only case I can think of is that someone uses a "manual" localization with just that exact key but then the localization probably will be the very same text.

@paulhoadley paulhoadley self-assigned this Feb 8, 2017
@paulhoadley paulhoadley merged commit 5acc32f into wocommunity:master Feb 8, 2017
@darkv darkv deleted the validation_localization_patch branch February 9, 2017 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants