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   983 Views

Avatar
jend

10 February 2012 at 6:41am (Last edited: 11 February 2012 4:40am), Community Member, 3 Posts

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

11 February 2012 at 6:07am Forum Moderator, 1093 Posts

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

11 February 2012 at 6:37am (Last edited: 11 February 2012 6:43am), Community Member, 3 Posts

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

12 February 2012 at 12:40am (Last edited: 12 February 2012 12:43am), Forum Moderator, 1093 Posts

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

12 February 2012 at 1:48am (Last edited: 12 February 2012 1:52am), Community Member, 3 Posts

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