本文整理匯總了PHP中Locale::get_messages方法的典型用法代碼示例。如果您正苦於以下問題:PHP Locale::get_messages方法的具體用法?PHP Locale::get_messages怎麽用?PHP Locale::get_messages使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Locale
的用法示例。
在下文中一共展示了Locale::get_messages方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: locale_js
/**
* Serves the locale Javascript to translate javascript strings.
*/
public function locale_js()
{
header('Expires: ' . gmdate('D, d M Y H:i:s ', time() + 432000) . 'GMT');
header('content-type: text/javascript');
$domain = Locale::get_messages();
$domain_json = json_encode($domain);
$js = <<<TEEHEE
function _t() {
var domain = {$domain_json};
var s = arguments[0];
if(domain[s] != undefined) {
s = domain[s][1][0];
}
for(var i = 1; i <= arguments.length; i++) {
r = new RegExp('%' + (i) + '\\\\\$s', 'g');
if(!s.match(r)) {
r = new RegExp('%s');
}
s = s.replace(r, arguments[i]);
}
return s;
}
TEEHEE;
echo Plugins::filter('locale_js', $js);
}
示例2: die
<?php
namespace Habari;
if (!defined('HABARI_PATH')) {
die('No direct access');
}
?>
</div><!-- end wrapper -->
<script type="text/javascript">
function _t() {
var domain = <?php
// retrieve only the translated strings that are used by this page's javascript functions.
$messages = array_intersect_key(Locale::get_messages(), array_flip(array("All selected", "%s selected", "None selected")));
echo json_encode($messages);
?>
;
var s = arguments[0];
if(domain[s] != undefined) {
s = domain[s][1][0];
}
for(var i = 1; i <= arguments.length; i++) {
r = new RegExp('%' + (i) + '\\\\\$s', 'g');
if(!s.match(r)) {
r = new RegExp('%s');
}
s = s.replace(r, arguments[i]);
}
return s;