Problem/Motivation
The implementation of EntityType::getLowercaseLabel() is simplistic and doesn't offer overriding. That is a problem for some entity type labels like "JW Player preset" which just becomes "jw player preset".
Proposed resolution
Add optional "lowercase_label" key to ConfigEntityType/ContentEntityType annotation?
Or add a $lowercase = FALSE parameter to label() (and label_callback usages)?
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#11 | lowercaselabel-2604902-11.interdiff.txt | 1.1 KB | Arla |
#11 | lowercaselabel-2604902-11.patch | 2.63 KB | Arla |
#8 | lowercaselabel-2604902-8.patch | 2.55 KB | Arla |
#7 | lowercaselabel-2604902-7.patch | 1.35 KB | Arla |
Comments
Comment #2
dawehnerThat sounds for me like the best, because simplest, solution. Are you sure we need the additional parameter on the label() method?
Comment #3
ArlaThe label() parameter was meant as an alternative solution, in which case a default strtolower implementation could be overridden by entity classes using label_callback.
So I had two separate suggestions.
Comment #4
ArlaBtw this would also solve the problem mentioned in #2507235: EntityType::getLowercaseLabel() breaks translation. This is possibly a duplicate?
Comment #5
dawehnerGiven that a new entity key also allows you to not break any kind of API, it should be pretty okay for 8.1
Comment #6
ArlaSorry, I got EntityType::getLabel and Entity::label mixed up. Removing the second alternative then :)
Comment #7
ArlaHere's the general idea.
Btw I also have to take back #4 because this will only solve the translation problem if the lowercase_label is present for a particular entity type (or required and present for all, which would break APIs). Then, with the Block example mentioned in that issue, you could have
Then you would have both strings translatable and German could translate "Block" to "Block" and "block" also to "Block".
Comment #8
ArlaWith a test.
Comment #9
BerdirMakes sense, but to fix #2507235: EntityType::getLowercaseLabel() breaks translation, we need to add it to all entity types and we need them all to have a 'entity-type-label-lowercase' or similar context so german can translate "content" to uppercase "Inhalt". Maybe we should even enforce that context?
Comment #10
dawehnerIdeally you would use two test methods for the two cases.
Comment #11
ArlaOkay, separated the tests.
But I guess Berdir has a point in that we might want to do all this in the translation issue directly, so we can add things rather than add and then change things. I'll see if I can write up a patch for that other issue too.
Comment #12
Gábor HojtsyPatch looks fine. It would be nice to figure out how will this work if/once #1850080: Entity type labels lack plurality, cannot generate UI text based on label if plural is needed is added too. You don't need to resolve it here, just saying that is also in the works.
I agree it would be important to have a "Lowercase label" context. It needs to be in the annotation for potx to parse it properly, so not much of a chance to automate that at another place.
Comment #13
Gábor HojtsyShould we close this in favor of #2507235: EntityType::getLowercaseLabel() breaks translation BTW?
Comment #14
BerdirI guess that makes sense, we can re-open if the direction will change there but I don't think so.
Comment #15
Gábor Hojtsy