Created
November 29, 2011 11:56
-
-
Save kepek/1404560 to your computer and use it in GitHub Desktop.
Magento Multilanguage Category Description (Fast Workaround)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Vritual Helper Function */ | |
public function translate($text = false, $lang = false) { | |
$lang = $lang ? $lang : Mage::app()->getLocale()->getLocaleCode(); | |
if($text) { | |
preg_match('#\[translate lang="'.$lang.'"\](.*?)\[/translate\]#si', $text, $match); | |
if($match) { | |
$output = trim($match[1]); | |
} | |
else { | |
$output = $text; | |
} | |
} | |
else { | |
$output = false; | |
} | |
return $output; | |
} | |
?> | |
<?php | |
/* Sample Category Description */ | |
$text = '[translate lang="en_GB"]Lorem Ipsum EN[/translate][translate lang="de_DE"]Lorem Ipsum DE[/translate]'; | |
?> | |
<?php | |
/* How to Use it? */ | |
echo Mage::helper('virtual')->translate($text, 'en_US'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment