Last active
December 31, 2015 02:09
-
-
Save darklow/7919307 to your computer and use it in GitHub Desktop.
Koken translation tag. <koken:trans en="Hello" fr="Bonjour" lv="Sveiki" />
This file contains hidden or 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 | |
class TagTrans extends Tag { | |
function generate() | |
{ | |
$value = '""'; | |
$lng = isset($_COOKIE['lang']) ? $_COOKIE['lang'] : 'en'; | |
if(isset($this->parameters[$lng])){ | |
$value = '"' . $this->attr_parse($this->parameters[$lng]) . '"'; | |
} | |
return <<<DOC | |
<?php echo $value; ?> | |
DOC; | |
} | |
} | |
/* Usage: | |
------------ | |
1. Copy this file to ./app/site/tags/ directory. | |
2. Add your own HTML/JS language switcher to templates and ensure $_COOKIE['lang'] is set with wanted language ('en', 'fr', ...) | |
3. In templates use <koken:trans en="Hello" fr="Bonjour" lv="Sveiki" /> | |
Now correct translation will be displayed. | |
Enjoy! | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment