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


PHP i18n::get_lang_from_locale方法代码示例

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


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

示例1: applyParsley

 /**
  * applyParsley
  * @return this
  **/
 public function applyParsley()
 {
     $this->parsleyEnabled = true;
     Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
     Requirements::javascript(ZENVALIDATOR_PATH . '/javascript/parsley/parsley.remote.min.js');
     $lang = i18n::get_lang_from_locale(i18n::get_locale());
     if ($lang != 'en') {
         Requirements::javascript(ZENVALIDATOR_PATH . '/javascript/parsley/i18n/' . $lang . '.js');
     }
     if ($this->form) {
         if ($this->defaultJS) {
             $this->form->addExtraClass('parsley');
             Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js');
             Requirements::javascript(ZENVALIDATOR_PATH . '/javascript/zenvalidator.js');
         } else {
             $this->form->addExtraClass('custom-parsley');
         }
         foreach ($this->constraints as $fieldName => $constraints) {
             foreach ($constraints as $constraint) {
                 $constraint->applyParsley();
             }
         }
     }
     return $this;
 }
开发者ID:helpfulrobot,项目名称:sheadawson-silverstripe-zenvalidator,代码行数:29,代码来源:ZenValidator.php

示例2: __construct

 /**
  * @param $locale
  */
 public function __construct($locale = null)
 {
     $this->defaultLocale = $locale ? $locale : i18n::get_lang_from_locale(i18n::default_locale());
     $this->basePath = Director::baseFolder();
     $this->baseSavePath = Director::baseFolder();
     parent::__construct();
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:10,代码来源:i18nTextCollector.php

示例3: Languages

 /**
  * Get a set of content languages (for quick language navigation)
  * @example
  * <code>
  * <!-- in your template -->
  * <ul class="langNav">
  * 		<% loop Languages %>
  * 		<li><a href="$Link" class="$LinkingMode" title="$Title.ATT">$Language</a></li>
  * 		<% end_loop %>
  * </ul>
  * </code>
  *
  * @return ArrayList|null
  */
 public function Languages()
 {
     $locales = TranslatableUtility::get_content_languages();
     // there's no need to show a navigation when there's less than 2 languages. So return null
     if (count($locales) < 2) {
         return null;
     }
     $currentLocale = Translatable::get_current_locale();
     $homeTranslated = null;
     if ($home = SiteTree::get_by_link('home')) {
         /** @var SiteTree $homeTranslated */
         $homeTranslated = $home->getTranslation($currentLocale);
     }
     /** @var ArrayList $langSet */
     $langSet = ArrayList::create();
     foreach ($locales as $locale => $name) {
         Translatable::set_current_locale($locale);
         /** @var SiteTree $translation */
         $translation = $this->owner->hasTranslation($locale) ? $this->owner->getTranslation($locale) : null;
         $langSet->push(new ArrayData(array('Locale' => $locale, 'RFC1766' => i18n::convert_rfc1766($locale), 'Language' => DBField::create_field('Varchar', strtoupper(i18n::get_lang_from_locale($locale))), 'Title' => DBField::create_field('Varchar', html_entity_decode(i18n::get_language_name(i18n::get_lang_from_locale($locale), true), ENT_NOQUOTES, 'UTF-8')), 'LinkingMode' => $currentLocale == $locale ? 'current' : 'link', 'Link' => $translation ? $translation->AbsoluteLink() : ($homeTranslated ? $homeTranslated->Link() : ''))));
     }
     Translatable::set_current_locale($currentLocale);
     i18n::set_locale($currentLocale);
     return $langSet;
 }
开发者ID:bummzack,项目名称:translatable-dataobject,代码行数:39,代码来源:TranslatableUtility.php

示例4: CurrentLocaleInformation

 /**
  * Retrieves information about this object in the CURRENT locale
  *
  * @param string $locale The locale information to request, or null to use the default locale
  * @return ArrayData Mapped list of locale properties
  */
 public function CurrentLocaleInformation()
 {
     $locale = Fluent::current_locale();
     // Store basic locale information
     $data = array('Locale' => $locale, 'LocaleRFC1766' => i18n::convert_rfc1766($locale), 'Alias' => Fluent::alias($locale), 'Title' => i18n::get_locale_name($locale), 'LanguageNative' => i18n::get_language_name(i18n::get_lang_from_locale($locale), true));
     return new ArrayData($data);
 }
开发者ID:micschk,项目名称:silverstripe-cmstweaks,代码行数:13,代码来源:PageHelpersExtension.php

示例5: updateCMSFields

 /**
  * Updates the CMS fields adding the fields defined in this extension
  * @param {FieldList} $fields Field List that new fields will be added to
  */
 public function updateCMSFields(FieldList $fields)
 {
     $urlSegmentField = $fields->dataFieldByName('URLSegment');
     if ($urlSegmentField) {
         $baseLink = Controller::join_links(Director::absoluteBaseURL(), (Config::inst()->get('MultilingualRootURLController', 'UseLocaleURL') ? $this->owner->Locale : i18n::get_lang_from_locale($this->owner->Locale)) . '/', SiteTree::config()->nested_urls && $this->owner->ParentID ? $this->owner->Parent()->RelativeLink(true) : null);
         $urlSegmentField->setURLPrefix($baseLink);
     }
 }
开发者ID:helpfulrobot,项目名称:webbuilders-group-silverstripe-translatablerouting,代码行数:12,代码来源:MultilingualSiteTreeExtension.php

示例6: __construct

 function __construct($name, $title = null, $value = null)
 {
     parent::__construct($name, $title, $value);
     Requirements::javascript(FORM_EXTRAS_PATH . '/javascript/tinymce/tinymce.min.js');
     $lang = i18n::get_lang_from_locale(i18n::get_locale());
     if ($lang != 'en') {
         Requirements::javascript(FORM_EXTRAS_PATH . '/javascript/tinymce/langs/' . $lang . '.js');
     }
 }
开发者ID:helpfulrobot,项目名称:lekoala-silverstripe-form-extras,代码行数:9,代码来源:SimpleTinyMceField.php

示例7: loadExtra

 /**
  * Load extra validator
  * @param string $name
  * */
 public function loadExtra($name)
 {
     $useCurrent = ZenValidator::config()->use_current;
     $parsleyFolder = 'parsley';
     if ($useCurrent) {
         $parsleyFolder = 'parsley_current';
     }
     Requirements::javascript(ZENVALIDATOR_PATH . '/javascript/' . $parsleyFolder . '/extra/validator/' . $name . '.js');
     $lang = i18n::get_lang_from_locale(i18n::get_locale());
     Requirements::javascript(ZENVALIDATOR_PATH . '/javascript/' . $parsleyFolder . '/i18n/' . $lang . '.extra.js');
 }
开发者ID:sheadawson,项目名称:silverstripe-zenvalidator,代码行数:15,代码来源:ZenValidatorConstraint.php

示例8: Field

 /**
  * Adds in the requirements for the field
  * @param {array} $properties Array of properties for the form element (not used)
  * @return {string} Rendered field template
  */
 public function Field($properties = array())
 {
     $siteKey = self::config()->site_key;
     $secretKey = self::config()->secret_key;
     if (empty($siteKey) || empty($secretKey)) {
         user_error('You must configure Nocaptcha.site_key and Nocaptcha.secret_key, you can retrieve these at https://google.com/recaptcha', E_USER_ERROR);
     }
     Requirements::javascript(NOCAPTCHA_BASE . '/javascript/NocaptchaField.js');
     Requirements::customScript("var _noCaptchaFields=_noCaptchaFields || [];_noCaptchaFields.push('" . $this->ID() . "');");
     Requirements::customScript("(function() {\n" . "    var gr = document.createElement('script'); gr.type = 'text/javascript'; gr.async = true;\n" . "    gr.src = ('https:' == document.location.protocol ? 'https://www' : 'http://www') + " . "'.google.com/recaptcha/api.js?render=explicit&hl=" . i18n::get_lang_from_locale(i18n::get_locale()) . "&onload=noCaptchaFieldRender';\n" . "    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gr, s);\n" . "})();\n", 'NocaptchaField-lib');
     return parent::Field($properties);
 }
开发者ID:helpfulrobot,项目名称:undefinedoffset-silverstripe-nocaptcha,代码行数:17,代码来源:NocaptchaField.php

示例9: __construct

 public function __construct($name, $title = null, $value = null)
 {
     parent::__construct($name, $title, $value);
     if ($this->getFileManager()) {
         FormExtraJquery::include_jquery();
     }
     Requirements::javascript(FORM_EXTRAS_PATH . '/javascript/tinymce/tinymce.min.js');
     $lang = i18n::get_lang_from_locale(i18n::get_locale());
     if ($lang != 'en') {
         Requirements::javascript(FORM_EXTRAS_PATH . '/javascript/tinymce/langs/' . $lang . '.js');
     }
 }
开发者ID:lekoala,项目名称:silverstripe-form-extras,代码行数:12,代码来源:SimpleTinyMceField.php

示例10: enable_custom_translations

 protected static function enable_custom_translations()
 {
     $locale = i18n::get_locale();
     $lang = i18n::get_lang_from_locale($locale);
     $profileDir = self::getProfileDir();
     $translators = array_reverse(i18n::get_translators(), true);
     // Make sure to include base translations
     i18n::include_by_locale($lang);
     foreach ($translators as $priority => $translators) {
         foreach ($translators as $name => $translator) {
             /* @var $adapter Zend_Translate_Adapter */
             $adapter = $translator->getAdapter();
             // Load translations from profile
             $filename = $adapter->getFilenameForLocale($lang);
             $filepath = Director::baseFolder() . "/mysite/lang/" . $profileDir . '/' . $filename;
             if ($filename && !file_exists($filepath)) {
                 continue;
             }
             $adapter->addTranslation(array('content' => $filepath, 'locale' => $lang));
         }
     }
 }
开发者ID:lekoala,项目名称:silverstripe-subsites-extras,代码行数:22,代码来源:SubsiteProfile.php

示例11: contentcontrollerInit

    public function contentcontrollerInit()
    {
        $useBrowserLanguage = Config::inst()->get('GoogleDirections', 'use_browser_language');
        if ($useBrowserLanguage) {
            Requirements::javascript("http://maps.google.com/maps/api/js?sensor=false");
        } else {
            $locale = i18n::get_locale();
            $language = i18n::get_lang_from_locale($locale);
            Requirements::javascript("http://maps.google.com/maps/api/js?sensor=false&language={$language}");
        }
        Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.min.js');
        Requirements::add_i18n_javascript(GOOGLEDIRECTIONS_BASE . '/javascript/lang');
        Requirements::javascript(GOOGLEDIRECTIONS_BASE . '/javascript/googledirections.js');
        Requirements::css(GOOGLEDIRECTIONS_BASE . '/css/googledirections.css');
        // Build a defaultmap if there is one defined
        $startupMap = $this->owner->GoogleMaps()->filter(array('ShowOnStartup' => true))->first();
        if ($startupMap) {
            $address = $startupMap->Address;
            $latlng = $startupMap->LatLng;
            $infoText = $startupMap->InfoText;
            $infoText = str_replace("", "''", $infoText);
            if ($address || $latlng) {
                Requirements::customScript(<<<JS
\t\t\t\t\t(function(\$) {
\t\t\t\t\t\t\$(document).ready(function() {
\t\t\t\t\t\t\tlocations.defaultMap = {
\t\t\t\t\t\t\t\tinfoText: '{$infoText}',
\t\t\t\t\t\t\t\taddress: '{$address}',
\t\t\t\t\t\t\t\tlatlng: '{$latlng}'
\t\t\t\t\t\t\t};
\t\t\t\t\t\t\tshowStartupMap('defaultMap');
\t\t\t\t\t\t});
\t\t\t\t\t}(jQuery));
JS
);
            }
        }
    }
开发者ID:helpfulrobot,项目名称:martimiz-silverstripe-googledirections,代码行数:38,代码来源:GoogleDirections.php

示例12: __construct

 public function __construct($arg1 = null, $arg2 = null)
 {
     if ($arg1 === null) {
         $arg1 = new TextField('StreetName', '');
         $arg1->setAttribute('placeholder', _t('GeoMemberExtension.STREETNAME'));
         $arg1->setAttribute('style', 'width:300px');
     }
     if ($arg2 === null) {
         $arg2 = new TextField('StreetNumber', '');
         $arg2->setAttribute('placeholder', _t('GeoMemberExtension.STREETNUMBER'));
         $arg2->setAttribute('style', 'width:75px');
     }
     $this->streetNameField = $arg1;
     $this->streetNumberField = $arg2;
     $lang = i18n::get_lang_from_locale(i18n::get_locale());
     if ($lang == 'fr') {
         parent::__construct($arg2, $arg1);
     } else {
         parent::__construct($arg1, $arg2);
     }
     $this->setTitle(_t('GeoMemberExtension.ADDRESSHEADER', 'Address'));
     $this->setFieldHolderTemplate('AddressFieldHolder');
 }
开发者ID:lekoala,项目名称:silverstripe-geotools,代码行数:23,代码来源:StreetField.php

示例13: get_silverstripe_language

function get_silverstripe_language()
{
    $locale = i18n::get_locale();
    if (class_exists('Fluent')) {
        $locale = Fluent::get_persist_locale();
    }
    $lang = i18n::get_lang_from_locale($locale);
    if ($lang == 'en') {
        return 'en_EN';
    }
    if ($lang == 'fr') {
        return 'fr_FR';
    }
    // Otherwise look in lang folder
    $ulocale = str_replace('-', '_', $locale);
    $lang_folder = dirname(__DIR__) . '/lang/';
    if (is_file($lang_folder . $lang . '.php')) {
        return $lang;
    }
    if (is_file($lang_folder . $ulocale . '.php')) {
        return $ulocale;
    }
    return 'en_EN';
}
开发者ID:lekoala,项目名称:silverstripe-form-extras,代码行数:24,代码来源:silverstripe-bridge.php

示例14: ShortLocale

 public function ShortLocale()
 {
     return i18n::get_lang_from_locale(i18n::get_locale());
 }
开发者ID:micschk,项目名称:silverstripe-liveseo,代码行数:4,代码来源:SeoSiteTreeExtension.php

示例15: add_i18n_javascript

 /**
  * Add i18n files from the given javascript directory. SilverStripe expects that the given
  * directory will contain a number of JavaScript files named by language: en_US.js, de_DE.js,
  * etc.
  *
  * @param string $langDir  The JavaScript lang directory, relative to the site root, e.g.,
  *                         'framework/javascript/lang'
  * @param bool   $return   Return all relative file paths rather than including them in
  *                         requirements
  * @param bool   $langOnly Only include language files, not the base libraries
  *
  * @return array
  */
 public function add_i18n_javascript($langDir, $return = false, $langOnly = false)
 {
     $files = array();
     $base = Director::baseFolder() . '/';
     if (i18n::config()->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 .= '/';
         }
         $candidates = array('en.js', 'en_US.js', i18n::get_lang_from_locale(i18n::default_locale()) . '.js', i18n::default_locale() . '.js', i18n::get_lang_from_locale(i18n::get_locale()) . '.js', i18n::get_locale() . '.js');
         foreach ($candidates as $candidate) {
             if (file_exists($base . DIRECTORY_SEPARATOR . $langDir . $candidate)) {
                 $files[] = $langDir . $candidate;
             }
         }
     } else {
         // Stub i18n implementation for when i18n is disabled.
         if (!$langOnly) {
             $files[] = FRAMEWORK_DIR . '/javascript/i18nx.js';
         }
     }
     if ($return) {
         return $files;
     } else {
         foreach ($files as $file) {
             $this->javascript($file);
         }
     }
 }
开发者ID:XDdesigners,项目名称:silverstripe-framework,代码行数:47,代码来源:Requirements.php


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