A Quick Way to Change Content Based on Selected Language in OpenCart

Here’s the quick php code to deliver different content based on site’s language currently selected in Open Cart Shop template.

Insert different content to a different language version:

<?php $lang = $this->config->get('config_language');
if($lang == 'ru'){
    $locale = 'ru_RU';
} elseif($lang == 'en'){
    $locale = 'en_US';
} ?>

And show the result:

<?php if ($locale) { echo $locale; } ?>

This particular piece was used to switch Facebook like box language to Russian in Russian site version of Opencart. But suitable to change anything.

This entry was posted in Templates and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *