/**
  * @return string Returns the CKEditor language configuration
  */
 protected function getLanguageOption()
 {
     $langPath = DIR_BASE . '/' . DIRNAME_PACKAGES . '/community_ckeditor/vendor/ckeditor/lang/';
     $useLanguage = 'en';
     $language = strtolower(str_replace('_', '-', Localization::activeLocale()));
     if (file_exists($langPath . $language . '.js')) {
         $useLanguage = $language;
     } elseif (file_exists($langPath . strtolower(Localization::activeLanguage()) . '.js')) {
         $useLanguage = strtolower(Localization::activeLanguage());
     }
     return $useLanguage;
 }
<?php

use Concrete\Core\Localization\Localization;
header('Content-type: text/javascript; charset=UTF-8');
$locale = str_replace('_', '-', Localization::activeLocale());
if ($locale === 'en-US') {
    echo '// No needs to translate ' . $locale;
} else {
    $language = Localization::activeLanguage();
    $alternatives = array($locale);
    if (strcmp($locale, $language) !== 0) {
        $alternatives[] = $language;
    }
    $content = false;
    foreach ($alternatives as $alternative) {
        $path = DIR_BASE_CORE . '/' . DIRNAME_JAVASCRIPT . "/i18n/select2_locale_{$alternative}.js";
        if (is_file($path) && is_readable($path)) {
            $content = @file_get_contents($path);
            if (is_string($content)) {
                break;
            }
        }
    }
    if (is_string($content)) {
        echo $content;
    } else {
        echo '// No select2 translations for ' . implode(', ', $alternatives);
    }
}
Esempio n. 3
0
 public function setup()
 {
     $config = $this->app['config'];
     $passwordMinLength = (int) $config->get('concrete.user.password.minimum', 5);
     $passwordMaxLength = (int) $config->get('concrete.user.password.maximum');
     $passwordAttributes = ['autocomplete' => 'off'];
     if ($passwordMinLength > 0) {
         $passwordAttributes['required'] = 'required';
         if ($passwordMaxLength > 0) {
             $passwordAttributes['placeholder'] = t('Between %1$s and %2$s Characters', $passwordMinLength, $passwordMaxLength);
             $passwordAttributes['pattern'] = '.{' . $passwordMinLength . ',' . $passwordMaxLength . '}';
         } else {
             $passwordAttributes['placeholder'] = t('at least %s characters', $passwordMinLength);
             $passwordAttributes['pattern'] = '.{' . $passwordMinLength . ',}';
         }
     } elseif ($passwordMaxLength > 0) {
         $passwordAttributes['placeholder'] = t('up to %s characters', $passwordMaxLength);
         $passwordAttributes['pattern'] = '.{0,' . $passwordMaxLength . '}';
     }
     $this->set('passwordAttributes', $passwordAttributes);
     $canonicalUrl = '';
     $canonicalUrlChecked = false;
     $canonicalSSLUrl = '';
     $canonicalSSLUrlChecked = false;
     $uri = $this->request->getUri();
     if (preg_match('/^(https?)(:.+?)(?:\\/' . preg_quote(DISPATCHER_FILENAME, '%') . ')?\\/install(?:$|\\/|\\?)/i', $uri, $m)) {
         $canonicalUrl = 'http' . rtrim($m[2], '/');
         $canonicalSSLUrl = 'https' . rtrim($m[2], '/');
         /*switch (strtolower($m[1])) {
               case 'http':
                   $canonicalUrlChecked = true;
                   break;
               case 'http':
                   $canonicalSSLUrlChecked = true;
                   break;
           }*/
     }
     $countries = array();
     $ll = $this->app->make('localization/languages');
     $cl = $this->app->make('lists/countries');
     $computedSiteLocaleLanguage = Localization::activeLanguage();
     $computedSiteLocaleCountry = null;
     $recommendedCountryValues = $cl->getCountriesForLanguage($computedSiteLocaleLanguage);
     $otherCountries = array();
     foreach ($cl->getCountries() as $code => $country) {
         if (!in_array($code, $recommendedCountryValues)) {
             $otherCountries[$code] = $country;
         }
     }
     $recommendedCountries = array();
     foreach ($recommendedCountryValues as $country) {
         if (!$computedSiteLocaleCountry) {
             $computedSiteLocaleCountry = $country;
         }
         $recommendedCountries[$country] = $cl->getCountryName($country);
     }
     $languages = $ll->getLanguageList();
     $this->set('languages', $languages);
     $this->set('countries', $countries);
     $this->set('computedSiteLocaleLanguage', $computedSiteLocaleLanguage);
     $this->set('computedSiteLocaleCountry', $computedSiteLocaleCountry);
     $this->set('recommendedCountries', $recommendedCountries);
     $this->set('otherCountries', $otherCountries);
     $this->set('setInitialState', $this->request->post('SITE') === null);
     $this->set('canonicalUrl', $canonicalUrl);
     $this->set('canonicalUrlChecked', $canonicalUrlChecked);
     $this->set('canonicalSSLUrl', $canonicalSSLUrl);
     $this->set('canonicalSSLUrlChecked', $canonicalSSLUrlChecked);
 }
 public static function getJQueryUIJavascript($setResponseHeaders = true)
 {
     if ($setResponseHeaders) {
         static::sendJavascriptHeader();
     }
     $env = Environment::get();
     /* @var $env \Concrete\Core\Foundation\Environment */
     $alternatives = array(Localization::activeLocale());
     if (Localization::activeLocale() !== Localization::activeLanguage()) {
         $alternatives[] = Localization::activeLanguage();
     }
     $found = null;
     foreach ($alternatives as $alternative) {
         $r = $env->getRecord(DIRNAME_JAVASCRIPT . '/i18n/ui.datepicker-' . str_replace('_', '-', $alternative) . '.js');
         if (is_file($r->file)) {
             $found = $r->file;
             break;
         }
     }
     if (isset($found)) {
         readfile($found);
     } else {
         echo '// No jQueryUI translations for ' . Localization::activeLocale();
     }
 }