Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Translatable - default locale change of existing content


Reply


5 Posts   1045 Views

Avatar
jend

Community Member, 3 Posts

10 February 2012 at 6:41am

Edited: 11/02/2012 4:40am

Hi,
I hope it is not for the 113th time someone asking this - I am experiencing some problems after applying translatable - sure I have ignored this - yes I am stupid

Important: If the "default language" of your site is not english (en_US), please ensure to set the appropriate default language for your content before building the database with Translatable enabled.

The existing content was en_US, I have added other 2 (cs_CZ, and en_GB) which are the ones I want on the site. I have changed the _config.php and rebuild. :)

EDIT: Is there a way to revert to the original status quo - to rebuild the database with the correct default locale (cs_CZ instead of en_US)?
Thank you very much

Avatar
martimiz

Forum Moderator, 1132 Posts

11 February 2012 at 6:07am

Hi jend, welcome to the forums

No, I'm afraid there really is no turning back - unless someone has written a script for it..?

To make sure we uderstand correctly what you now have: you say you added other 2. Do you mean you now have a master en_US website and two other websiteversions en_GB and cs_CZ?

Or do you just have a cs_CZ master that has the wrong Locale (en_US) attached to it?

Avatar
jend

Community Member, 3 Posts

11 February 2012 at 6:37am

Edited: 11/02/2012 6:43am

Hi Martimiz,
Exactly - I have a en_US master (with czech content in it) and two other versions (cs_CZ and en_GB) as a result of aplying translatable extensions (without changing the default from en_US -> cs_CZ first).
I have tried to clean the db (modifying/deleting the locale fields and records - SiteTree, SiteConfig + translationgroups) but could not get rid of the en_US - it pops up from somewhere always.
The desired result is a cs_CZ master with current (en_US) content and empty en_GB language version.

Avatar
martimiz

Forum Moderator, 1132 Posts

12 February 2012 at 12:40am

Edited: 12/02/2012 12:43am

It 'pops up from somewhere'... But where does it popup? Do the Locale fields get rewritten as en_US?

I don't suppose you would want to revert back to a mySQL dump from before enabling Translatable? :-(

Anyway, if you want to use the original en_US site to become the default cs_CZ site I would start by doing something like this:

- do a database dump
- remove all existing pages/other stuff from the extra cs_CZ translation in the cms, if you're not going to use it.
- leave the en_GB translations as they are
- leave the translation groups as they are

// Set the site locale (just in case)
i18n::set_locale('cs_CZ');

// set the default language for a multilingual site
Translatable::set_default_locale('cs_CZ');

- empty the Locale fields in the database (something like: update xxx set Locale = '' where Locale='en_US') for:
SiteTree
SiteTree_Live
SiteTree_versions
SiteConfig
(And any other dataobjects you made translatable)

- do a /dev/build/?flush=1
- check the Locale fields, they should now be cs_CZ.
- check back here with the results :-)

One more thing - once you get things running, don't forget this:

public function init() {

parent::init();

if($this->dataRecord->hasExtension('Translatable')) {
i18n::set_locale($this->dataRecord->Locale);
}
...
}

_

Avatar
jend

Community Member, 3 Posts

12 February 2012 at 1:48am

Edited: 12/02/2012 1:52am

Hi Martimiz,
thanks a lot - :) yes I was thinking of using a backup, but finally found out exactly the same procedure (except for the final init) as you are describing below.
The problem with the en_US was a mistyping in a Translatable::set_default_locale directive - sorry to bother you.
Thank you very much