Global Areas for multilingual site

Permalink 1 user found helpful
First post on the forums, I hope you all can help me.

First of all I'm really glad that multilingual support is added to 5.7! Just one question about this. I have a few Global Areas in the footer. The content is in my default language (Dutch), but I would like to translate this content to the secondary language (English). How can this be done?

I found a solution for older C5 versions where a Global Area got generated for every locale. Is there a similar solution for 5.7?

Thanks in advance!

 
goodnightfirefly replied on at Permalink Reply
goodnightfirefly
What was the result when you tried that solution?
Damask replied on at Permalink Reply
I used this code:

<?php
      Loader::model('section', 'multilingual');
      $ms = Multilingual::getCurrentSection();
      if (is_object($ms)) {
          $lang = $ms->getLanguage();
      } else {
          $lang = LANGUAGE;
      }
      if ($lang != 'en'){
          $a = new GlobalArea('Footer ' . ucwords($lang));
      } else {
          $a = new GlobalArea('Footer');
      }
      $a->display();
   ?>


When I add that to my theme I get this error message: Class 'Multilingual' not found
hissy replied on at Permalink Best Answer Reply
hissy
This is the my solution to generate Global Areas for each language section, for 5.7.

Create application/src/Area/GlobalArea.php as below

<?php
namespace Application\Src\Area;
use Concrete\Core\Area\GlobalArea as CoreGlobalArea;
use Concrete\Core\Multilingual\Page\Section\Section as MultilingualSection;
use Localization;
use Punic\Language;
use Punic\Data;
class GlobalArea extends CoreGlobalArea
{
   public function __construct($arHandle)
    {
        $ms = MultilingualSection::getCurrentSection();
        if (is_object($ms)) {
            $locale = $ms->getLocale();
        } else {


Then modify your application/config/app.php

<?php
return array(
    'aliases' => array(
        'GlobalArea' => 'Application\Src\Area\GlobalArea'
    )
);


Hope this is helpful
NickKN replied on at Permalink Reply
Thank you for this - I'll bookmark it for future reference.

I'm not quite clear how I implement in a template though - you still have to configure the content for each language you're using.

I'm beginning to despair of ever understanding 5.7
hissy replied on at Permalink Reply
hissy
Nick, this is the discussion thread about Global Area. You might want to post a new thread about how to use multilingual feature on 5.7...
NickKN replied on at Permalink Reply
You declare a global area in a template - typically in the header, footer or a sidebar.

The code for 5.6 no longer will work and you, very generously make this available. I note that it involves creating an new file which extends / modifies the core programme and another file that points to the new file.

I do not think it is unreasonable to ask what code then goes into a template. I'm not a php developer, I'm lower down the food chain, just trying to design a site or two that work.
hissy replied on at Permalink Reply
hissy
If you want to use 5.6 code, please just do some modification...

change MultilingualSection to \Concrete\Core\Multilingual\Page\Section\Section
change ACTIVE_LOCALE to Localization::activeLocale()

That' all.
NickKN replied on at Permalink Reply
This is brilliant !

Had to do fresh install to get the multilingual function and spent some time looking at the code.
Not sure what you've done but it means templates need no modification.

You should get a medal !
Damask replied on at Permalink Reply
Wow, great! Works like a charm.

Thanks!
a575606 replied on at Permalink Reply
Hi

I have implemented this solution which worked fine in 5.7.4, but now I'm on 5.7.5.1, and I need to undo this solution because Concerete5 has built in support for multilingual stacks. Any ideas how to undo? All my menus and blocks have disappeared in my other language versions.
NickKN replied on at Permalink Reply
Multilingual support is not yet available for 5.7 - it is in development and will be part of 5.73 when that comes out.
So no add-ons !

This is the current 5.6 solution to your problem (using my site's menu as an example and one stack per language)
<?php 
        Loader::model('section', 'multilingual');
        $c = Page::getCurrentPage();
        $al = MultilingualSection::getBySectionOfSite($c);
        $locale = ACTIVE_LOCALE;
        if (is_object($al)) {
          $locale = $al->getLanguage();
        }
        ?>
         <nav id="main-menu" class="">
            <?php
            if($locale == 'en'){
              $a = new GlobalArea('English Main Nav');
              $a->display();
            }


You don't say if you've used 5.6 but basically the idea is that the multilingual addon will be rolled into the 5.7 core.
As things stand any block you use, if there are language dependent variations of content, you have to create a template that enables the block to know where it is - using the "$c = page::... part".
goodnightfirefly replied on at Permalink Reply
goodnightfirefly
Damask replied on at Permalink Reply
As goodnightfirefly said, 5.7.3 is out (yay!), so i should be possible. Is did try your code, but sadly id didn't work. I got the following error: Class 'MultilingualSection' not found
NickKN replied on at Permalink Reply
I didn't realise it was out !

I suppose we'll have to wait for the experts to tell us what to do...
My theme is littered with that sort of call...

Just been looking at the api (not that I understand much)
http://concrete5.org/api/class-Concrete.Core.Localization.Localizat...

could the answer be here ?
NickKN replied on at Permalink Reply
I've just updated to 5.7.3...

Can't find any internationalisation though !?

Do I have to do something to enable it ?
Damask replied on at Permalink Reply
You can find it under 'System & Settings > Multilingual'
NickKN replied on at Permalink Reply
That's the problem
I don't have a multilingual section in my dashboard.
andrew replied on at Permalink Reply
andrew
FYI: in 5.7.4 we will add support for multilingual stacks, which should make hacks to enable multilingual global areas unnecessary. (Although they will totally work right now.)
NickKN replied on at Permalink Reply
That's great!
Life gets better and better !
Cahueya replied on at Permalink Reply
You guys are incredibly great :)
hissy replied on at Permalink Reply
hissy
Great news!
pedroserapio replied on at Permalink Reply
pedroserapio
This functionality will be very welcome to work together with a Global Area. Will reduce a lot of work.
ketaz replied on at Permalink Reply
ketaz
That's great news, thanks, this will save a lot of hassle! Is 5.7.4 coming up anytime soon?

In the meantime, could you point me on how do I detect current/active locale in the code in 5.7.3? Something equivalent to 5.6's:
$lh = Loader::helper('section', 'multilingual');
print $lh->getLanguage();
pedroserapio replied on at Permalink Reply
pedroserapio
Try have a look to:

..concrete/blocks/switch_language/....

But this maybe can be a starting point:

<?php
  $lh = Loader::helper('section', 'multilingual');
  echo $lh->getLanguage();
?>
ketaz replied on at Permalink Reply
ketaz
Nope Pedro, that was exactly my point - this helper wouldnt work in 5.7.x

However you pointed me in the right direction, looking into language switcher block revealed the correct solution:
$locale = \Localization::activeLocale();


Thanks a lot for the right pointer ;-)
pedroserapio replied on at Permalink Reply
pedroserapio
Ahah, sorry, only now I saw that part of my answer it's the same of your question.
a575606 replied on at Permalink Reply
Hi, I just loaded 5.7.4 RC1 on a test site to play around with it, but didn't see any way to use multi lingual stacks. Did that feature get skipped?
andrew replied on at Permalink Reply
andrew
This feature was never 100% confirmed for 5.7.4. We would like to include it as soon as we can but it will take development resources that are currently tied up. It's been bumped to further out.