Steps to reproduce:

1) Locale is disabled.
2) Create a new article and populate the body field. The field is $node->body[LANGUAGE_NONE]...
3) Enable locale.
4) Edit same article. The body is gone. Enter new text. The field is now $node->body['en']...

Maybe when we enable/ disable locale we should convert all LANGUAGE_NONE to the default language and vice versa?

Comments

yched’s picture

Subscribe.

plach's opinion welcome :-)

plach’s picture

Title: Tranlatable field's content is lost when enable/ disable locale module » Field content is no more accessible when enabling/disabling Locale module
Component: locale.module » language system
Issue tags: +translatable fields

I suspect this is caused by Locale changing default language for nodes not having language support enabled from LANGUAGE_NONE to language_default(). Content is not lost, it just doesn't show up in the form, since form language and field languages do not match. We probably need to account for this somewhere before displaying the form.

Edit: this would fix the issue on enabling Locale. When Locale is disabled every field content with language different from LANGUAGE_NONE is no more *visible*, so I think this part should be ignored, since it was a design decision (if you disable Locale after creating multilingual content you may expect something can stop working).

good_man’s picture

Is there any reason why we have the LANGUAGE_NONE? I mean why not setting the language (in case locale is disabled) to the installation language?

plach’s picture

Status: Active » Postponed (maintainer needs more info)

@Amitaibu:

I cannot reproduce this using the steps described in the OP. Would you provide some more information?

@good_man:

Core implements a sensible behavior: for sites not having Locale enabled having the very concept of language makes no sense, so node language is always LANGUAGE_NONE. When Locale is enabled and language support is disabled what should be the "right" behavior is debatable and mostly depends on your particular needs, AAMOF i18n allows to change the core behavior providing more options.

amitaibu’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

@plach,
Indeed, I can't reproduce it myself (although I'm sure it did happen as described in the OP). Has something changed? Anyway, closing issue.

amitaibu’s picture

Status: Closed (cannot reproduce) » Active

Ok, re-found it. Indeed, OP scenario wasn't correct.

1) Clean install.
2) Enable locale module.
3) Create an article and popualte body. Field has "en" not LANGUAGE_NONE.
4) Disable locale module.
5) Body field is no longer accessible.

good_man’s picture

Status: Active » Postponed (maintainer needs more info)

@plach: I got your point, but since Drupal installer is by default in English (or another language if you have it's translation package), we can consider that it's installing & running in English. Haven't think of what problems & issues will follow, but want to think & consider the pros of this approach. Any thoughts?

Edit: dont' know what happend to the status & why it's changed! didn't touch it.

good_man’s picture

Status: Postponed (maintainer needs more info) » Active

going back to active after the wierd behaviour.

plach’s picture

Title: Field content is no more accessible when enabling/disabling Locale module » Field content is no more accessible after enabling Locale module
Status: Active » Closed (cannot reproduce)

@Amitaibu:

As I said, the fact that multilingual content may be no more accessible when Locale is disabled is a design decision. Altering field languages on disable/uninstall may lead to unpredictable consequences when more than one field translation is available. I don't think requiring people to leave Locale enabled after they created multilingual content is such an unsensible request.

OTOH if this actually happens after enabling Locale we need to fix it. Please, reopen if you can reproduce it.

@good_man:

The behavior you are proposing makes perfect sense, but it is just a different (sensible) use case. In D6 it was decided to implement a different (sensible) behavior and changing it would involve tricky upgrade path issues. Anyway we are OT here, please open a new issue for D8 and link it here if you really wish to go on this way.

amitaibu’s picture

Status: Closed (cannot reproduce) » Closed (works as designed)

@plach,
Thanks for the comment. Setting to correct status.

plach’s picture

Title: Field content is no more accessible after enabling Locale module » Field content is no more accessible after disabling Locale module
lduerig’s picture

All well and wonderful if that is the design of the system, but what if I actually want to disable the Locale module? I already have enough content here that I'd rather not lose. I don't really like playing with the database directly, but I will if I have to, and just changing the language field in the node table doesn't seem to solve the problem. How can I uninstall the Locale module without losing my content?

plach’s picture

@lduerig:

Setting node language and field languages to LANGUAGE_NONE ('und') and clearing the cache should do the trick.

e.g.:

UPDATE node SET language = 'und'
UPDATE field_data_body SET language = 'und'
UPDATE field_revision_body SET language = 'und'

lduerig’s picture

@plach Very late that I noticed this reply, but the question is still valid, so I will do that. Thanks!

gdhp’s picture

Issue summary: View changes

Sorry where should I run the command in #14? My SQL?

Annoyingly I found this error because I had locale enabled it for no real necessity (it was a requirement of another module that I had tested and then discarded - I think it was AG Reservations). However I had left Locale on during the build.

I then went through and turned off all non essential modules after build and came across Locale which was still turned on. Switched it off and suddenly all the content has gone. Not great. Hopefully it will be easy to fix.