本文整理汇总了PHP中_bindtextdomain函数的典型用法代码示例。如果您正苦于以下问题:PHP _bindtextdomain函数的具体用法?PHP _bindtextdomain怎么用?PHP _bindtextdomain使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_bindtextdomain函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: startup_gettext
function startup_gettext()
{
# Get locale from Accept-Language header
$lang = al2gt(array_keys(get_translations()), "text/html");
if (defined('_TRANSLATION_OVERRIDE_DEFAULT')) {
$lang = _TRANSLATION_OVERRIDE_DEFAULT;
}
if ($_SESSION["uid"] && get_schema_version() >= 120) {
$pref_lang = get_pref("USER_LANGUAGE", $_SESSION["uid"]);
if ($pref_lang && $pref_lang != 'auto') {
$lang = $pref_lang;
}
}
if ($lang) {
if (defined('LC_MESSAGES')) {
_setlocale(LC_MESSAGES, $lang);
} else {
if (defined('LC_ALL')) {
_setlocale(LC_ALL, $lang);
}
}
_bindtextdomain("messages", "locale");
_textdomain("messages");
_bind_textdomain_codeset("messages", "UTF-8");
}
}
示例2: startup_gettext
function startup_gettext()
{
# Get locale from Accept-Language header
$lang = al2gt(array_keys(get_translations()), "text/html");
if (defined('_TRANSLATION_OVERRIDE_DEFAULT')) {
$lang = _TRANSLATION_OVERRIDE_DEFAULT;
}
/* In login action of mobile version */
if ($_POST["language"] && defined('MOBILE_VERSION')) {
$lang = $_POST["language"];
} else {
if ($_SESSION["language"] && $_SESSION["language"] != "auto") {
$lang = $_SESSION["language"];
}
}
if ($lang) {
if (defined('LC_MESSAGES')) {
_setlocale(LC_MESSAGES, $lang);
} else {
if (defined('LC_ALL')) {
_setlocale(LC_ALL, $lang);
}
}
if (defined('MOBILE_VERSION')) {
_bindtextdomain("messages", "../locale");
} else {
_bindtextdomain("messages", "locale");
}
_textdomain("messages");
_bind_textdomain_codeset("messages", "UTF-8");
}
}
示例3: bindTextDomain
/**
* bind text domain.
*
* @param string $domain text domain
* @param string $directory directory where the translation file is. the directory must have trailing slash.
* @param string $language_locale_uri language to check translation file exists.
*/
public function bindTextDomain($domain, $directory, $language_locale_uri)
{
if (is_file($directory . $language_locale_uri . DS . 'LC_MESSAGES' . DS . $domain . '.mo') && function_exists('_bindtextdomain') && function_exists('_bind_textdomain_codeset')) {
_bindtextdomain($domain, $directory);
_bind_textdomain_codeset($domain, $this->encoding);
}
}
示例4: setUp
public function setUp()
{
MoTranslator\Loader::loadFunctions();
_setlocale(0, 'cs');
_textdomain('phpmyadmin');
_bindtextdomain('phpmyadmin', __DIR__ . '/data/locale/');
_bind_textdomain_codeset('phpmyadmin', 'UTF-8');
}
示例5: changeLocale
function changeLocale($newlocale)
{
global $CURRENTLOCALE, $EMULATEGETTEXT, $text_domains;
$CURRENTLOCALE = $newlocale;
$EMULATEGETTEXT = 1;
_textdomain('kusaba');
_setlocale(LC_ALL, $newlocale);
_bindtextdomain('kusaba', KU_ROOTDIR . 'inc/lang', $newlocale);
_bind_textdomain_codeset('kusaba', KU_CHARSET);
}
示例6: init_locale
function init_locale($locale, $error = 'error')
{
if (_setlocale(LC_ALL, $locale) === false) {
$error('The specified locale (' . $locale . ') does not exist on your platform!');
}
if (extension_loaded('gettext')) {
bindtextdomain('tinyboard', './inc/locale');
bind_textdomain_codeset('tinyboard', 'UTF-8');
textdomain('tinyboard');
} else {
_bindtextdomain('tinyboard', './inc/locale');
_bind_textdomain_codeset('tinyboard', 'UTF-8');
_textdomain('tinyboard');
}
}
示例7: init_locale
function init_locale($locale, $error = 'error')
{
if ($locale === 'en') {
$locale = 'en_US.utf8';
}
if (extension_loaded('gettext')) {
setlocale(LC_ALL, $locale);
bindtextdomain('tinyboard', './inc/locale');
bind_textdomain_codeset('tinyboard', 'UTF-8');
textdomain('tinyboard');
} else {
_setlocale(LC_ALL, $locale);
_bindtextdomain('tinyboard', './inc/locale');
_bind_textdomain_codeset('tinyboard', 'UTF-8');
_textdomain('tinyboard');
}
}
示例8: smarty_block_t
/**
* Smarty block function, provides gettext support for smarty.
*
* The block content is the text that should be translated.
*
* Any parameter that is sent to the function will be represented as %n in the translation text,
* where n is 1 for the first parameter. The following parameters are reserved:
* - escape - sets escape mode:
* - 'html' for HTML escaping, this is the default.
* - 'js' for javascript escaping.
* - 'url' for url escaping.
* - 'no'/'off'/0 - turns off escaping
* - plural - The plural version of the text (2nd parameter of ngettext())
* - count - The item count for plural mode (3rd parameter of ngettext())
*/
function smarty_block_t($params, $text, &$smarty)
{
//ADDING PHP-GETTEXT SUPPORT
//error_reporting(E_ALL | E_STRICT); //for debugging
$settings = setupPhpGettext();
extract($settings);
/*
if(!defined('PROJECT_DIR')) define('PROJECT_DIR', $project_dir);
if(!defined('LOCALE_DIR')) define('LOCALE_DIR', $locale_dir);
if(!defined('DEFAULT_LOCALE')) define('DEFAULT_LOCALE', $default_locale);
*/
// gettext setup
T_setlocale(LC_MESSAGES, $locale);
// Set the text domain as 'messages'
$domain = 'messages';
_bindtextdomain($domain, LOCALE_DIR);
// bind_textdomain_codeset is supported only in PHP 4.2.0+
if (function_exists('bind_textdomain_codeset')) {
_bind_textdomain_codeset($domain, $encoding);
}
_textdomain($domain);
// end PHP-GETTEXT SUPPORT
$text = stripslashes($text);
// set escape mode
if (isset($params['escape'])) {
$escape = $params['escape'];
unset($params['escape']);
}
// set plural version
if (isset($params['plural'])) {
$plural = $params['plural'];
unset($params['plural']);
// set count
if (isset($params['count'])) {
$count = $params['count'];
unset($params['count']);
}
}
// use plural if required parameters are set
if (isset($count) && isset($plural)) {
$text = _ngettext($text, $plural, $count);
} else {
// use normal
$text = _gettext($text);
}
// run strarg if there are parameters
if (count($params)) {
$text = smarty_gettext_strarg($text, $params);
}
if (!isset($escape) || $escape == 'html') {
// html escape, default
$text = nl2br(htmlspecialchars($text));
} elseif (isset($escape)) {
switch ($escape) {
case 'javascript':
case 'js':
// javascript escape
$text = str_replace('\'', '\\\'', stripslashes($text));
break;
case 'url':
// url escape
$text = urlencode($text);
break;
}
}
return $text;
}
示例9: bindtextdomain
function bindtextdomain($domain, $path)
{
return _bindtextdomain($domain, $path);
}
示例10: T_setlocale
* 2. Supply an array that lists all available translations (main
* purpose is to use it for creating html selects to change language)
*
* TODO: Maybe change $available_languages to just list the native
* language name (well, useres should be able to find their own
* language, shouldn't they?) :)
* NOTE: The gettext library might be used, if it is available.
* The problem is that mo files are cached by the extension, so a
* server restart is necessary if these files are updated (e.g. by
* a senayan update). I replaced all _('') with __(''), so
* php-gettext is always used, thus circumventing this problem.
* Obviously there is no real speed disadvantage, since this is the
* way wordpress does it.
* Developers should use __('') and _ngettext in code!
*/
// gettext setup
$locale = $sysconf['default_lang'];
$domain = 'messages';
$encoding = 'UTF-8';
// set language to use
T_setlocale(LC_ALL, $locale);
// set locales dictionary location
_bindtextdomain($domain, INC_DIR . 'locale');
// codeset
_bind_textdomain_codeset($domain, $encoding);
// set .mo filename to use
_textdomain($domain);
// Array with available translations
// $available_languages[] = array('CODE', __('ENGLISH NAME'), 'NATIVE NAME');
$available_languages[] = array('en_US', __('English'), 'English');
$available_languages[] = array('id_ID', __('Indonesian'), 'Indonesia');
示例11: _bindtextdomain
<?php
include_once 'application/lib/gettext/gettext.inc.php';
_bindtextdomain();
class kxTemplate
{
private static $template_dir;
private static $debug_flag = false;
private static $data = array();
private static $instance = null;
// Manage wrapper
private static $manage;
// Manage sidebar menu extras
public static $menu_extra = '';
private function __construct()
{
}
public static function init($template_dir = null, $compiled_dir = null, $cache_dir = null)
{
if (self::$instance == null) {
//echo "<p>init() called!</p>";
if ($template_dir != null) {
self::$template_dir = $template_dir;
} else {
self::$template_dir = KX_ROOT . kxEnv::get("kx:templates:dir");
}
$loader = new Twig_Loader_Filesystem(self::$template_dir);
if ($cache_dir == null) {
$cache_dir = KX_ROOT . kxEnv::get("kx:templates:cachedir");
}
self::$instance = new Twig_Environment($loader, array('cache' => $cache_dir, 'auto_reload' => true, 'debug' => true));
示例12: define
* Developers should use __('') and _ngettext in code!
*/
// key to authenticate
if (!defined('INDEX_AUTH')) {
define('INDEX_AUTH', '1');
}
// set php-gettext library
require LANG . 'php-gettext' . DS . 'gettext.inc';
// gettext setup
$locale = $sysconf['default_lang'];
$domain = 'messages';
$encoding = 'UTF-8';
// set language to use
T_setlocale(LC_ALL, $locale);
// set locales dictionary location
_bindtextdomain($domain, LANG . 'locale');
// codeset
_bind_textdomain_codeset($domain, $encoding);
// set .mo filename to use
_textdomain($domain);
// Array with available translations
// $available_languages[] = array('CODE', __('ENGLISH NAME'), 'NATIVE NAME');
$available_languages[] = array('ar_AR', __('Arabic'), 'Arabic');
$available_languages[] = array('bn_BD', __('Bengali'), 'Bengali');
$available_languages[] = array('pt_BR', __('Brazilian Portuguese'), 'Brazilian Portuguese');
$available_languages[] = array('cn_PRC', __('Chinese'), 'Chinese');
$available_languages[] = array('kr_KR', __('Korean'), 'Korean');
$available_languages[] = array('en_US', __('English'), 'English');
$available_languages[] = array('es_ES', __('Espanol'), 'Espanol');
$available_languages[] = array('de_DE', __('German'), 'Deutsch');
$available_languages[] = array('id_ID', __('Indonesian'), 'Indonesia');
示例13: dirname
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
include_once dirname(__FILE__) . '/php-gettext/gettext.inc';
include_once dirname(__FILE__) . '/iso-set.php';
if (!defined('SESSION_DISABLE')) {
LoadObjectDependency('net.php.pear.HTTP_Session2');
$lang = HTTP_Session2::get('language', DEFAULT_LANGUAGE);
} else {
$lang = DEFAULT_LANGUAGE;
}
$locale_dir = dirname(dirname(__FILE__)) . '/locale';
$__domains = array('freemed', UI);
_setlocale(LC_MESSAGES, $lang);
$GLOBALS['ISOSET'] = language2isoset($lang);
foreach ($__domains as $_v) {
_bindtextdomain($_v, $locale_dir);
_bind_textdomain_codeset($_v, language2isoset($lang));
_textdomain($_v);
}
function get_translation_matrix($domain)
{
global $default_domain;
$default_domain = $domain;
$l10n = _get_reader();
return $l10n->cache_translations;
}
// end method get_translation_matrix
示例14: ev_ngettext
}
}
function ev_ngettext($string, $plural, $number)
{
return ngettext($string, $plural, $number);
}
function _bind_textdomain_codeset($domain, $codeset)
{
return bind_textdomain_codeset($domain, $codeset);
}
function _bindtextdomain($domain, $path)
{
return bindtextdomain($domain, $path);
}
function _textdomain($domain)
{
return textdomain($domain);
}
function _gettext($msgid)
{
return gettext($msgid);
}
function _setlocale($category, $locale)
{
return setlocale($category, $locale);
}
}
// this won't change over the request. so set it once and permanently
_bindtextdomain('eventum', APP_PATH . '/localization/');
_bind_textdomain_codeset('eventum', APP_CHARSET);
_textdomain('eventum');
示例15: dirname
<?php
require_once 'config.php';
$locale = LANG;
$textdomain = "multi_lang";
$locales_dir = dirname(__FILE__) . '/lang';
if (isset($_GET['lang']) && !empty($_GET['lang'])) {
$locale = $_GET['lang'];
}
putenv('LANGUAGE=' . $locale);
putenv('LANG=' . $locale);
putenv('LC_ALL=' . $locale);
putenv('LC_MESSAGES=' . $locale);
require_once 'lib/gettext.inc';
_setlocale(LC_ALL, $locale);
_setlocale(LC_CTYPE, $locale);
_bindtextdomain($textdomain, $locales_dir);
_bind_textdomain_codeset($textdomain, 'UTF-8');
_textdomain($textdomain);
/*
* This function is an helper that should be
* used to avoid some repetitions. Use "_e"
* instead of "echo __".
*/
function _e($string)
{
echo __($string);
}