コード例 #1
0
ファイル: LangTest.php プロジェクト: hyrmedia/microweber
 public function testLang()
 {
     $current_lang = current_lang();
     set_current_lang('bg');
     $new_current_lang = current_lang();
     $this->assertEquals('en', $current_lang);
     $this->assertEquals('bg', $new_current_lang);
     $lang_string_test = _e("Select country", true);
     $this->assertEquals('Избери държава', $lang_string_test);
 }
コード例 #2
0
 public function boot(Request $request)
 {
     parent::boot();
     // public = /
     App::instance('path.public', base_path());
     Cache::extend('file', function ($app) {
         return new Utils\Adapters\Cache\CacheStore();
     });
     // If installed load module functions and set locale
     if (mw_is_installed()) {
         $modules = load_all_functions_files_for_modules();
         $this->commands('Microweber\\Commands\\OptionCommand');
         $language = get_option('language', 'website');
         if ($language != false) {
             set_current_lang($language);
         }
         if ($this->app->runningInConsole()) {
             $this->commands('Microweber\\Commands\\UpdateCommand');
         }
     } else {
         // Otherwise register the install command
         $this->commands('Microweber\\Commands\\InstallCommand');
     }
     // Register routes
     $this->registerRoutes();
 }
コード例 #3
0
ファイル: lang.php プロジェクト: microweber/microweber
/**
 * Get the current language of the site.
 *
 * @example
 * <code>
 *  $current_lang = current_lang();
 *  print $current_lang;
 * </code>
 */
function current_lang()
{
    $app_locale = App::getLocale();
    if (isset($_COOKIE['lang']) and $_COOKIE['lang'] != false) {
        $lang = $_COOKIE['lang'];
        if ($lang != $app_locale) {
            set_current_lang($lang);
            $app_locale = App::getLocale();
        }
    }
    return $app_locale;
}