• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP get_parent_language函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_parent_language函数的典型用法代码示例。如果您正苦于以下问题:PHP get_parent_language函数的具体用法?PHP get_parent_language怎么用?PHP get_parent_language使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: replace_callback

 protected static function replace_callback($langblock)
 {
     global $CFG;
     static $parentcache;
     if (!isset($parentcache)) {
         $parentcache = array();
     }
     $mylang = current_language();
     if (!array_key_exists($mylang, $parentcache)) {
         $parentlang = get_parent_language($mylang);
         $parentcache[$mylang] = $parentlang;
     } else {
         $parentlang = $parentcache[$mylang];
     }
     $blocklang = trim(core_text::strtolower($langblock[1]));
     $blocktext = $langblock[2];
     if ($mylang === $blocklang || $parentlang === $blocklang) {
         return $blocktext;
     }
     return '';
 }
开发者ID:alexferrergrau,项目名称:moodle-filter_multilang2,代码行数:21,代码来源:filter.php


示例2: filter_multilang_impl

function filter_multilang_impl($langblock)
{
    global $CFG;
    $mylang = current_language();
    static $parentcache;
    if (!isset($parentcache)) {
        $parentcache = array();
    }
    if (!array_key_exists($mylang, $parentcache)) {
        $parentlang = get_parent_language($mylang);
        $parentcache[$mylang] = $parentlang;
    } else {
        $parentlang = $parentcache[$mylang];
    }
    $searchtosplit = '/<(?:lang|span)[^>]+lang="([a-zA-Z0-9_-]+)"[^>]*>(.*?)<\\/(?:lang|span)>/is';
    if (!preg_match_all($searchtosplit, $langblock[0], $rawlanglist)) {
        //skip malformed blocks
        return $langblock[0];
    }
    $langlist = array();
    foreach ($rawlanglist[1] as $index => $lang) {
        $lang = str_replace('-', '_', strtolower($lang));
        // normalize languages
        $langlist[$lang] = $rawlanglist[2][$index];
    }
    if (array_key_exists($mylang, $langlist)) {
        return $langlist[$mylang];
    } else {
        if (array_key_exists($parentlang, $langlist)) {
            return $langlist[$parentlang];
        } else {
            $first = array_shift($langlist);
            return $first;
        }
    }
}
开发者ID:evltuma,项目名称:moodle,代码行数:36,代码来源:filter.php


示例3: array

    if (file_exists($CFG->dataroot . '/lang/' . $lang . '_utf8') or file_exists($CFG->dirroot . '/lang/' . $lang . '_utf8')) {
        $lang = $lang . '_utf8';
    } else {
        $lang = 'en_utf8';
    }
}
// load english defaults
$string = array();
foreach (get_langpack_locations('en_utf8') as $location) {
    if (!file_exists($location)) {
        continue;
    }
    include $location;
}
// find parent language
if ($parent = get_parent_language($lang)) {
    foreach (get_langpack_locations($parent) as $location) {
        if (!file_exists($location)) {
            continue;
        }
        include $location;
    }
}
// load wanted language
if ($lang !== 'en_utf8') {
    foreach (get_langpack_locations($lang) as $location) {
        if (!file_exists($location)) {
            continue;
        }
        include $location;
    }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:31,代码来源:strings.php


示例4: get_string

        }
    }
    if ($updated) {
        $notice_ok[] = get_string('langupdatecomplete', 'tool_langimport');
    } else {
        $notice_ok[] = get_string('nolangupdateneeded', 'tool_langimport');
    }
    unset($installer);
}
get_string_manager()->reset_caches();
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('langimport', 'tool_langimport'));
$installedlangs = get_string_manager()->get_list_of_translations(true);
$missingparents = array();
foreach ($installedlangs as $installedlang => $unused) {
    $parent = get_parent_language($installedlang);
    if (empty($parent)) {
        continue;
    }
    if (!isset($installedlangs[$parent])) {
        $missingparents[$installedlang] = $parent;
    }
}
$installer = new lang_installer();
if ($availablelangs = $installer->get_remote_list_of_languages()) {
    $remote = true;
} else {
    $remote = false;
    $availablelangs = array();
    echo $OUTPUT->box_start();
    print_string('remotelangnotavailable', 'tool_langimport', $CFG->dataroot . '/lang/');
开发者ID:abhilash1994,项目名称:moodle,代码行数:31,代码来源:index.php


示例5: get_parent_language

 /**
  * Returns a parent language of the given installed language
  *
  * @param string $langcode
  * @return string parent language's code
  */
 protected function get_parent_language($langcode)
 {
     return get_parent_language($langcode);
 }
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:10,代码来源:componentlib.class.php


示例6: load_language

/**
 * includes a language file or returns the content of a language file
 *
 * tries to load in descending order:
 *   param language, user language, default language
 *
 * @param string $filename
 * @param string $dirname
 * @param mixed options can contain
 *     @option string language - language to load
 *     @option bool return - if true the file content is returned
 *     @option bool no_fallback - if true do not load default language
 *     @option bool|string force_fallback - force pre-loading of another language
 *        default language if *true* or specified language
 *     @option bool local - if true load file from local directory
 * @return boolean|string
 */
function load_language($filename, $dirname = '', $options = array())
{
    global $user, $language_files;
    // keep trace of plugins loaded files for switch_lang_to() function
    if (!empty($dirname) && !empty($filename) && !@$options['return'] && !isset($language_files[$dirname][$filename])) {
        $language_files[$dirname][$filename] = $options;
    }
    if (!@$options['return']) {
        $filename .= '.php';
    }
    if (empty($dirname)) {
        $dirname = PHPWG_ROOT_PATH;
    }
    $dirname .= 'language/';
    $default_language = defined('PHPWG_INSTALLED') and !defined('UPGRADES_PATH') ? get_default_language() : PHPWG_DEFAULT_LANGUAGE;
    // construct list of potential languages
    $languages = array();
    if (!empty($options['language'])) {
        // explicit language
        $languages[] = $options['language'];
    }
    if (!empty($user['language'])) {
        // use language
        $languages[] = $user['language'];
    }
    if (($parent = get_parent_language()) != null) {
        // parent language
        // this is only for when the "child" language is missing
        $languages[] = $parent;
    }
    if (isset($options['force_fallback'])) {
        // fallback language
        // this is only for when the main language is missing
        if ($options['force_fallback'] === true) {
            $options['force_fallback'] = $default_language;
        }
        $languages[] = $options['force_fallback'];
    }
    if (!@$options['no_fallback']) {
        // default language
        $languages[] = $default_language;
    }
    $languages = array_unique($languages);
    // find first existing
    $source_file = '';
    $selected_language = '';
    foreach ($languages as $language) {
        $f = @$options['local'] ? $dirname . $language . '.' . $filename : $dirname . $language . '/' . $filename;
        if (file_exists($f)) {
            $selected_language = $language;
            $source_file = $f;
            break;
        }
    }
    if (!empty($source_file)) {
        if (!@$options['return']) {
            // load forced fallback
            if (isset($options['force_fallback']) && $options['force_fallback'] != $selected_language) {
                @(include str_replace($selected_language, $options['force_fallback'], $source_file));
            }
            // load language content
            @(include $source_file);
            $load_lang = @$lang;
            $load_lang_info = @$lang_info;
            // access already existing values
            global $lang, $lang_info;
            if (!isset($lang)) {
                $lang = array();
            }
            if (!isset($lang_info)) {
                $lang_info = array();
            }
            // load parent language content directly in global
            if (!empty($load_lang_info['parent'])) {
                $parent_language = $load_lang_info['parent'];
            } else {
                if (!empty($lang_info['parent'])) {
                    $parent_language = $lang_info['parent'];
                } else {
                    $parent_language = null;
                }
            }
            if (!empty($parent_language) && $parent_language != $selected_language) {
//.........这里部分代码省略.........
开发者ID:squidjam,项目名称:Piwigo,代码行数:101,代码来源:functions.inc.php


示例7: stdClass

}
//download lang pack with optional notification
if ($CFG->lang != 'en') {
    if ($cd = new component_installer('http://download.moodle.org', 'langpack/2.0', $CFG->lang . '.zip', 'languages.md5', 'lang')) {
        if ($cd->install() == COMPONENT_ERROR) {
            if ($cd->get_error() == 'remotedownloaderror') {
                $a = new stdClass();
                $a->url = 'http://download.moodle.org/langpack/2.0/' . $CFG->lang . '.zip';
                $a->dest = $CFG->dataroot . '/lang';
                cli_problem(get_string($cd->get_error(), 'error', $a));
            } else {
                cli_problem(get_string($cd->get_error(), 'error'));
            }
        } else {
            // install parent lang if defined
            if ($parentlang = get_parent_language()) {
                if ($cd = new component_installer('http://download.moodle.org', 'langpack/2.0', $parentlang . '.zip', 'languages.md5', 'lang')) {
                    $cd->install();
                }
            }
        }
    }
}
// switch the string_manager instance to stop using install/lang/
$CFG->early_install_lang = false;
$CFG->langotherroot = $CFG->dataroot . '/lang';
$CFG->langlocalroot = $CFG->dataroot . '/lang';
get_string_manager(true);
// make sure we are installing stable release or require a confirmation
if (isset($maturity)) {
    if ($maturity < MATURITY_STABLE and !$options['allow-unstable']) {
开发者ID:hitphp,项目名称:moodle,代码行数:31,代码来源:install.php


示例8: upgrade_language_pack

/**
 * Try to upgrade the given language pack (or current language)
 * @global object
 */
function upgrade_language_pack($lang = '')
{
    global $CFG, $OUTPUT;
    if (empty($lang)) {
        $lang = current_language();
    }
    if ($lang == 'en_utf8') {
        return true;
        // Nothing to do
    }
    upgrade_started(false);
    echo $OUTPUT->heading(get_string('langimport', 'admin') . ': ' . $lang);
    @mkdir($CFG->dataroot . '/temp/');
    //make it in case it's a fresh install, it might not be there
    @mkdir($CFG->dataroot . '/lang/');
    require_once $CFG->libdir . '/componentlib.class.php';
    if ($cd = new component_installer('http://download.moodle.org', 'lang16', $lang . '.zip', 'languages.md5', 'lang')) {
        $status = $cd->install();
        //returns COMPONENT_(ERROR | UPTODATE | INSTALLED)
        if ($status == COMPONENT_INSTALLED) {
            @unlink($CFG->dataroot . '/cache/languages');
            if ($parentlang = get_parent_language($lang)) {
                if ($cd = new component_installer('http://download.moodle.org', 'lang16', $parentlang . '.zip', 'languages.md5', 'lang')) {
                    $cd->install();
                }
            }
            echo $OUTPUT->notification(get_string('success'), 'notifysuccess');
        }
    }
    print_upgrade_separator();
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:35,代码来源:upgradelib.php


示例9: get_list_of_currencies

/**
 * Returns a list of currencies in the current language
 *
 * @global object
 * @global object
 * @return array
 */
function get_list_of_currencies()
{
    global $CFG, $USER;
    $lang = current_language();
    if (!file_exists($CFG->dataroot . '/lang/' . $lang . '/currencies.php')) {
        if ($parentlang = get_parent_language()) {
            if (file_exists($CFG->dataroot . '/lang/' . $parentlang . '/currencies.php')) {
                $lang = $parentlang;
            } else {
                $lang = 'en_utf8';
                // currencies.php must exist in this pack
            }
        } else {
            $lang = 'en_utf8';
            // currencies.php must exist in this pack
        }
    }
    if (file_exists($CFG->dataroot . '/lang/' . $lang . '/currencies.php')) {
        include_once $CFG->dataroot . '/lang/' . $lang . '/currencies.php';
    } else {
        //if en_utf8 is not installed in dataroot
        include_once $CFG->dirroot . '/lang/' . $lang . '/currencies.php';
    }
    if (!empty($string)) {
        asort($string);
    }
    return $string;
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:35,代码来源:moodlelib.php


示例10: installLangPack

 public function installLangPack($pack)
 {
     global $CFG;
     require_once $CFG->libdir . '/adminlib.php';
     require_once $CFG->libdir . '/filelib.php';
     require_once $CFG->libdir . '/componentlib.class.php';
     $thisversion = '2.0';
     // TODO this information should be taken from version.php or similar source
     make_upload_directory('lang');
     if (is_array($pack)) {
         $packs = $pack;
     } else {
         $packs = array($pack);
     }
     foreach ($packs as $pack) {
         if ($cd = new component_installer('http://download.moodle.org', 'langpack/' . $thisversion, $pack . '.zip', 'languages.md5', 'lang')) {
             $status = $cd->install();
             switch ($status) {
                 case COMPONENT_ERROR:
                     if ($cd->get_error() == 'remotedownloaderror') {
                         $a = new stdClass();
                         $a->url = 'http://download.moodle.org/langpack/' . $thisversion . '/' . $pack . '.zip';
                         $a->dest = $CFG->dataroot . '/lang';
                         print_error($cd->get_error(), 'error', 'langimport.php', $a);
                     } else {
                         print_error($cd->get_error(), 'error', 'langimport.php');
                     }
                     break;
                 case COMPONENT_INSTALLED:
                     if ($parentlang = get_parent_language($pack)) {
                         // install also parent pack if specified
                         if ($cd = new component_installer('http://download.moodle.org', 'langpack/' . $thisversion, $parentlang . '.zip', 'languages.md5', 'lang')) {
                             $cd->install();
                         }
                     }
                     break;
             }
         } else {
             echo $OUTPUT->notification('Had an unspecified error with the component installer, sorry.');
         }
     }
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:42,代码来源:GcrCurrentEschool.class.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_parent_post_rel_link函数代码示例发布时间:2022-05-15
下一篇:
PHP get_parent_interface函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap