Jump to:

4895 Posts in 7193 Topics by 1472 members

Installing SilverStripe

SilverStripe Forums » Installing SilverStripe » About Multi Language installation

Getting SilverStripe up and running on your computer and on your web server.

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

Page: 1 2
Go to End
Author Topic: 4189 Views
  • atroz
    Avatar
    Community Member
    3 Posts

    About Multi Language installation Link to this post

    Hello

    Im new with the silverstripe im working with the 2.3.7 Version I would like to know what is the correct way to configure multi-language content, try the options I found on the forum and in the site documentation but i still getting errors

    thaks for any help

  • OwenW
    Avatar
    Community Member
    45 Posts

    Re: About Multi Language installation Link to this post

    Hi atroz,

    To help us in the forums understand how we can help you, what are the errors that you are seeing with the multi-language content? Also, what options have you enabled?

    Cheers
    Owen

  • atroz
    Avatar
    Community Member
    3 Posts

    Re: About Multi Language installation Link to this post

    ok first i try addthis line to the _config.php

    Object::add_extension('SiteTree', 'Translatable');

    as i read in http://doc.silverstripe.org/doku.php?id=multilingualcontent but i get this "There has been an error
    The website server has not been able to respond to your request", then i use the command ?isDev=1 to try to look where the error was but i get a big list of errors about Mysql.

    then i find this in the forums

    in mysite\_config.php add:

    Translatable::enable();

    but i get similar errors ...

    im doing all bad or missunderstanding something?

    please help

  • OwenW
    Avatar
    Community Member
    45 Posts

    Re: About Multi Language installation Link to this post

    Hi atroz,

    The errors from Mysql are important to working out what is wrong. Can you post some of them?

    Cheers
    Owen

  • yurigoul
    Avatar
    Community Member
    202 Posts

    Re: About Multi Language installation Link to this post

    Important question: did you give a yoursite.com/dev/build (where yoursite.com is your web address)

    Here is the code I a using right now for a multilingual website with 4 languages and german as the default language:

    /* Multilingual content */
    /********************/
    //translatable
    Translatable::set_default_locale('de_DE'); // This defines Translatable::current_lang() in Page.php
    // Enable Translatable
    Object::add_extension('SiteTree', 'Translatable');

    // i18n
    i18n::enable();
    // Define allowed locales overriding those present in i18n::$common_locales
    global $allowed_locales;
    $allowed_locales = array(
    'de_DE' => array('German', 'Deutsch'),
    'en_GB' => array('English', 'English'),
    'fr_FR' => array('French', 'Français'),
    'es_ES' => array('Spanish', 'Espanol')
    //
    );
    i18n::$common_locales = $allowed_locales;

  • atroz
    Avatar
    Community Member
    3 Posts

    Re: About Multi Language installation Link to this post

    This is what i get:

    User Error] Couldn't run query: SELECT `SiteTree`.*, `GhostPage`.*, `BlogEntry`.*, `BlogTree`.*, `Calendar`.*, `CalendarEvent`.*, `FlickrGallery`.*, `ErrorPage`.*, `RedirectorPage`.*, `VirtualPage`.*, `BlogHolder`.*, `SiteTree`.ID, if(`SiteTree`.ClassName,`SiteTree`.ClassName,'SiteTree') AS RecordClassName FROM `SiteTree` LEFT JOIN `GhostPage` ON `GhostPage`.ID = `SiteTree`.ID LEFT JOIN `BlogEntry` ON `BlogEntry`.ID = `SiteTree`.ID LEFT JOIN `BlogTree` ON `BlogTree`.ID = `SiteTree`.ID LEFT JOIN `Calendar` ON `Calendar`.ID = `SiteTree`.ID LEFT JOIN `CalendarEvent` ON `CalendarEvent`.ID = `SiteTree`.ID LEFT JOIN `FlickrGallery` ON `FlickrGallery`.ID = `SiteTree`.ID LEFT JOIN `ErrorPage` ON `ErrorPage`.ID = `SiteTree`.ID LEFT JOIN `RedirectorPage` ON `RedirectorPage`.ID = `SiteTree`.ID LEFT JOIN `VirtualPage` ON `VirtualPage`.ID = `SiteTree`.ID LEFT JOIN `BlogHolder` ON `BlogHolder`.ID = `SiteTree`.ID WHERE (HomepageForDomain REGEXP '(, ^) *kaminu\.com *(,|$)') AND (`SiteTree`.`Locale` = 'es_ES') ORDER BY Sort LIMIT 1 | Unknown column 'SiteTree.Locale' in 'where clause'
    GET /silverstripe/?isDev=1
    Line 401 in /home/kaminuco/public_html/silverstripe/sapphire/core/model/MySQLDatabase.php

    Source
    392    }
    393    
    394    function databaseError($msg, $errorLevel = E_USER_ERROR) {
    395       // try to extract and format query
    396       if(preg_match('/Couldn\'t run query: ([^\|]*)\|\s*(.*)/', $msg, $matches)) {
    397          $formatter = new SQLFormatter();
    398          $msg = "Couldn't run query: \n" . $formatter->formatPlain($matches[1]) . "\n\n" . $matches[2];
    399       }
    400       
    401       user_error($msg, $errorLevel);
    402    }
    403 }
    404
    405 /**
    406 * A result-set from a MySQL database.
    407 * @package sapphire
    Trace
    •Couldn't run query: SELECT `SiteTree`.*, `GhostPage`.*, `BlogEntry`.*, `BlogTree`.*, `Calendar`.*, `CalendarEvent`.*, `FlickrGallery`.*, `ErrorPage`.*, `RedirectorPage`.*, `VirtualPage`.*, `BlogHolder`.*, `SiteTree`.ID, if(`SiteTree`.ClassName,`SiteTree`.ClassName,'SiteTree') AS RecordClassName FROM `SiteTree` LEFT JOIN `GhostPage` ON `GhostPage`.ID = `SiteTree`.ID LEFT JOIN `BlogEntry` ON `BlogEntry`.ID = `SiteTree`.ID LEFT JOIN `BlogTree` ON `BlogTree`.ID = `SiteTree`.ID LEFT JOIN `Calendar` ON `Calendar`.ID = `SiteTree`.ID LEFT JOIN `CalendarEvent` ON `CalendarEvent`.ID = `SiteTree`.ID LEFT JOIN `FlickrGallery` ON `FlickrGallery`.ID = `SiteTree`.ID LEFT JOIN `ErrorPage` ON `ErrorPage`.ID = `SiteTree`.ID LEFT JOIN `RedirectorPage` ON `RedirectorPage`.ID = `SiteTree`.ID LEFT JOIN `VirtualPage` ON `VirtualPage`.ID = `SiteTree`.ID LEFT JOIN `BlogHolder` ON `BlogHolder`.ID = `SiteTree`.ID WHERE (HomepageForDomain REGEXP '(, ^) *kaminu\.com *(,|$)') AND (`SiteTree`.`Locale` = 'es_ES') ORDER BY Sort LIMIT 1 | Unknown column 'SiteTree.Locale' in 'where clause'
    Line 401 of MySQLDatabase.php
    •MySQLDatabase->databaseError(Couldn't run query: SELECT `SiteTree`.*, `GhostPage`.*, `BlogEntry`.*, `BlogTree`.*, `Calendar`.*, `CalendarEvent`.*, `FlickrGallery`.*, `ErrorPage`.*, `RedirectorPage`.*, `VirtualPage`.*, `BlogHolder`.*, `SiteTree`.ID, if(`SiteTree`.ClassName,`SiteTree`.ClassName,'SiteTree') AS RecordClassName FROM `SiteTree` LEFT JOIN `GhostPage` ON `GhostPage`.ID = `SiteTree`.ID LEFT JOIN `BlogEntry` ON `BlogEntry`.ID = `SiteTree`.ID LEFT JOIN `BlogTree` ON `BlogTree`.ID = `SiteTree`.ID LEFT JOIN `Calendar` ON `Calendar`.ID = `SiteTree`.ID LEFT JOIN `CalendarEvent` ON `CalendarEvent`.ID = `SiteTree`.ID LEFT JOIN `FlickrGallery` ON `FlickrGallery`.ID = `SiteTree`.ID LEFT JOIN `ErrorPage` ON `ErrorPage`.ID = `SiteTree`.ID LEFT JOIN `RedirectorPage` ON `RedirectorPage`.ID = `SiteTree`.ID LEFT JOIN `VirtualPage` ON `VirtualPage`.ID = `SiteTree`.ID LEFT JOIN `BlogHolder` ON `BlogHolder`.ID = `SiteTree`.ID WHERE (HomepageForDomain REGEXP '(,|^) *kaminu\.com *(,|$)') AND (`SiteTree`.`Locale` = 'es_ES') ORDER BY Sort LIMIT 1 | Unknown column 'SiteTree.Locale' in 'where clause',256)
    Line 102 of MySQLDatabase.php
    •MySQLDatabase->query(SELECT `SiteTree`.*, `GhostPage`.*, `BlogEntry`.*, `BlogTree`.*, `Calendar`.*, `CalendarEvent`.*, `FlickrGallery`.*, `ErrorPage`.*, `RedirectorPage`.*, `VirtualPage`.*, `BlogHolder`.*, `SiteTree`.ID, if(`SiteTree`.ClassName,`SiteTree`.ClassName,'SiteTree') AS RecordClassName FROM `SiteTree` LEFT JOIN `GhostPage` ON `GhostPage`.ID = `SiteTree`.ID LEFT JOIN `BlogEntry` ON `BlogEntry`.ID = `SiteTree`.ID LEFT JOIN `BlogTree` ON `BlogTree`.ID = `SiteTree`.ID LEFT JOIN `Calendar` ON `Calendar`.ID = `SiteTree`.ID LEFT JOIN `CalendarEvent` ON `CalendarEvent`.ID = `SiteTree`.ID LEFT JOIN `FlickrGallery` ON `FlickrGallery`.ID = `SiteTree`.ID LEFT JOIN `ErrorPage` ON `ErrorPage`.ID = `SiteTree`.ID LEFT JOIN `RedirectorPage` ON `RedirectorPage`.ID = `SiteTree`.ID LEFT JOIN `VirtualPage` ON `VirtualPage`.ID = `SiteTree`.ID LEFT JOIN `BlogHolder` ON `BlogHolder`.ID = `SiteTree`.ID WHERE (HomepageForDomain REGEXP '(,|^) *kaminu\.com *(,|$)') AND (`SiteTree`.`Locale` = 'es_ES') ORDER BY Sort LIMIT 1,256)
    Line 120 of DB.php
    •DB::query(SELECT `SiteTree`.*, `GhostPage`.*, `BlogEntry`.*, `BlogTree`.*, `Calendar`.*, `CalendarEvent`.*, `FlickrGallery`.*, `ErrorPage`.*, `RedirectorPage`.*, `VirtualPage`.*, `BlogHolder`.*, `SiteTree`.ID, if(`SiteTree`.ClassName,`SiteTree`.ClassName,'SiteTree') AS RecordClassName FROM `SiteTree` LEFT JOIN `GhostPage` ON `GhostPage`.ID = `SiteTree`.ID LEFT JOIN `BlogEntry` ON `BlogEntry`.ID = `SiteTree`.ID LEFT JOIN `BlogTree` ON `BlogTree`.ID = `SiteTree`.ID LEFT JOIN `Calendar` ON `Calendar`.ID = `SiteTree`.ID LEFT JOIN `CalendarEvent` ON `CalendarEvent`.ID = `SiteTree`.ID LEFT JOIN `FlickrGallery` ON `FlickrGallery`.ID = `SiteTree`.ID LEFT JOIN `ErrorPage` ON `ErrorPage`.ID = `SiteTree`.ID LEFT JOIN `RedirectorPage` ON `RedirectorPage`.ID = `SiteTree`.ID LEFT JOIN `VirtualPage` ON `VirtualPage`.ID = `SiteTree`.ID LEFT JOIN `BlogHolder` ON `BlogHolder`.ID = `SiteTree`.ID WHERE (HomepageForDomain REGEXP '(,|^) *kaminu\.com *(,|$)') AND (`SiteTree`.`Locale` = 'es_ES') ORDER BY Sort LIMIT 1)
    Line 426 of SQLQuery.php
    •SQLQuery->execute()
    Line 2531 of DataObject.php
    •DataObject->instance_get_one(HomepageForDomain REGEXP '(,|^) *kaminu\.com *(,|$)',)
    Line 2468 of DataObject.php
    •DataObject::get_one(SiteTree,HomepageForDomain REGEXP '(,|^) *kaminu\.com *(,|$)')
    Line 64 of RootURLController.php
    •RootURLController::get_homepage_urlsegment()
    Line 41 of RootURLController.php
    •RootURLController->handleRequest(HTTPRequest)
    Line 280 of Director.php
    •Director::handleRequest(HTTPRequest,Session)
    Line 121 of Director.php
    •Director::direct(/)
    Line 118 of main.php

  • profimus
    Avatar
    Community Member
    8 Posts

    Re: About Multi Language installation Link to this post

    Thanks yurigoul,

    I've succeeded to use your code on SS 2.4.1, but now cannot find the right way to display a language chooser in a front end. What can you recommend?

  • yurigoul
    Avatar
    Community Member
    202 Posts

    Re: About Multi Language installation Link to this post

    This is what I use in Page.ss for one site:

       <% if Translations %>
       <ul id="languageMenu" >

    <!-- for all translations except the current one -->
       <% control Translations %>
       <li class="$Locale">
       <a href="$Link" hreflang="$Locale.RFC1766"
       title="$Title">
       $Locale
       </a></li><% end_control %>

    <!-- for the current language, but you can leave it out -->
       <li class="$Locale">
       <a href="$Link" hreflang="$Locale.RFC1766"
       title="$Title">
       $Locale
       </a>
       </li>
       </ul>
       <% end_if %>

    There is no function in my page.php (or is there, it has been a while, I did search for it, and I had a couple of glasses of wine, but have to sleep now and get up early in the morning )

    ####################

    In another:

    page.php:

    function LangMenu() {
          if($this->URLSegment == "Security") return false;
           $availTransl = Translatable::getTranslations();
        if(count($availTransl) == 0) return false;
        if ($this->ClassName == 'SubscriptionPage') return false;

          $langs = Translatable::get_existing_content_languages();
          $data = new DataObjectSet();

          foreach(array_keys($langs) as $code) {
              $page = $this->getTranslation($code);
              if (isset($page)) {
              if (!($code == $this->Locale)) {
    // get country code (e.g. "de")
    $lang = i18n::get_lang_from_locale($code);
    $data->push(new ArrayData(array(
    'Name' => i18n::get_language_name($lang, true),
    'Title' => $page->Title,
    'Link' => Director::baseURL() . $page->URLSegment,
    'Code' => $code
    //'page' => $page
    )));
    }
    }
    }
    return $data;
       }

    In page.ss:

    <% if LangMenu %>
    <ul class="languageMenu" >
       <% control LangMenu %>
       <li class="$Name"><a href="$Link" hreflang="$Code" title="$Name"><span>$Name</span></a></li>
       <% end_control %>
    </ul>
    <% end_if %>

    4189 Views
Page: 1 2
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.