Example #1
1
 public function getErrors(Config $cfg)
 {
     $i18n = Localization::getTranslator();
     $walletSettings = [];
     $emailSettings = [];
     $providerClass = '';
     try {
         $provider = $cfg->getWalletProvider();
         $providerClass = get_class($provider);
         $provider->verifyOwnership();
     } catch (Exception $e) {
         if (strpos($providerClass, 'CoinbaseWallet') !== false) {
             $walletSettings[] = ['id' => '#wallet-coinbaseApiKey-error', 'error' => $e->getMessage()];
         } else {
             $walletSettings[] = ['id' => '#wallet-id-error', 'error' => $e->getMessage()];
         }
     }
     try {
         $t = new Swift_SmtpTransport('smtp.gmail.com', 465, 'ssl');
         $t->setUsername($cfg->getEmailUsername())->setPassword($cfg->getEmailPassword())->start();
     } catch (Exception $e) {
         $emailSettings[] = ['id' => '#email-username-error', 'error' => $e->getMessage()];
     }
     $errors = [];
     if (!empty($pricingSettings)) {
         $errors['#pricing-settings'] = self::getPricingErrorsFromConfig($cfg);
     }
     if (!empty($walletSettings)) {
         $errors['#wallet-settings'] = $walletSettings;
     }
     if (!empty($emailSettings)) {
         $errors['#email-settings'] = $emailSettings;
     }
     return $errors;
 }
function langA($name, $args)
{
    static $base = null;
    $value = Localization::instance()->lang($name);
    if (is_null($value)) {
        if (!Env::isDebugging()) {
            if (!$base instanceof Localization) {
                $base = new Localization();
                $base->loadSettings("en_us", ROOT . "/language");
            }
            $value = $base->lang($name);
        }
        if (is_null($value)) {
            $value = Localization::instance()->lang(str_replace(" ", "_", $name));
            if (is_null($value)) {
                $value = Localization::instance()->lang(str_replace("_", " ", $name));
                if (is_null($value)) {
                    return "Missing lang: {$name}";
                }
            }
        }
    }
    // We have args? Replace all {x} with arguments
    if (is_array($args) && count($args)) {
        $i = 0;
        foreach ($args as $arg) {
            $value = str_replace('{' . $i . '}', $arg, $value);
            $i++;
        }
        // foreach
    }
    // if
    // Done here...
    return $value;
}
Example #3
0
 /**
  * Performs character set and HTML character translations on the string.
  *
  * @access public
  * @param string       $string      required The string that is to be translated.
  * @param Localization $locale      required The locale object for doing the character set translation.
  * @param string       $toCharset   required Translate to this character set.
  * @param string       $fromCharset          Translate from this character set.
  * @return string The translated string.
  */
 public function translateCharacters($string, Localization $locale, $toCharset, $fromCharset = "UTF-8")
 {
     // perform character set translations on the string
     $string = $locale->translateCharset($string, $fromCharset, $toCharset);
     // perform HTML character translations on the string
     $string = from_html($string);
     return $string;
 }
 public function getLocale()
 {
     if (!isset($this->locale)) {
         $loc = new Localization();
         $this->locale = $loc->getCurrentLocale();
     }
     // if
     return $this->locale;
 }
Example #5
0
 public function testAssignedUserName()
 {
     global $locale;
     require_once 'include/Localization/Localization.php';
     $locale = new Localization();
     $testName = $locale->getLocaleFormattedName($this->user->first_name, $this->user->last_name);
     $testTemplate = new EmailTemplate();
     $testTemplate->retrieve($this->emailTemplate->id);
     $this->assertEquals($testName, $testTemplate->assigned_user_name, 'Assert that the assigned_user_name is the locale formatted name value');
 }
	private function build_original_mail_info($original_mail, $type = 'plain') {
		$loc = new Localization();
		$loc->setDateTimeFormat("D, d M Y H:i:s O");
		if ($type == 'plain') {
			$cc_cell = $original_mail->getCc() == '' ? '' : "\n".lang('mail CC').": ".$original_mail->getCc();
			$str = "\n\n----- ".lang('original message')."-----\n".lang('mail from').": ".$original_mail->getFrom()."\n".lang('mail to').": ".$original_mail->getTo()."$cc_cell\n".lang('mail sent').": ".$loc->formatDateTime($original_mail->getSentDate(), logged_user()->getTimezone())."\n".lang('mail subject').": ".$original_mail->getSubject()."\n\n";
		} else {
			$cc_cell = $original_mail->getCc() == '' ? '' : "<tr><td>".lang('mail CC').": ".$original_mail->getCc()."</td></tr>";
			$str = "<br><br><table><tr><td>----- ".lang('original message')." -----</td></tr><tr><td>".lang('mail from').": ".$original_mail->getFrom()."</td></tr><tr><td>".lang('mail to').": ".$original_mail->getTo()."</td></tr>$cc_cell<tr><td>".lang('mail sent').": ".$loc->formatDateTime($original_mail->getSentDate(), logged_user()->getTimezone())."</td></tr><tr><td>".lang('mail subject').": ".$original_mail->getSubject()."</td></tr></table><br>";
		}		 
		return $str;
	}
 public function view()
 {
     $locales = Localization::getAvailableInterfaceLanguageDescriptions();
     $this->set('LANGUAGE_CHOOSE_ON_LOGIN', Config::get('LANGUAGE_CHOOSE_ON_LOGIN'));
     $this->set('LANGUAGE_MULTILINGUAL_CONTENT_ENABLED', Config::get('LANGUAGE_MULTILINGUAL_CONTENT_ENABLED'));
     $this->set('interfacelocales', $locales);
 }
 /**
  * Renders the field
  *
  * @return string
  */
 function render()
 {
     $random_keys = array('name' => $this->field_id, 'latitude' => Helper::getRandomString(), 'longitude' => Helper::getRandomString());
     $values = array('name' => isset($this->field_data['name']) ? $this->field_data['name'] : '', 'latitude' => isset($this->field_data['latitude']) ? $this->field_data['latitude'] : '', 'longitude' => isset($this->field_data['longitude']) ? $this->field_data['longitude'] : '');
     $html = '<div class="map"';
     // add in per-field settings
     $settings = array();
     foreach ($this->field_config as $setting => $value) {
         if (!in_array($setting, $this->allowed_settings) || is_null($value)) {
             continue;
         }
         $settings[$setting] = $value;
     }
     // if we found something, add the configuration to the element
     if (count($settings)) {
         $html .= " data-location-configuration='" . json_encode($settings) . "'";
     }
     $html .= '></div>';
     $html .= '<div class="entry">';
     $html .= '	<div class="name">';
     $html .= '		<p>';
     $html .= Fieldtype::render_fieldtype('text', 'yaml][' . $this->field . '][name', array('display' => Localization::fetch('location_name')), $values['name'], NULL, NULL, $random_keys['name']);
     $html .= '		</p>';
     $html .= '	</div>';
     $html .= '	<div class="coordinates">';
     $html .= '		<p class="latitude">';
     $html .= Fieldtype::render_fieldtype('text', 'yaml][' . $this->field . '][latitude', array('display' => Localization::fetch('latitude')), $values['latitude'], NULL, NULL, $random_keys['latitude']);
     $html .= '		</p>';
     $html .= '		<p class="longitude">';
     $html .= Fieldtype::render_fieldtype('text', 'yaml][' . $this->field . '][longitude', array('display' => Localization::fetch('longitude')), $values['longitude'], NULL, NULL, $random_keys['longitude']);
     $html .= '		</p>';
     $html .= '	</div>';
     $html .= '</div>';
     return $html;
 }
Example #9
0
/**
 * Shortcut function for retrieving single lang value
 *
 * @access public
 * @param string $name
 * @return string
 */
function lang($name)
{
    // Get function arguments and remove first one.
    $args = func_get_args();
    if (is_array($args)) {
        array_shift($args);
    }
    // if
    // Get value and if we have NULL done!
    if (plugin_active('i18n')) {
        $value = lang_from_db($name);
    } else {
        $value = Localization::instance()->lang($name);
    }
    if (is_null($value)) {
        return $value;
    }
    // if
    // We have args? Replace all %s with arguments
    if (is_array($args) && count($args)) {
        foreach ($args as $arg) {
            $value = str_replace_first('%s', $arg, $value);
        }
        // foreach
    }
    // if
    // Done here...
    return $value;
}
Example #10
0
	public function do_update($pkgHandle = false) {
		$tp = new TaskPermission();
		if ($tp->canInstallPackages()) { 
			if ($pkgHandle) {
				$tests = Package::testForInstall($pkgHandle, false);
				if (is_array($tests)) {
					$tests = Package::mapError($tests);
					$this->set('error', $tests);
				} else {
					$p = Package::getByHandle($pkgHandle);
					$currentLocale = Localization::activeLocale();
					if ($currentLocale != 'en_US') {
						// Prevent the database records being stored in wrong language
						Localization::changeLocale('en_US');
					}
					try {
						$p->upgradeCoreData();
						if ($currentLocale != 'en_US') {
							Localization::changeLocale($currentLocale);
						}
						$p->upgrade();
						$this->set('message', t('The package has been updated successfully.'));
					} catch(Exception $e) {
						$this->set('error', $e);
					}
				}
			}
		}
		$this->view();
	}
Example #11
0
 public function __construct($page, $comment_id, $type = 0)
 {
     $this->_localization = Localization::getInstance();
     $this->type = $type;
     $this->page = $page;
     $this->comment_id = $comment_id;
     $this->form_values['comment_text'] = isset($_POST['comment_text']) ? htmlspecialchars($_POST['comment_text']) : '';
     $this->form_values['name'] = isset($_POST['name']) ? htmlspecialchars($_POST['name']) : '';
     $this->form_values['email_hp'] = isset($_POST['email_hp']) ? htmlspecialchars($_POST['email_hp']) : '';
     $this->_form_session = 'comment_form_session_' . $this->comment_id . '_' . $this->type;
     if ($this->type == 1) {
         if (isset($_GET['get_5'])) {
             $this->current_page = intval($_GET['get_5']);
         } else {
             $this->current_page = 1;
         }
     } else {
         if (isset($_GET['get_1'])) {
             $this->current_page = intval($_GET['get_1']);
         } else {
             $this->current_page = 1;
         }
     }
     if ($this->current_page == 0) {
         $this->current_page = 1;
     }
     if (isset($_SESSION[$this->_form_session])) {
         $this->form_session = $_SESSION[$this->_form_session];
         $form_session_data['name'] = session_name();
         $form_session_data['id'] = session_id();
         $this->form_session_data = $form_session_data;
     }
 }
Example #12
0
 public function view()
 {
     $this->requireAsset('javascript', 'jquery');
     $ml = Section::getList();
     $c = \Page::getCurrentPage();
     $al = Section::getBySectionOfSite($c);
     $languages = [];
     $locale = null;
     if ($al !== null) {
         $locale = $al->getLanguage();
     }
     if (!$locale) {
         $locale = \Localization::activeLocale();
         $al = Section::getByLocale($locale);
     }
     foreach ($ml as $m) {
         $languages[$m->getCollectionID()] = $m->getLanguageText($m->getLocale());
     }
     $this->set('languages', $languages);
     $this->set('languageSections', $ml);
     $this->set('activeLanguage', $al ? $al->getCollectionID() : null);
     $dl = $this->app->make('multilingual/detector');
     $this->set('defaultLocale', $dl->getPreferredSection());
     $this->set('locale', $locale);
     $this->set('cID', $c->getCollectionID());
 }
Example #13
0
	protected function testAndRunInstall() {
		if (file_exists(DIR_CONFIG_SITE . '/site_install_user.php')) {
			require(DIR_CONFIG_SITE . '/site_install.php');
			@include(DIR_CONFIG_SITE . '/site_install_user.php');
			if (defined('ACTIVE_LOCALE') && Localization::activeLocale() !== ACTIVE_LOCALE) {
				Localization::changeLocale(ACTIVE_LOCALE);
			}
			$e = Loader::helper('validation/error');
			$e = $this->validateDatabase($e);
			if ($e->has()) {
				$this->set('error', $e);
			} else {
				$this->addHeaderItem(Loader::helper('html')->css('jquery.ui.css'));
				$this->addHeaderItem(Loader::helper('html')->javascript('jquery.ui.js'));
				if (defined('INSTALL_STARTING_POINT') && INSTALL_STARTING_POINT) { 
					$spl = Loader::startingPointPackage(INSTALL_STARTING_POINT);
				} else {
					$spl = Loader::startingPointPackage('standard');
				}
				$this->set('installPackage', $spl->getPackageHandle());
				$this->set('installRoutines', $spl->getInstallRoutines());
				$this->set('successMessage', t('Congratulations. concrete5 has been installed. You have been logged in as <b>%s</b> with the password you chose. If you wish to change this password, you may do so from the users area of the dashboard.', USER_SUPER, $uPassword));
			}
		}
	}
Example #14
0
 public static function setupSiteInterfaceLocalization(Page $c = null)
 {
     if (\User::isLoggedIn() && Config::get('concrete.multilingual.keep_users_locale')) {
         return;
     }
     if (!$c) {
         $c = Page::getCurrentPage();
     }
     // don't translate dashboard pages
     $dh = \Core::make('helper/concrete/dashboard');
     if ($dh->inDashboard($c)) {
         return;
     }
     $ms = Section::getBySectionOfSite($c);
     if (!is_object($ms)) {
         $ms = static::getPreferredSection();
     }
     if (!$ms) {
         return;
     }
     $locale = $ms->getLocale();
     if (strlen($locale)) {
         \Localization::changeLocale($locale);
     }
 }
Example #15
0
 public function render()
 {
     // Let's make sure they set an upload destination
     if (array_get($this->field_config, 'destination', false) === false) {
         throw new Exception("You need to set a destination for your File field.");
     }
     if ($this->field_data) {
         $file = Path::toAsset($this->field_data);
         $html = "<div class='file-field-container file-exists'>";
         $html .= "<div>";
         if (File::isImage(Path::fromAsset($this->field_data, true))) {
             $html .= "<img src='{$file}' height='58'>";
         }
         $html .= "<p>" . basename($this->field_data) . "</p>";
         $html .= "<a class='btn btn-small btn-remove-file' href='#'>" . Localization::fetch('remove') . "</a>";
         $html .= "</div>";
         $html .= $this->makeFileSelect($file);
     } else {
         $html = "<div class='file-field-container'>";
         $html .= "<div class='upload-file'>";
         $html .= "<p><input type='file' name='{$this->fieldname}' tabindex='{$this->tabindex}' value='' /></p>";
         $html .= $this->makeFileSelect();
         $html .= "</div>";
     }
     $html .= "</div>";
     return $html;
 }
 public function on_start()
 {
     $this->error = Loader::helper('validation/error');
     if (USER_REGISTRATION_WITH_EMAIL_ADDRESS == true) {
         $this->set('uNameLabel', t('Email Address'));
     } else {
         $this->set('uNameLabel', t('Username'));
     }
     $txt = Loader::helper('text');
     if (strlen($_GET['uName'])) {
         // pre-populate the username if supplied, if its an email address with special characters the email needs to be urlencoded first,
         $this->set("uName", trim($txt->email($_GET['uName'])));
     }
     $languages = array();
     $locales = array();
     if (Config::get('LANGUAGE_CHOOSE_ON_LOGIN')) {
         Loader::library('3rdparty/Zend/Locale');
         Loader::library('3rdparty/Zend/Locale/Data');
         $languages = Localization::getAvailableInterfaceLanguages();
         if (count($languages) > 0) {
             array_unshift($languages, 'en_US');
         }
         $locales = array('' => t('** Default'));
         Zend_Locale_Data::setCache(Cache::getLibrary());
         foreach ($languages as $lang) {
             $loc = new Zend_Locale($lang);
             $locales[$lang] = Zend_Locale::getTranslation($loc->getLanguage(), 'language', ACTIVE_LOCALE);
         }
     }
     $this->locales = $locales;
     $this->set('locales', $locales);
     $this->openIDReturnTo = BASE_URL . View::url("/login", "complete_openid");
 }
Example #17
0
 public function filterByKeywords($kw)
 {
     static $reverseLookup = array();
     $db = Loader::db();
     $locale = Localization::activeLocale();
     if (!array_key_exists($locale, $reverseLookup)) {
         $reverseLookup[$locale] = false;
         if (Localization::activeLocale() != 'en_US' || ENABLE_TRANSLATE_LOCALE_EN_US) {
             $limit = defined('GROUPNAME_REVERSELOOKUP_LIMIT') ? GROUPNAME_REVERSELOOKUP_LIMIT : 100;
             $count = $db->GetOne('select count(*) from Groups');
             if ($count > 0 && $count <= $limit) {
                 $reverseLookup[$locale] = array();
                 $rs = $db->Query('select gID, gName, gDescription from Groups');
                 while ($row = $rs->FetchRow()) {
                     $reverseLookup[$locale][$row['gID']] = array('name' => tc('GroupName', $row['gName']), 'description' => tc('GroupDescription', $row['gDescription']));
                 }
                 $rs->Close();
             }
         }
     }
     if ($reverseLookup[$locale]) {
         $foundIDs = array();
         foreach ($reverseLookup[$locale] as $gID => $gTranslated) {
             if (stripos($gTranslated['name'], $kw) !== false || stripos($gTranslated['description'], $kw) !== false) {
                 $foundIDs[] = $gID;
             }
         }
         if (count($foundIDs)) {
             $this->filter(false, '(Groups.gID in (' . implode(', ', $foundIDs) . '))');
             return;
         }
     }
     $this->filter(false, "(Groups.gName like " . $db->qstr('%' . $kw . '%') . " or Groups.gDescription like " . $db->qstr('%' . $kw . '%') . ")");
 }
Example #18
0
 public function send($lastOverride = false)
 {
     $i18n = Localization::getTranslator();
     $lastFn = '/home/pi/phplog/last-tx-sent';
     $last = 0;
     if (file_exists($lastFn)) {
         $last = intval(trim(file_get_contents($lastFn)));
     }
     if ($lastOverride !== false) {
         $last = $lastOverride;
     }
     $csvMaker = Container::dispense('TransactionCSV');
     $config = Admin::volatileLoad()->getConfig();
     $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')->setUsername($config->getEmailUsername())->setPassword($config->getEmailPassword());
     $msg = Swift_Message::newInstance()->setSubject($config->getMachineName() . $i18n->_(': Transaction Log'))->setFrom([$config->getEmailUsername() => $config->getMachineName()])->setTo(array($config->getEmailUsername()))->setBody($i18n->_('See attached for transaction log.'));
     $file = $csvMaker->save($last);
     if (!$file) {
         throw new Exception('Unable to save CSV');
     }
     $msg->attach(Swift_Attachment::fromPath($file));
     file_put_contents($lastFn, $csvMaker->getLastID());
     $mailer = Swift_Mailer::newInstance($transport);
     if (!$mailer->send($msg)) {
         throw new Exception('Unable to send: unkown cause');
     }
 }
 public function control_panel__add_routes()
 {
     $app = \Slim\Slim::getInstance();
     $app->get('/globes', function () use($app) {
         authenticateForRole('admin');
         doStatamicVersionCheck($app);
         Statamic_View::set_templates(array('globes-overview'), __DIR__ . '/templates');
         $data = $this->tasks->getThemeSettings();
         $app->render(null, array('route' => 'globes', 'app' => $app) + $data);
     })->name('globes');
     // Update global vars
     $app->post('/globes/update', function () use($app) {
         authenticateForRole('admin');
         doStatamicVersionCheck($app);
         $data = $this->tasks->getThemeSettings();
         $vars = Request::fetch('pageglobals');
         foreach ($vars as $name => $var) {
             foreach ($data['globals'] as $key => $item) {
                 if ($item['name'] === $name) {
                     $data['globals'][$key]['value'] = $var;
                 }
             }
         }
         File::put($this->tasks->getThemeSettingsPath(), YAML::dump($data, 1));
         $app->flash('success', Localization::fetch('update_success'));
         $app->redirect($app->urlFor('globes'));
     });
 }
 public function getMembers()
 {
     // get locale
     $locale = \Localization::activeLocale();
     $c = $this->getCollectionObject();
     if (is_object($c)) {
         $al = Section::getBySectionOfSite($c);
         if (is_object($al)) {
             $locale = $al->getLocale();
         }
     }
     // fix for sorting
     if ($locale == 'en_US') {
         $locale = 'en';
     }
     $params = array('limit' => 100, 'member_of' => $this->parentId, 'sort' => '1058', 'l' => $locale);
     // build URL with params
     $uh = \Core::make('helper/url');
     $url = \Config::get('worldskills.api_url', 'https://api.worldskills.org') . '/org/members';
     $url = $uh->buildQuery($url, $params);
     // fetch JSON
     $data = \Core::make("helper/file")->getContents($url);
     $data = json_decode($data, true);
     return $data;
 }
 public function deliverQueryObject()
 {
     $query = parent::deliverQueryObject();
     $u = new User();
     if ($u->isLoggedIn()) {
         $uID = $u->getUserID();
     } else {
         $uID = -1;
     }
     if ($uID != -1) {
         // $query->leftJoin('p', 'UserPageFavorites', 'fav', 'p.cID = fav.cID');
         // $query->addSelect('fav.uID IS NOT NULL as favorite');
         // $query->leftJoin('p', 'UserPageFavorites', 'fav', 'p.pID = fav.pID and fav.uID = '.(int)$u->getUserID());
         $relation = Database::get()->createQueryBuilder();
         $relation->select('mpRelationID')->from('MultilingualPageRelations', 'mppr')->leftJoin('mppr', 'UserPageFavorites', 'fav', 'mppr.CID = fav.cID WHERE fav.uID = :uID')->setParameter('uID', (int) $uID);
         //     // ->
         // andWhere('fav.uID = :uID');
         $query->leftJoin('p', 'MultilingualPageRelations', 'mmpr2', 'p.cID = mmpr2.cID');
         $query->addSelect('mmpr2.mpRelationID');
         // $query->andWhere("mmpr2.mpRelationID in (" . $relation . ")");
         $query->addSelect(' mmpr2.mpRelationID in (' . $relation . ') as favorite');
         $query->andWhere("mmpr2.mpLocale = :loc");
         $query->setParameter('uID', (int) $uID);
         $query->setParameter('loc', \Localization::activeLocale());
         if ($this->onlyFavorites) {
             // Does this slow the query or what
             $query->andWhere('mmpr2.mpRelationID in (' . $relation . ')');
         }
         // var_dump(\Localization::activeLocale());
         // echo $query->getSql();
     }
     return $query;
 }
Example #22
0
 public static function setupSiteInterfaceLocalization(Page $c = null)
 {
     $loc = \Localization::getInstance();
     if (!(\User::isLoggedIn() && Config::get('concrete.multilingual.keep_users_locale'))) {
         if (!$c) {
             $c = Page::getCurrentPage();
         }
         // don't translate dashboard pages
         $dh = \Core::make('helper/concrete/dashboard');
         if ($dh->inDashboard($c)) {
             return;
         }
         $locale = null;
         $ms = Section::getBySectionOfSite($c);
         if ($ms) {
             $locale = $ms->getLocale();
         }
         if (!$locale) {
             if (Config::get('concrete.multilingual.use_previous_locale') && Session::has('previous_locale')) {
                 $locale = Session::get('previous_locale');
             }
             if (!$locale) {
                 $ms = static::getPreferredSection();
                 if ($ms) {
                     $locale = $ms->getLocale();
                 }
             }
         }
         if ($locale) {
             $loc->setLocale($locale);
         }
     }
     Session::set('previous_locale', $loc->getLocale());
 }
Example #23
0
 function testFill_in_additional_detail_fields()
 {
     $locale = new Localization();
     $this->c->fill_in_additional_detail_fields();
     $localName = $locale->getLocaleFormattedName('testfirst', 'testlast');
     $this->assertEquals($this->c->name, $localName);
     //$this->assertEquals($this->c->name, 'testfirst testlast');
 }
Example #24
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     \Localization::setLocale('id');
     if (Schema::hasTable('top_menu')) {
         $top_menu = TopMenu::all()->sortBy('urutan');
         view()->share('top_menu', $top_menu);
     }
 }
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         $class = __CLASS__;
         self::$instance = new $class();
     }
     return self::$instance;
 }
Example #26
0
 /**
  * Imports symbol table into template file's execution context, rendering
  * as the file dictates
  *
  * @param array $symbols to import
  * @return void
  */
 public function render(array $symbols = array())
 {
     extract($symbols);
     unset($symbols);
     $html = new HTML();
     $i18n = Localization::getTranslator();
     include $this->getPage();
 }
 public function __construct()
 {
     Loader::library('3rdparty/Zend/Locale');
     $countries = Zend_Locale::getTranslationList('territory', Localization::activeLocale(), 2);
     // unset invalid countries
     unset($countries['SU'], $countries['ZZ'], $countries['IM'], $countries['JE'], $countries['VD']);
     asort($countries, SORT_LOCALE_STRING);
     $this->countries = $countries;
 }
Example #28
0
 /** Returns the Zend_Locale instance for the current locale.
  * @return Zend_Locale
  */
 protected function getZendLocale()
 {
     static $zl;
     $locale = Localization::activeLocale();
     if (!isset($zl) || $locale != $zl->toString()) {
         $zl = new Zend_Locale($locale);
     }
     return $zl;
 }
Example #29
0
 public static function Localize($name, $identifier)
 {
     $locale = Localization::Get($name);
     for ($i = 0; $i < count(self::$_preferred); $i++) {
         $lang = self::$_preferred[$i];
         if ($locale->{$identifier}->{$lang}) {
             return $locale->{$identifier}->{$lang};
         }
     }
 }
Example #30
0
function locale($locale = null, $return = FALSE)
{
    if (count(func_get_args())) {
        $lang = load_locale($locale, $return);
        Localization::$active_locale = $locale;
        return $lang;
    } else {
        return Localization::$active_locale;
    }
}