Hi,
I couldn't understand why some Term Reference fields produced arrays with [und] =>, and others with [en] =>. Until I noticed the 'translatable' boolean in the field_config table.
But Drupal has mixed up its decisions, the consistency is lost. Some fields have translatable = 1, others 0 and no way for me to influence that. It's very frustrating, because it makes working with the values complex.
For example, working in a custom module with functions like field_view_field(), I'm trying to read terms from nodes with language=en, but the term field has [und].
I fixed my problems by manually going into field_config and setting everything I need to translatable = 1.
I've seen several threads about this, but the decision apparently was to remove a field-language setting. I think that decision needs another look.
Comments
Comment #1
juhaniemi commentedField translations will get more love in Drupal 8. I doubt this kind of architectural choices will/can be changed in 7.x branch.
In the meanwhile, I'd recommend using Entity module's Entity Metadata Wrappers, so you can streamline working with entities and field values. Getting values from fields is as easy as $node_wrapper->field_terms->value() without having to know anything about languages, etc...
I would gently mark this as a duplicate for #1260640: Improve field language API DX.
Comment #2
murzDrupal 8.x is not ready for using in production sites. What can I do for solve this problem in Drupal 7.x? I need to switch all fields into LANGUAGE_NONE, but can't do this.
In "field_config" table I change translatable=0 instead of 1 (via sql query) and clear all caches, but node still loads values from "en" instead of "und". How can I fix this problem?
Maybe some php code, hack or sql query?