Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
i18n component language conditions
#1
Hi guys,

I need help with i18n and components. I want to change some text directly in the components with conditions. I searched the official manual and found the following:

<?php if ($language == 'en') { ?>English text<?php } ?>
<?php if ($language == 'de') { ?>Deutscher Text<?php } ?>
<?php if ($language == 'es') { ?>...<?php } ?>

But it only works directly in the template. Doesn`t work in components. How do I need to change it?

thanx
Reply
#2
(2013-07-05, 17:16:19)itsmeee Wrote: Hi guys,

I need help with i18n and components. I want to change some text directly in the components with conditions. I searched the official manual and found the following:

<?php if ($language == 'en') { ?>English text<?php } ?>
<?php if ($language == 'de') { ?>Deutscher Text<?php } ?>
<?php if ($language == 'es') { ?>...<?php } ?>

But it only works directly in the template. Doesn`t work in components. How do I need to change it?

thanx

If you add
Code:
<?php global $language; ?>
at the beginning, it should work in the component, too.

But you can also use multiple components suffixed with the language.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#3
Tried to add globals but it didn`t work for me.

Found a solution:
<?php $language = $_GET["lang"] ?>

This should do it. Thanks for your help.
Reply
#4
components run anonymously, you must declare globals in scope.

so
Code:
GLOBAL $language,$blargh;

Maybe $language is wrong or not defined yet.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#5
but in this case, why do you need to switch between components this way, when it's perfectly working with suffixes ?
Reply
#6
This methods you mentioned above doesn't work neither on template files nor on components.
Reply




Users browsing this thread: 1 Guest(s)