Skip to content

Instantly share code, notes, and snippets.

@mingtsay
Created April 30, 2011 14:36
Show Gist options
  • Save mingtsay/949718 to your computer and use it in GitHub Desktop.
Save mingtsay/949718 to your computer and use it in GitHub Desktop.
mt's gettext
<?php
/**
* Define: FILE_ROOT_PATH
* Set Value: $lang
* Create an ini file: i18n/lang.ini
* Call function: _gettext("Homepage") or someelse string
**/
function _gettext($text) {
global $lang;
$langs = parse_ini_file(FILE_ROOT_PATH . "i18n/lang.ini", true);
return ((isset($langs[$lang][$text]))? ($langs[$lang][$text]): ((isset($langs['en'][$text]))? ($langs['en'][$text]): ($text)));
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment