Ejemplo n.º 1
0
 /**
  * Return associative array of all locales supported by the site.
  * These locales are used to provide a language toggle on the main site pages.
  * @return array
  */
 function &getSupportedLocaleNames()
 {
     $supportedLocales =& Registry::get('siteSupportedLocales', true, null);
     if ($supportedLocales === null) {
         $supportedLocales = array();
         $localeNames =& AppLocale::getAllLocales();
         $locales = $this->getSupportedLocales();
         foreach ($locales as $localeKey) {
             $supportedLocales[$localeKey] = $localeNames[$localeKey];
         }
         asort($supportedLocales);
     }
     import('helpers.LocaleHelper');
     $supportedLocales = LocaleHelper::sortZhTwFirst($supportedLocales);
     return $supportedLocales;
 }
Ejemplo n.º 2
0
 /**
  * @dataProvider toLanguages
  */
 public function testToLanguage($locale, $lang)
 {
     $this->assertEquals($lang, LocaleHelper::toLanguage($locale));
 }
Ejemplo n.º 3
0
<?php

Route::group(['middleware' => ['web']], function () {
    foreach (array_merge([''], ClientHelper::getValidLocales()) as $locale) {
        Route::group(['middleware' => ['localization'], 'prefix' => $locale . '/api', 'namespace' => 'AlistairShaw\\Vendirun\\App\\Http\\Controllers\\Api'], function () use($locale) {
            $localePrefix = $locale ? $locale . '.' : '';
            Route::get('/', ['as' => $localePrefix . 'vendirun.api.base', 'uses' => 'HomeController@index']);
            Route::get('cart/calculate', ['as' => $localePrefix . 'vendirun.api.cart.calculate', 'uses' => 'CartController@calculate']);
            Route::post('cart/add', ['as' => $localePrefix . 'vendirun.api.cart.add', 'uses' => 'CartController@add']);
            Route::post('cart/remove', ['as' => $localePrefix . 'vendirun.api.cart.remove', 'uses' => 'CartController@remove']);
            Route::get('product/{productId}', ['as' => $localePrefix . 'vendirun.api.product.find', 'uses' => 'ProductController@find']);
        });
    }
});
Route::group(['middleware' => ['web']], function () {
    foreach (array_merge([''], LocaleHelper::validLocales()) as $locale) {
        Route::group(['middleware' => ['localization'], 'prefix' => $locale, 'namespace' => 'AlistairShaw\\Vendirun\\App\\Http\\Controllers'], function () use($locale) {
            $localePrefix = $locale ? $locale . '.' : '';
            Route::group(['prefix' => 'property'], function () use($localePrefix) {
                Route::any('/', ['as' => $localePrefix . 'vendirun.propertySearch', 'uses' => 'Property\\PropertyController@index']);
                Route::any('/xml', ['as' => $localePrefix . 'vendirun.propertyXml', 'uses' => 'Property\\PropertyController@xml']);
                Route::get('view/{id}/{propertyName?}', ['as' => $localePrefix . 'vendirun.propertyView', 'uses' => 'Property\\PropertyController@propertyView']);
                Route::get('clear-search', ['as' => $localePrefix . 'vendirun.propertyClearSearch', 'uses' => 'Property\\PropertyController@clearSearch']);
                Route::get('search', ['as' => $localePrefix . 'vendirun.searchProperties', 'uses' => 'Property\\PropertyController@search']);
                Route::get('category/{categoryName?}', ['as' => $localePrefix . 'vendirun.category', 'uses' => 'Property\\CategoryController@index']);
                Route::get('location/{locationName?}', ['as' => $localePrefix . 'vendirun.location', 'uses' => 'Property\\LocationController@index']);
                Route::get('property/recommend/{propertyId}', ['as' => $localePrefix . 'vendirun.propertyRecommend', 'uses' => 'Property\\PropertyController@recommend']);
                // require user to be logged in
                Route::get('add-to-favourite/{id}', ['as' => $localePrefix . 'vendirun.propertyAddToFav', 'uses' => 'Property\\PropertyAuthController@addToFavourite']);
                Route::get('remove-favourite/{id}', ['as' => $localePrefix . 'vendirun.propertyRemoveFav', 'uses' => 'Property\\PropertyAuthController@RemoveFavourite']);
                Route::get('view-favourite-properties', ['as' => $localePrefix . 'vendirun.viewFavouriteProperties', 'uses' => 'Property\\PropertyAuthController@viewFavouriteProperties']);
Ejemplo n.º 4
0
 /**
  * Return associative array of all locales supported by the site.
  * These locales are used to provide a language toggle on the main site pages.
  * @return array
  */
 function &getSupportedLocaleNames()
 {
     static $supportedLocales;
     if (!isset($supportedLocales)) {
         $supportedLocales = array();
         $localeNames =& AppLocale::getAllLocales();
         $locales = $this->getSetting('supportedLocales');
         if (!isset($locales) || !is_array($locales)) {
             $locales = array();
         }
         foreach ($locales as $localeKey) {
             $supportedLocales[$localeKey] = $localeNames[$localeKey];
         }
     }
     import('helpers.LocaleHelper');
     $supportedLocales = LocaleHelper::sortZhTwFirst($supportedLocales);
     return $supportedLocales;
 }