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!
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!
What was the result when you tried that solution?
I used this code:
When I add that to my theme I get this error message: Class 'Multilingual' not found
When I add that to my theme I get this error message: Class 'Multilingual' not found
This is the my solution to generate Global Areas for each language section, for 5.7.
Create application/src/Area/GlobalArea.php as below
Then modify your application/config/app.php
Hope this is helpful
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 {
Viewing 15 lines of 25 lines. View entire code block.
Then modify your application/config/app.php
Hope this is helpful
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
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
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...
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.
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.
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.
change MultilingualSection to \Concrete\Core\Multilingual\Page\Section\Section
change ACTIVE_LOCALE to Localization::activeLocale()
That' all.
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 !
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 !
Wow, great! Works like a charm.
Thanks!
Thanks!
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.
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.
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)
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".
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(); }
Viewing 15 lines of 21 lines. View entire code block.
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".
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
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 ?
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 ?
I've just updated to 5.7.3...
Can't find any internationalisation though !?
Do I have to do something to enable it ?
Can't find any internationalisation though !?
Do I have to do something to enable it ?
You can find it under 'System & Settings > Multilingual'
That's the problem
I don't have a multilingual section in my dashboard.
I don't have a multilingual section in my dashboard.
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.)
That's great!
Life gets better and better !
Life gets better and better !
You guys are incredibly great :)
Great news!
This functionality will be very welcome to work together with a Global Area. Will reduce a lot of work.
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:
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();
Try have a look to:
..concrete/blocks/switch_language/....
But this maybe can be a starting point:
..concrete/blocks/switch_language/....
But this maybe can be a starting point:
<?php $lh = Loader::helper('section', 'multilingual'); echo $lh->getLanguage(); ?>
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:
Thanks a lot for the right pointer ;-)
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 ;-)
Ahah, sorry, only now I saw that part of my answer it's the same of your question.
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?
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.