当前位置: 首页>>代码示例>>PHP>>正文


PHP Translator::getInstance方法代码示例

本文整理汇总了PHP中Translator::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Translator::getInstance方法的具体用法?PHP Translator::getInstance怎么用?PHP Translator::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Translator的用法示例。


在下文中一共展示了Translator::getInstance方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sgGallery

 /**
  * Constructor
  * @param string     gallery id
  * @param sgGallery  reference to the parent gallery
  */
 function sgGallery($id, &$parent)
 {
     $this->id = $id;
     $this->parent = $parent;
     $this->config = sgConfig::getInstance();
     $this->translator = Translator::getInstance();
 }
开发者ID:kyroskoh,项目名称:singapore-1,代码行数:12,代码来源:gallery.class.php

示例2: __construct

 public function __construct()
 {
     $this->_view = View::getInstance();
     $this->_request = Request::getInstance();
     $this->_validator = Validator::getInstance();
     $this->_translator = Translator::getInstance();
 }
开发者ID:gerq,项目名称:gpstuner,代码行数:7,代码来源:BaseForm.php

示例3: __callStatic

 public static function __callStatic($name, $arguments)
 {
     $translator = Translator::getInstance();
     $callback = array();
     if (in_array($name, array('addCatalog', 'setCacheDir'))) {
         $callback = array($translator, $name);
     }
     if (!is_callable($callback)) {
         throw new UnexistentMethodException('core.message_undefined_method', __CLASS__, $name);
     }
     return call_user_func_array($callback, $arguments);
 }
开发者ID:dayax,项目名称:dayax,代码行数:12,代码来源:Message.php

示例4: sgGallery

 /**
  * Fetches gallery info for the specified gallery and immediate children.
  * @param string  gallery id
  * @param string  language code spec for this request (optional)
  * @param int     number of levels of child galleries to fetch (optional)
  * @return sgGallery  the gallery object created
  */
 function &getGallery($galleryId, &$parent, $getChildGalleries = 1, $language = null)
 {
     $gal = new sgGallery($galleryId, $parent);
     if ($language == null) {
         $translator = Translator::getInstance();
         $language = $translator->language;
     }
     //try to open language specific metadata
     $fp = @fopen($this->config->base_path . $this->config->pathto_galleries . $galleryId . "/metadata.{$language}.csv", "r");
     //if fail then try to open generic metadata
     if (!$fp) {
         $fp = @fopen($this->config->base_path . $this->config->pathto_galleries . $galleryId . "/metadata.csv", "r");
     }
     if ($fp) {
         while ($temp[] = fgetcsv($fp, 2048)) {
         }
         fclose($fp);
         list($gal->filename, $gal->thumbnail, $gal->owner, $gal->groups, $gal->permissions, $gal->categories, $gal->name, $gal->artist, $gal->email, $gal->copyright, $gal->desc, $gal->summary, $gal->date) = $temp[1];
         //only fetch individual images if child galleries are required
         if ($getChildGalleries) {
             for ($i = 0; $i < count($temp) - 3; $i++) {
                 $gal->images[$i] = new sgImage($temp[$i + 2][0], $gal, $this->config);
                 list(, $gal->images[$i]->thumbnail, $gal->images[$i]->owner, $gal->images[$i]->groups, $gal->images[$i]->permissions, $gal->images[$i]->categories, $gal->images[$i]->name, $gal->images[$i]->artist, $gal->images[$i]->email, $gal->images[$i]->copyright, $gal->images[$i]->desc, $gal->images[$i]->location, $gal->images[$i]->date, $gal->images[$i]->camera, $gal->images[$i]->lens, $gal->images[$i]->film, $gal->images[$i]->darkroom, $gal->images[$i]->digital) = $temp[$i + 2];
                 //get image size and type
                 list($gal->images[$i]->width, $gal->images[$i]->height, $gal->images[$i]->type) = @GetImageSize($gal->images[$i]->realPath());
             }
             //otherwise just fill in empty images
         } else {
             if (count($temp) > 3) {
                 for ($i = 0; $i < count($temp) - 3; $i++) {
                     $gal->images[$i] = new sgImage($temp[$i + 2][0], $gal);
                 }
             }
         }
     } else {
         //no metadata found so use iifn method implemented in superclass
         return parent::getGallery($galleryId, $parent, $getChildGalleries, $language);
     }
     //discover child galleries
     $dir = Singapore::getListing($this->config->base_path . $this->config->pathto_galleries . $galleryId . "/");
     if ($getChildGalleries) {
         //but only fetch their info if required too
         foreach ($dir->dirs as $gallery) {
             $gal->galleries[] = $this->getGallery($galleryId . "/" . $gallery, $gal, $getChildGalleries - 1, $language);
         }
     } else {
         //otherwise just copy their names in so they can be counted
         $gal->galleries = $dir->dirs;
     }
     return $gal;
 }
开发者ID:kyroskoh,项目名称:singapore-1,代码行数:58,代码来源:io_csv.class.php

示例5: __construct

 /**
  * 
  */
 public function __construct(Gw2Account $account = null)
 {
     $trans = Translator::getInstance();
     // GENERAL
     $menu = Menu::create($trans['menu.general']);
     $menu->addItem('account', $trans['menu.general.account']);
     $menu->addItem('wallet', $trans['menu.general.wallet'])->setPermission(Gw2Account::PERMISSION_WALLET);
     $menu->addItem('golds', $trans['menu.general.golds']);
     $menu->addItem('search', $trans['menu.general.search']);
     $menu->addItem('pvp', $trans['menu.general.pvp'])->setPermission(Gw2Account::PERMISSION_PVP);
     $menu->addItem('statistics', $trans['menu.general.statistics']);
     $this->addMenu($menu);
     // CHARACTERS
     $menu = Menu::create($trans['menu.characters']);
     $menu->addItem('characters', $trans['menu.characters.characters']);
     $menu->addItem('equipments', $trans['menu.characters.equipments']);
     $menu->addItem('inventories', $trans['menu.characters.inventories'])->setPermission(Gw2Account::PERMISSION_INVENTORIES);
     $menu->addItem('attributes', $trans['menu.characters.attributes']);
     $menu->addItem('builds', $trans['menu.characters.builds'])->setPermission(Gw2Account::PERMISSION_BUILDS);
     if ($account) {
         $menu->addSeparator();
         foreach ($account->getCharacterNames() as $name) {
             $menu->addItem('character/' . $name, $name, 'character/' . $name);
         }
     }
     $this->addMenu($menu);
     // VAULTS
     $menu = Menu::create($trans['menu.vaults']);
     $menu->addItem('bank', $trans['menu.vaults.bank'])->setPermission(Gw2Account::PERMISSION_INVENTORIES);
     $menu->addItem('collectibles', $trans['menu.vaults.collectibles'])->setPermission(Gw2Account::PERMISSION_INVENTORIES);
     $this->addMenu($menu);
     // UNLOCKS
     $menu = Menu::create($trans['menu.unlocks']);
     $menu->addItem('wardrobe_armors', $trans['menu.unlocks.wardrobe_armors'])->setPermission(Gw2Account::PERMISSION_UNLOCKS);
     $menu->addItem('wardrobe_weapons', $trans['menu.unlocks.wardrobe_weapons'])->setPermission(Gw2Account::PERMISSION_UNLOCKS);
     $menu->addItem('dyes', $trans['menu.unlocks.dyes'])->setPermission(Gw2Account::PERMISSION_UNLOCKS);
     $menu->addItem('minis', $trans['menu.unlocks.minis'])->setPermission(Gw2Account::PERMISSION_UNLOCKS);
     $this->addMenu($menu);
     // TRADING POST
     $menu = Menu::create($trans['menu.tp']);
     $menu->addItem('tp_buys', $trans['menu.tp.tp_buys'])->setPermission(Gw2Account::PERMISSION_TRADINGPOST);
     $menu->addItem('tp_sells', $trans['menu.tp.tp_sells'])->setPermission(Gw2Account::PERMISSION_TRADINGPOST);
     $this->addMenu($menu);
     // ACHIEVMENTS
     $menu = Menu::create($trans['menu.achievements']);
     $menu->addItem('achievements_daily', $trans['menu.achievements.daily']);
     $this->addMenu($menu);
 }
开发者ID:mflayhart,项目名称:gw2tools,代码行数:51,代码来源:MenuList.php

示例6: __

function __()
{
    if (func_num_args() < 1) {
        return false;
    }
    $translator = Translator::getInstance();
    $config = Config::singleton();
    $lang = is_null(Session::get("lang")) ? $config->get("defaultLang") : Session::get("lang");
    $args = func_get_args();
    $str = array_shift($args);
    if (count($args)) {
        return vsprintf($translator->get($str, $lang), $args);
    } else {
        return $translator->get($str, $lang);
    }
}
开发者ID:fmunoz92,项目名称:mili,代码行数:16,代码来源:Translator.php

示例7: reservationList

 public function reservationList($date)
 {
     $dateStart = DateTime::createFromFormat(DATE_FORMAT, $date);
     $sql = "\r\n            SELECT \r\n                t.tableId, \r\n                t.tableName, \r\n                t.tablePerson,\r\n                b.bookingFrom,\r\n                b.bookingTo\r\n            FROM tables t\r\n            LEFT JOIN booking b USING(tableId)\r\n            WHERE \r\n                bookingFrom >= ? AND bookingTo <= ?\r\n            ORDER BY b.bookingFrom, tablePerson\r\n\r\n        ";
     $start = $dateStart->format("Y-m-d 00:00:00");
     $end = $dateStart->format("Y-m-d 23:59:59");
     $stmt = $this->_connection->prepare($sql);
     $stmt->bind_param('ss', $start, $end);
     $stmt->execute();
     $stmt->bind_result($tableId, $tableName, $tablePerson, $bookingFrom, $bookingTo);
     $t = Translator::getInstance();
     $tables = array();
     while ($stmt->fetch()) {
         $tables[] = array($tableId, $t->translate($tableName), $tablePerson, $bookingFrom, $bookingTo);
     }
     return $tables;
 }
开发者ID:gerq,项目名称:gpstuner,代码行数:17,代码来源:BookingModel.php

示例8: sgAdmin

 /**
  * Admin constructor. Doesn't call {@link Singapore} constructor.
  * @param string the path to the base singapore directory
  */
 function sgAdmin($basePath = "")
 {
     //import class definitions
     //io handler class included once config is loaded
     require_once $basePath . "includes/translator.class.php";
     require_once $basePath . "includes/thumbnail.class.php";
     require_once $basePath . "includes/gallery.class.php";
     require_once $basePath . "includes/config.class.php";
     require_once $basePath . "includes/image.class.php";
     require_once $basePath . "includes/user.class.php";
     //start execution timer
     $this->scriptStartTime = microtime();
     //remove slashes
     if (get_magic_quotes_gpc()) {
         $_REQUEST = array_map(array("Singapore", "arraystripslashes"), $_REQUEST);
         //as if magic_quotes_gpc wasn't insane enough, php doesn't add slashes
         //to the tmp_name variable so I have to add them manually. Grrrr.
         foreach ($_FILES as $key => $nothing) {
             $_FILES[$key]["tmp_name"] = addslashes($_FILES[$key]["tmp_name"]);
         }
         $_FILES = array_map(array("Singapore", "arraystripslashes"), $_FILES);
     }
     $galleryId = isset($_REQUEST["gallery"]) ? $_REQUEST["gallery"] : ".";
     //load config from singapore root directory
     $this->config = sgConfig::getInstance();
     $this->config->loadConfig($basePath . "singapore.ini");
     $this->config->loadConfig($basePath . "secret.ini.php");
     //set runtime values
     $this->config->pathto_logs = $this->config->pathto_data_dir . "logs/";
     $this->config->pathto_cache = $this->config->pathto_data_dir . "cache/";
     $this->config->pathto_current_template = $this->config->pathto_templates . $this->config->default_template . "/";
     $this->config->pathto_admin_template = $this->config->pathto_templates . $this->config->admin_template_name . "/";
     //load config from admin template ini file (admin.ini) if present
     $this->config->loadConfig($basePath . $this->config->pathto_admin_template . "admin.ini");
     $this->template = $this->config->default_template;
     //do not load gallery-specific ini files
     //set current language from request vars or config
     $this->language = isset($_REQUEST["lang"]) ? $_REQUEST["lang"] : $this->config->default_language;
     //read the language file
     $this->translator = Translator::getInstance($this->language);
     $this->translator->readLanguageFile($this->config->base_path . $this->config->pathto_locale . "singapore." . $this->language . ".pmo");
     $this->translator->readLanguageFile($this->config->base_path . $this->config->pathto_locale . "singapore.admin." . $this->language . ".pmo");
     //include IO handler class and create instance
     require_once $basePath . "includes/io_" . $this->config->io_handler . ".class.php";
     $ioClassName = "sgIO_" . $this->config->io_handler;
     $this->io = new $ioClassName($this->config);
     //set character set
     if (!empty($this->translator->languageStrings[0]["charset"])) {
         $this->character_set = $this->translator->languageStrings[0]["charset"];
     } else {
         $this->character_set = $this->config->default_charset;
     }
     //set action to perform
     if (empty($_REQUEST["action"])) {
         $this->action = "menu";
     } else {
         $this->action = $_REQUEST["action"];
     }
     //set page title
     $this->pageTitle = $this->config->gallery_name;
     //set root node of crumb line
     $holder = new sgGallery("", new stdClass());
     $holder->name = $this->config->gallery_name;
     $this->ancestors = array($holder);
 }
开发者ID:kyroskoh,项目名称:singapore-1,代码行数:69,代码来源:admin.class.php

示例9: parseDirectory

<title>language cache updater</title>
<link rel="stylesheet" type="text/css" href="tools.css" />
</head>

<body>

<h1>language cache updater</h1>

<p><?php 
$files = parseDirectory($OUTPUTPATH, 'pmo');
$availableLanguages = array();
foreach ($files as $file) {
    if (!preg_match("/singapore\\.([\\w]+)\\.pmo\$/i", $file, $matches)) {
        continue;
    }
    $i18n = Translator::getInstance($matches[1]);
    $i18n->readLanguageFile($sgConfig->base_path . $sgConfig->pathto_locale . "singapore." . $i18n->language . ".pmo");
    $availableLanguages[$matches[1]] = $i18n->languageStrings[0]['language'];
    echo "Added {$matches['1']} => " . $i18n->languageStrings[0]['language'] . " to available languages.<br />\n";
}
//add english which has no translation files
$availableLanguages["en"] = "English";
ksort($availableLanguages);
if (saveCache($availableLanguages, $OUTPUTFILE)) {
    echo "Cache file saved as " . $OUTPUTFILE;
} else {
    echo "Could not save cache file as " . $OUTPUTFILE;
}
?>
</p>
开发者ID:kyroskoh,项目名称:singapore-1,代码行数:30,代码来源:localecache.php

示例10: __construct

 public function __construct()
 {
     if (!$this->isAvailable()) {
         throw new Exception(Translator::getInstance()->trans("The archiver :name is not available. Please install the php extension :extension first.", [':name' => $this->getName(), ':extension' => $this->getExtension()]));
     }
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:6,代码来源:AbstractArchiver.php

示例11: Singapore

 /**
  * Constructor, does all init type stuff. This code is a total mess.
  * @param string the path to the base singapore directory
  */
 function Singapore($basePath = "")
 {
     //import class definitions
     //io handler class included once config is loaded
     require_once $basePath . "includes/translator.class.php";
     require_once $basePath . "includes/thumbnail.class.php";
     require_once $basePath . "includes/gallery.class.php";
     require_once $basePath . "includes/config.class.php";
     require_once $basePath . "includes/image.class.php";
     require_once $basePath . "includes/user.class.php";
     //start execution timer
     $this->scriptStartTime = microtime();
     //remove slashes
     if (get_magic_quotes_gpc()) {
         $_REQUEST = array_map(array("Singapore", "arraystripslashes"), $_REQUEST);
     }
     //desanitize request
     $_REQUEST = array_map("htmlentities", $_REQUEST);
     //load config from singapore root directory
     $this->config = sgConfig::getInstance();
     $this->config->loadConfig($basePath . "singapore.ini");
     $this->config->loadConfig($basePath . "secret.ini.php");
     //if instantiated remotely...
     if (!empty($basePath)) {
         //...try to guess base path and relative url
         if (empty($this->config->base_path)) {
             $this->config->base_path = $basePath;
         }
         if (empty($this->config->base_url)) {
             $this->config->base_url = $basePath;
         }
         //...load local config if present
         //may over-ride guessed values above
         $this->config->loadConfig("singapore.local.ini");
     }
     //set current gallery to root if not specified in url
     $galleryId = isset($_GET[$this->config->url_gallery]) ? $_GET[$this->config->url_gallery] : ".";
     //load config from gallery ini file (gallery.ini) if present
     $this->config->loadConfig($basePath . $this->config->pathto_galleries . $galleryId . "/gallery.ini");
     //set current template from request vars or config
     //first, preset template to default one
     $this->template = $this->config->default_template;
     //then check if requested template exists
     if (!empty($_REQUEST[$this->config->url_template])) {
         $templates = Singapore::getListing($this->config->base_path . $this->config->pathto_templates);
         foreach ($templates->dirs as $single) {
             if ($single == $_REQUEST[$this->config->url_template]) {
                 $this->template = $single;
                 break;
             }
         }
     }
     $this->config->pathto_current_template = $this->config->pathto_templates . $this->template . '/';
     //load config from template ini file (template.ini) if present
     $this->config->loadConfig($basePath . $this->config->pathto_current_template . "template.ini");
     //set runtime values
     $this->config->pathto_logs = $this->config->pathto_data_dir . "logs/";
     $this->config->pathto_cache = $this->config->pathto_data_dir . "cache/";
     $this->config->pathto_admin_template = $this->config->pathto_templates . $this->config->admin_template_name . "/";
     //set current language from request vars or config
     if (!empty($_REQUEST[$this->config->url_lang])) {
         $this->language = $_REQUEST[$this->config->url_lang];
     } else {
         $this->language = $this->config->default_language;
         if ($this->config->detect_language) {
             foreach ($this->getBrowserLanguages() as $lang) {
                 if ($lang == "en" || file_exists($basePath . $this->config->pathto_locale . "singapore." . $lang . ".pmo")) {
                     $this->language = $lang;
                     break;
                 }
             }
         }
     }
     //read the language file
     $this->translator = Translator::getInstance($this->language);
     $this->translator->readLanguageFile($this->config->base_path . $this->config->pathto_locale . "singapore." . $this->language . ".pmo");
     //clear the UMASK
     umask(0);
     //include IO handler class and create instance
     require_once $basePath . "includes/io_" . $this->config->io_handler . ".class.php";
     $ioClassName = "sgIO_" . $this->config->io_handler;
     $this->io = new $ioClassName($this->config);
     //load gallery and image info
     $this->selectGallery($galleryId);
     //set character set
     if (!empty($this->translator->languageStrings[0]["charset"])) {
         $this->character_set = $this->translator->languageStrings[0]["charset"];
     } else {
         $this->character_set = $this->config->default_charset;
     }
     if (ini_get("mbstring.func_overload") == "7") {
         $this->character_set = "UTF-8";
     }
     //set action to perform
     if (empty($_REQUEST["action"])) {
         $this->action = "view";
//.........这里部分代码省略.........
开发者ID:kyroskoh,项目名称:singapore-1,代码行数:101,代码来源:singapore.class.php

示例12: _

 public function _($key)
 {
     $this->_translator = Translator::getInstance();
     return $this->_translator->translate($key);
 }
开发者ID:gerq,项目名称:gpstuner,代码行数:5,代码来源:View.php

示例13: translatePlural

 /**
  * Translate a plural message.
  *
  * @param string $singular
  * @param string $plural
  * @param int    $number
  * @param string $domain
  * @param string $locale
  *
  * @return string
  */
 public function translatePlural($singular, $plural, $number, $domain = null, $locale = null)
 {
     return Translator::getInstance()->translatePlural($singular, $plural, $number, $domain, $locale);
 }
开发者ID:slickframework,项目名称:i18n,代码行数:15,代码来源:TranslateMethods.php


注:本文中的Translator::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。