Reputation: 349
I'm using Opencart v2.3.0.2. Need help in how to translate some text strings. I've added some links to my header menu (in /catalog/view/theme/mytheme/template/common/header.tpl) using code :
<ul class="static_links">
<li class="head-links">
<a href="<?php echo $about_products; ?>">
<?php echo $text_products; ?>
</a>
</li>
<li class="head-links">
<a href="<?php echo $contact; ?>">
<?php echo $text_novosti; ?>
</a>
</li>
<li class="head-links">
<a href="<?php echo $contact; ?>">
<?php echo $text_onas; ?>
</a>
</li>
</ul>
Also I've added new strings and translations in footer.php (/catalog/language/ru-ru/common/footer.php):
$_['text_products'] = 'О продуктах'; $_['$text_novosti'] = 'Новости'; $_['$text_onas'] = 'О нас';
Finally I've registered that translations in header.php (/catalog/controller/common/header.php):
//New links in menu
$data['text_products'] = $this->language->get('text_products');
$data['text_novosti'] = $this->language->get('text_novosti');
$data['text_onas'] = $this->language->get('text_onas');
After all when I open page with menu it shows only translation texts for $text_products
. In other places it shows only value text_novosti
and text_onas
. But in should show translations from footer.php instead.
Please help me, how to display translations correctly?
Or maybe there is a way to hardcode texts based on language? Something like:
<?php if ($lang='en') {?> <a href="#">News</a><a href="#">About us</a>
<?php } ?>
НовостиО нас
Upvotes: 0
Views: 5369
Reputation: 3000
If you want to use your strings in header.tpl, then you must add your strings to:
catalog/language/ru-ru/common/header.php
not to:
catalog/language/ru-ru/common/footer.php
If you want to hardcode, in header.php
add:
$data['lang_id'] = $this->config->get('config_language_id');
And in header.tpl
:
<?php if ($lang_id == 1) {?>
<a href="#">News</a>
<a href="#">About us</a>
<?php } else if ($lang_id == 2) {?>
<a href="#">Новости</a>
<a href="#">О нас</a>
<?php } ?>
Upvotes: 1