Problem

  • The entity system enforces a $langcode property for all entities, but when the actual entity is a Language, the property conflicts with the Language's langcode.

Goal

  • Do not enforce any hard-coded properties onto entities.

Proposed solution

  1. Provide a way to opt-out of the default $langcode handling; i.e., retaining the originally intended behavior, but allowing Language entities to work without dirty hacks.

Comments

Gábor Hojtsy’s picture

It would be great to keep the language handling in the Entity base, since that would make it easy for people to just have language support on any kind of entity (their use on config entities for example is not yet fully explored but can be pretty useful as well for example).

tim.plunkett’s picture

I'd say put it in ContentEntityInterface.

sun’s picture

I absolutely have to agree with @Gábor Hojtsy, because ConfigEntity objects share the same semantics of ContentEntity objects with regard to language support:

Just like any other content entity, Configurables can be created in any language (as original language).

This means I can initially create a Configurable in German, and I should be able to translate it into English later on, if I need to.

For this reason, I intentionally chose a careful wording and proposed to "opt-out" in the issue summary. ;)

fago’s picture

The entity system enforces a $langcode property for all entities, but when the actual entity is a Language, the property conflicts with the Language's langcode.

The entity sytem does not enforce this, it's just in the base class Entity. So doing your own should suffice. Also, with #1346214: [meta] Unified Entity Field API language handling is becoming better encapsulated such that it should suffice to override one or two methods from the base class to use $langcode not for language handling.

andypost’s picture

Language as ConfigEntity also have a $langcode that points it's language so only a question how to define a relation betwen a lang_code and language entity

alexpott’s picture

Status:Active» Closed (won't fix)

Now that #1754246: Languages should be configuration entities has landed this issue is no longer relevant. The langcode on the config entity refers to the language that the name is in.