Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The current push notification token entity does not contain a language code, but needs it.
At first, I was trying to implement this using a "language" base field. This field brings a lot of nice validations (e.g. valid language when creating token through REST), but also wants to translate tokens, which is not applicable to this module.
So instead, I'm going with a basic string field and add a custom validation plugin that validates the language code.
Comment | File | Size | Author |
---|---|---|---|
#2 | token_langcode_validation.patch | 5.54 KB | haagendazs |
Comments
Comment #2
haagendazs CreditAttribution: haagendazs as a volunteer commentedMade some good progress on this, but then my dev environment blew up. Here's a patch of the current state. Will finish soon.
Comment #4
haagendazs CreditAttribution: haagendazs as a volunteer commentedThis is ready for review:
Comment #5
mihai7221 CreditAttribution: mihai7221 commentedCan you please explain what is the logic behind translating the token entities? Why they need to be translated ?
I was thinking that since we already translate the push notifications, on sending, the language for the users is taken from the preferred account's language or the default site language if the content translation hasn't been enabled.
Comment #6
haagendazs CreditAttribution: haagendazs as a volunteer commented@canutza: I have two reasons, and the first one is probably a pretty weak one.
What do you think?
Comment #7
mihai7221 CreditAttribution: mihai7221 commentedOk, I see your point, you are right.
Everything seems to work with your patch, however, the error messages are not well formatted in the watchdog because it doesn't interpret HTML, it displays plain text.
Also, the rest call throws a 422 "Unprocessable Entity" with the message "The website encountered an unexpected error. Please try again later." so this is something that we should work on I suppose.