Jump to:

10842 Posts in 2512 Topics by 1792 members

All other Modules

SilverStripe Forums » All other Modules » Translatable - default locale change of existing content

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 805 Views
  • jend
    Avatar
    Community Member
    3 Posts

    Translatable - default locale change of existing content Link to this post

    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

  • martimiz
    Avatar
    Forum Moderator
    1035 Posts

    Re: Translatable - default locale change of existing content Link to this post

    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?

  • jend
    Avatar
    Community Member
    3 Posts

    Re: Translatable - default locale change of existing content Link to this post

    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.

  • martimiz
    Avatar
    Forum Moderator
    1035 Posts

    Re: Translatable - default locale change of existing content Link to this post

    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);
    }
    ...
    }

    _

  • jend
    Avatar
    Community Member
    3 Posts

    Re: Translatable - default locale change of existing content Link to this post

    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

    805 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.