本文整理汇总了PHP中_textdomain函数的典型用法代码示例。如果您正苦于以下问题:PHP _textdomain函数的具体用法?PHP _textdomain怎么用?PHP _textdomain使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_textdomain函数的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: setUp
public function setUp()
{
MoTranslator\Loader::loadFunctions();
_setlocale(0, 'cs');
_textdomain('phpmyadmin');
_bindtextdomain('phpmyadmin', __DIR__ . '/data/locale/');
_bind_textdomain_codeset('phpmyadmin', 'UTF-8');
}
示例4: 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);
}
示例5: testGettext
/**
* Test for setting and parsing locales
*
* @param string $locale locale name
*
* @return void
*
* @group large
* @dataProvider listLocales
*/
public function testGettext($locale)
{
/* We should be able to set the language */
$this->assertTrue(PMA_langSet($locale));
/* Bind locales */
_setlocale(LC_MESSAGES, $GLOBALS['lang']);
_bind_textdomain_codeset('phpmyadmin', 'UTF-8');
_textdomain('phpmyadmin');
/* Grab some texts */
$this->assertContains('%s', _ngettext('%s table', '%s tables', 10));
$this->assertContains('%s', _ngettext('%s table', '%s tables', 1));
}
示例6: _t
/**
* get text translation.
*
* @param string $text text message.
* @param string $domain text domain.
* @return string return translated text.
*/
function _t($text, $domain = 'messages')
{
if ($domain == null) {
$domain = 'messages';
}
if (function_exists('_textdomain')) {
_textdomain($domain);
}
if (function_exists('_gettext')) {
return _gettext($text);
} else {
\System\Libraries\Log::write('language', 'warning', 'Unable to find _gettext function. Please check php-gettext component.');
return $text;
}
}
示例7: 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');
}
}
示例8: 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');
}
}
示例9: file_exists
}
require PHPDISK_ROOT . 'includes/phpdisk_version.inc.php';
$C['gz']['open'] = $settings['gzipcompress'];
phpdisk_core::gzcompress_open();
$db = phpdisk_core::init_db_connect();
$setting_file = PHPDISK_ROOT . 'system/settings.inc.php';
file_exists($setting_file) ? require_once $setting_file : settings_cache();
$arr = phpdisk_core::init_lang_tpl();
$user_tpl_dir = 'templates/default/';
$admin_tpl_dir = $arr['admin_tpl_dir'];
$C['lang_type'] = $arr['lang_name'];
require PHPDISK_ROOT . 'includes/lib/php-gettext/gettext.inc.php';
_setlocale(LC_MESSAGES, $C['lang_type']);
_bindtextdomain('phpdisk', 'languages');
_bind_textdomain_codeset('phpdisk', $charset);
_textdomain('phpdisk');
if (!@get_magic_quotes_gpc()) {
$_GET = addslashes_array($_GET);
$_POST = addslashes_array($_POST);
$_COOKIE = addslashes_array($_COOKIE);
}
$group_settings_file = PHPDISK_ROOT . 'system/global/group_settings.inc.php';
file_exists($group_settings_file) ? require_once $group_settings_file : group_settings_cache();
list($pd_uid, $pd_gid, $pd_username, $pd_pwd, $pd_email) = gpc('phpdisk_zcore_info', 'C', '') ? explode("\t", pd_encode(gpc('phpdisk_zcore_info', 'C', ''), 'DECODE')) : array('', '', '', '', '');
$pd_uid = (int) $pd_uid;
if (!$pd_uid || !$pd_pwd) {
$pd_uid = 0;
} else {
$userinfo = $db->fetch_one_array("select userid,u.gid,username,password,email,group_name from {$tpf}users u,{$tpf}groups g where username='{$pd_username}' and password='{$pd_pwd}' and u.gid=g.gid limit 1");
if ($userinfo) {
$pd_username = $userinfo['username'];
示例10: 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
示例11: 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;
}
示例12: 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);
}
示例13: while
while (list($key, $value) = each($cf)) {
define($key, $value);
}
unset($cf);
}
// DO NOT MODIFY BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING OR ELSE BAD THINGS MAY HAPPEN
$modules_loaded = array();
$required = array(KU_ROOTDIR, KU_WEBFOLDER, KU_WEBPATH);
if (in_array('CHANGEME', $required) || in_array('', $required)) {
echo 'You must set KU_ROOTDIR, KU_WEBFOLDER, and KU_WEBPATH before installation will finish!';
die;
}
require KU_ROOTDIR . 'lib/gettext/gettext.inc.php';
require KU_ROOTDIR . 'lib/adodb/adodb.inc.php';
// Gettext
_textdomain('kusaba');
_setlocale(LC_ALL, KU_LOCALE);
_bindtextdomain('kusaba', KU_ROOTDIR . 'inc/lang');
_bind_textdomain_codeset('kusaba', KU_CHARSET);
// SQL database
if (!isset($tc_db) && !isset($preconfig_db_unnecessary)) {
$tc_db =& NewADOConnection(KU_DBTYPE);
if (KU_DBUSEPERSISTENT) {
$tc_db->PConnect(KU_DBHOST, KU_DBUSERNAME, KU_DBPASSWORD, KU_DBDATABASE) or die('SQL database connection error: ' . $tc_db->ErrorMsg());
mysql_query('SET NAMES utf8');
} else {
$tc_db->Connect(KU_DBHOST, KU_DBUSERNAME, KU_DBPASSWORD, KU_DBDATABASE) or die('SQL database connection error: ' . $tc_db->ErrorMsg());
mysql_query('SET NAMES utf8');
}
// SQL debug
if (KU_DEBUG) {
示例14: activate
/**
* Activates given translation
*
* @return bool
*/
public function activate()
{
$GLOBALS['lang'] = $this->code;
// Set locale
_setlocale(LC_MESSAGES, $this->code);
_bindtextdomain('phpmyadmin', LOCALE_PATH);
_bind_textdomain_codeset('phpmyadmin', 'UTF-8');
_textdomain('phpmyadmin');
/* Text direction for language */
if ($this->isRTL()) {
$GLOBALS['text_dir'] = 'rtl';
} else {
$GLOBALS['text_dir'] = 'ltr';
}
/* TCPDF */
$GLOBALS['l'] = array();
/* TCPDF settings */
$GLOBALS['l']['a_meta_charset'] = 'UTF-8';
$GLOBALS['l']['a_meta_dir'] = $GLOBALS['text_dir'];
$GLOBALS['l']['a_meta_language'] = $this->code;
/* TCPDF translations */
$GLOBALS['l']['w_page'] = __('Page number:');
/* Show possible warnings from langauge selection */
LanguageManager::getInstance()->showWarnings();
}
示例15: 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');