本文整理汇总了PHP中i18n::get_js_i18n方法的典型用法代码示例。如果您正苦于以下问题:PHP i18n::get_js_i18n方法的具体用法?PHP i18n::get_js_i18n怎么用?PHP i18n::get_js_i18n使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类i18n
的用法示例。
在下文中一共展示了i18n::get_js_i18n方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_i18n_javascript
/**
* Add i18n files from the given javascript directory. Sapphire expects that the given directory
* will contain a number of java script files named by language: en_US.js, de_DE.js, etc.
* @param $langDir The javascript lang directory, relative to the site root, e.g., 'sapphire/javascript/lang'
*/
public function add_i18n_javascript($langDir)
{
if (i18n::get_js_i18n()) {
// Include i18n.js even if no languages are found. The fact that
// add_i18n_javascript() was called indicates that the methods in
// here are needed.
$this->javascript(SAPPHIRE_DIR . '/javascript/i18n.js');
if (substr($langDir, -1) != '/') {
$langDir .= '/';
}
$this->javascript($langDir . i18n::default_locale() . '.js');
$this->javascript($langDir . i18n::get_locale() . '.js');
// Stub i18n implementation for when i18n is disabled.
} else {
$this->javascript[SAPPHIRE_DIR . '/javascript/i18nx.js'] = true;
}
}
示例2: add_i18n_javascript
/**
* Add i18n files from the given javascript directory. SilverStripe expects that the given directory
* will contain a number of java script files named by language: en_US.js, de_DE.js, etc.
*
* @param String The javascript lang directory, relative to the site root, e.g., 'framework/javascript/lang'
* @param Boolean Return all relative file paths rather than including them in requirements
* @param Boolean Only include language files, not the base libraries
*/
public function add_i18n_javascript($langDir, $return = false, $langOnly = false)
{
$files = array();
if (i18n::get_js_i18n()) {
// Include i18n.js even if no languages are found. The fact that
// add_i18n_javascript() was called indicates that the methods in
// here are needed.
if (!$langOnly) {
$files[] = FRAMEWORK_DIR . '/javascript/i18n.js';
}
if (substr($langDir, -1) != '/') {
$langDir .= '/';
}
$files[] = $langDir . i18n::default_locale() . '.js';
$files[] = $langDir . i18n::get_locale() . '.js';
// Stub i18n implementation for when i18n is disabled.
} else {
if (!$langOnly) {
$files[] = FRAMEWORK_DIR . '/javascript/i18nx.js';
}
}
if ($return) {
return $files;
} else {
foreach ($files as $file) {
$this->javascript($file);
}
}
}