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


PHP Internationalization类代码示例

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


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

示例1: run

    function run($max_time) {
        foreach (array(
                'registration-staff', 'pwreset-staff', 'banner-staff',
                'registration-client', 'pwreset-client', 'banner-client',
                'registration-confirm', 'registration-thanks',
                'access-link') as $type) {
            $i18n = new Internationalization();
            $tpl = $i18n->getTemplate("templates/page/{$type}.yaml");
            if (!($page = $tpl->getData()))
                // No such template on disk
                continue;

            if ($id = db_result(db_query('select id from '.PAGE_TABLE
                    .' where `type`='.db_input($type))))
                // Already have a template for the content type
                continue;

            $sql = 'INSERT INTO '.PAGE_TABLE.' SET type='.db_input($type)
                .', name='.db_input($page['name'])
                .', body='.db_input($page['body'])
                .', lang='.db_input($tpl->getLang())
                .', notes='.db_input($page['notes'])
                .', created=NOW(), updated=NOW(), isactive=1';
            db_query($sql);
        }
        // Set the content_id for all the new items
        db_query('UPDATE '.PAGE_TABLE
            .' SET `content_id` = `id` WHERE `content_id` = 0');
    }
开发者ID:KingsleyGU,项目名称:osticket,代码行数:29,代码来源:f5692e24-4323a6a8.task.php

示例2: getTipsJson

 function getTipsJson($namespace, $lang = false)
 {
     global $ost, $thisstaff;
     if (!$lang) {
         $lang = $thisstaff ? $thisstaff->getLanguage() : Internationalization::getDefaultLanguage();
     }
     $i18n = new Internationalization($lang);
     $tips = $i18n->getTemplate("help/tips/{$namespace}.yaml");
     if (!$tips || !($data = $tips->getData())) {
         Http::response(404, 'Help content not available');
     }
     // Translate links to the root path of this installation
     foreach ($data as $tip => &$info) {
         if ($ost) {
             $info = $ost->replaceTemplateVariables($info, array('config' => $ost->getConfig()));
         }
         if (isset($info['links'])) {
             foreach ($info['links'] as &$l) {
                 if ($l['href'][0] == '/') {
                     $l['href'] = ROOT_PATH . substr($l['href'], 1);
                 }
             }
         }
     }
     return $this->json_encode($data);
 }
开发者ID:ed00m,项目名称:osTicket-1.8,代码行数:26,代码来源:ajax.tips.php

示例3: run

    function run($max_time) {
        global $cfg;

        $i18n = new Internationalization($cfg->get('system_language', 'en_US'));
        $sequences = $i18n->getTemplate('sequence.yaml')->getData();
        foreach ($sequences as $s) {
            Sequence::create($s)->save();
        }
        db_query('UPDATE '.SEQUENCE_TABLE.' SET `next`= '
            .'(SELECT MAX(ticket_id)+1 FROM '.TICKET_TABLE.') '
            .'WHERE `id`=1');

        require_once(INCLUDE_DIR . 'class.list.php');

        $lists = $i18n->getTemplate('list.yaml')->getData();
        foreach ($lists as $l) {
            DynamicList::create($l);
        }

        $statuses = $i18n->getTemplate('ticket_status.yaml')->getData();
        foreach ($statuses as $s) {
            TicketStatus::__create($s);
        }

        // Initialize MYSQL search backend
        MysqlSearchBackend::__init();
    }
开发者ID:KingsleyGU,项目名称:osticket,代码行数:27,代码来源:8f99b8bf-03ff59bf.task.php

示例4: run

 function run($max_time)
 {
     $i18n = new Internationalization('en_US');
     $forms = $i18n->getTemplate('form.yaml')->getData();
     foreach ($forms as $f) {
         DynamicForm::create($f);
     }
 }
开发者ID:dmiguel92,项目名称:osTicket-1.8,代码行数:8,代码来源:dad45ca2-61c9d5d7.task.php

示例5: createUpgradedTicket

 function createUpgradedTicket()
 {
     global $cfg;
     $i18n = new Internationalization();
     $vars = $i18n->getTemplate('templates/ticket/upgraded.yaml')->getData();
     $vars['deptId'] = $cfg->getDefaultDeptId();
     //Create a ticket to make the system warm and happy.
     $errors = array();
     Ticket::create($vars, $errors, 'api', false, false);
 }
开发者ID:ed00m,项目名称:osTicket-1.8,代码行数:10,代码来源:class.upgrader.php

示例6: __loadDefaultForm

 /**
  * Auto-installer. Necessary for 1.8 users between the RC1 release and
  * the stable release who don't have the form in their database because
  * it wan't in the yaml file for installation or upgrade.
  */
 function __loadDefaultForm()
 {
     require_once INCLUDE_DIR . 'class.i18n.php';
     $i18n = new Internationalization();
     $tpl = $i18n->getTemplate('form.yaml');
     foreach ($tpl->getData() as $f) {
         if ($f['type'] == 'C') {
             $form = DynamicForm::create($f);
             $form->save();
             break;
         }
     }
 }
开发者ID:KingsleyGU,项目名称:osticket,代码行数:18,代码来源:class.company.php

示例7: getLanguageFile

 function getLanguageFile($lang, $key)
 {
     global $cfg;
     $i18n = new Internationalization($lang);
     switch ($key) {
         case 'js':
             $data = $i18n->getTemplate('js/redactor.js')->getRawData();
             $data .= $i18n->getTemplate('js/jquery.ui.datepicker.js')->getRawData();
             // Strings from various javascript files
             $data .= $i18n->getTemplate('js/osticket-strings.js')->getRawData();
             header('Content-Type: text/javascript; charset=UTF-8');
             break;
         default:
             Http::response(404, 'No such i18n data');
     }
     Http::cacheable(md5($data), $cfg->lastModified());
     echo $data;
 }
开发者ID:ayurmedia,项目名称:osTicket-1.8,代码行数:18,代码来源:ajax.i18n.php

示例8: run

 function run($runtime)
 {
     $errors = array();
     $i18n = new Internationalization('en_US');
     $tpls = $i18n->getTemplate('email_template_group.yaml')->getData();
     foreach ($tpls as $t) {
         // If the email template group specifies an id attribute, remove
         // it for upgrade because we cannot assume that the id slot is
         // available
         unset($t['id']);
         EmailTemplateGroup::create($t, $errors);
     }
     $files = $i18n->getTemplate('file.yaml')->getData();
     foreach ($files as $f) {
         $id = AttachmentFile::create($f, $errors);
         // Ensure the new files are never deleted (attached to Disk)
         $sql = 'INSERT INTO ' . ATTACHMENT_TABLE . ' SET object_id=0, `type`=\'D\', inline=1' . ', file_id=' . db_input($id);
         db_query($sql);
     }
 }
开发者ID:dmiguel92,项目名称:osTicket-1.8,代码行数:20,代码来源:d51f303a-dad45ca2.task.php

示例9: configureForUser

 static function configureForUser($user = false)
 {
     $lang = Internationalization::getCurrentLanguage($user);
     $info = Internationalization::getLanguageInfo(strtolower($lang));
     if (!$info) {
         // Not a supported language
         return;
     }
     // Define locale for C-libraries
     putenv('LC_ALL=' . $info['code']);
     self::setLocale(LC_ALL, $info['code']);
 }
开发者ID:iHunt101,项目名称:phlite,代码行数:12,代码来源:TextDomain.php

示例10: client

 function client()
 {
     global $cfg;
     $lang = Internationalization::getCurrentLanguage();
     list($sl, $locale) = explode('_', $lang);
     $rtl = false;
     foreach (Internationalization::availableLanguages() as $info) {
         if (isset($info['direction'])) {
             $rtl = true;
         }
     }
     $config = array('html_thread' => (bool) $cfg->isHtmlThreadEnabled(), 'lang' => $lang, 'short_lang' => $sl, 'has_rtl' => $rtl);
     $config = $this->json_encode($config);
     Http::cacheable(md5($config), $cfg->lastModified());
     header('Content-Type: application/json; charset=UTF-8');
     return $config;
 }
开发者ID:gizur,项目名称:osticket,代码行数:17,代码来源:ajax.config.php

示例11: getLanguage

 function getLanguage()
 {
     static $cached = false;
     if (!$cached) {
         $cached =& $_SESSION['staff:lang'];
     }
     if (!$cached) {
         $cached = $this->config->get('lang');
         if (!$cached) {
             $cached = Internationalization::getDefaultLanguage();
         }
     }
     return $cached;
 }
开发者ID:KingsleyGU,项目名称:osticket,代码行数:14,代码来源:class.staff.php

示例12: fromInitialData

 /**
  * Load the template from the initial_data directory. The format of the
  * file should be free flow text. The first line is the subject and the
  * rest of the file is the body.
  */
 function fromInitialData($name, $group = null)
 {
     $templ = new EmailTemplate(0, $group);
     $lang = $group ? $group->getLanguage() : 'en_US';
     $i18n = new Internationalization($lang);
     if (!($tpl = $i18n->getTemplate("templates/email/{$name}.yaml")) || !($info = $tpl->getData())) {
         return false;
     }
     if (isset($info['subject']) && isset($info['body'])) {
         $templ->ht = $info;
         return $templ;
     }
     raise_error("{$lang}/templates/{$name}.yaml: " . _S('Email templates must define both "subject" and "body" parts of the template'), 'InitialDataError');
     return false;
 }
开发者ID:KingsleyGU,项目名称:osticket,代码行数:20,代码来源:class.template.php

示例13: __

            </td>
        </tr>
</tbody>
<tbody id="language">
        <tr>
            <td width="180" class="required">
                <?php echo __('Language'); ?>:
            </td>
            <td>
        <?php
        $langs = Internationalization::availableLanguages(); ?>
                <select name="lang_id">
<?php foreach($langs as $l) {
    $selected = ($info['lang_id'] == $l['code']) ? 'selected="selected"' : ''; ?>
                    <option value="<?php echo $l['code']; ?>" <?php echo $selected;
                        ?>><?php echo Internationalization::getLanguageDescription($l['code']); ?></option>
<?php } ?>
                </select>
                &nbsp;<span class="error">*&nbsp;<?php echo $errors['lang_id']; ?></span>
                <i class="help-tip icon-question-sign" href="#language"></i>
            </td>
        </tr>
</tbody>
<tbody>
        <?php } ?>
        <tr>
            <th colspan="2">
                <em><strong><?php echo __('Internal Notes');?></strong>: <?php echo __(
                "be liberal, they're internal");?></em>
            </th>
        </tr>
开发者ID:KingsleyGU,项目名称:osticket,代码行数:31,代码来源:template.inc.php

示例14: __load

 static function __load()
 {
     require_once INCLUDE_DIR . 'class.i18n.php';
     $i18n = new Internationalization();
     $tpl = $i18n->getTemplate('list.yaml');
     foreach ($tpl->getData() as $f) {
         if ($f['type'] == 'ticket-status') {
             $list = DynamicList::create($f);
             $list->save();
             break;
         }
     }
     if (!$list || !($o = DynamicForm::objects()->filter(array('type' => 'L' . $list->getId())))) {
         return false;
     }
     // Create default statuses
     if ($statuses = $i18n->getTemplate('ticket_status.yaml')->getData()) {
         foreach ($statuses as $status) {
             TicketStatus::__create($status);
         }
     }
     return $o[0];
 }
开发者ID:KingsleyGU,项目名称:osticket,代码行数:23,代码来源:class.list.php

示例15: foreach

                </select>
                &nbsp;<span class="error">*&nbsp;<?php 
    echo $errors['tpl_id'];
    ?>
</span><i class="help-tip icon-question-sign" href="#template_to_clone"></i>
            </td>
        </tr>
</tbody>
<tbody id="language">
        <tr>
            <td width="180" class="required">
                Language:
            </td>
            <td>
        <?php 
    $langs = Internationalization::availableLanguages();
    ?>
                <select name="lang_id">
<?php 
    foreach ($langs as $l) {
        $selected = $info['lang_id'] == $l['code'] ? 'selected="selected"' : '';
        ?>
                    <option value="<?php 
        echo $l['code'];
        ?>
" <?php 
        echo $selected;
        ?>
><?php 
        echo $l['desc'];
        ?>
开发者ID:ed00m,项目名称:osTicket-1.8,代码行数:31,代码来源:template.inc.php


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