コード例 #1
0
ファイル: subpage.php プロジェクト: krishnasrikanth/smvc-php7
<?php

/**
 * Sample layout
 */
use Core\Locale;
?>

<div class="page-header">
	<h1><?php 
echo $data['title'];
?>
</h1>
</div>

<p><?php 
echo $data['welcome_message'];
?>
</p>

<a class="btn btn-md btn-success" href="<?php 
echo DIR;
?>
">
	<?php 
echo Locale::show('back_home', 'Welcome');
?>
</a>
コード例 #2
0
ファイル: welcome.php プロジェクト: krishnasrikanth/smvc-php7
<div class="page-header">
	<h1><?php 
echo $data['title'];
?>
</h1>
</div>

<p><?php 
echo $data['welcome_message'];
?>
</p>

<a class="btn btn-md btn-success" href="<?php 
echo DIR;
?>
/welcome/subpage">
	<?php 
echo Locale::show('open_subpage', 'Welcome');
?>
</a>

<a class="btn btn-md btn-info" href="<?php 
echo DIR;
?>
/test/module-controller">
<?php 
echo Locale::show('open_modulepage', 'Welcome');
?>
</a>
コード例 #3
0
ファイル: Bootstrap.php プロジェクト: biggtfish/cms
 /**
  * Init locale.
  *
  * @param DI     $di     Dependency injection.
  * @param Config $config Dependency injection.
  *
  * @return void
  */
 protected function _initI18n(DI $di, Config $config)
 {
     if ($di->get('app')->isConsole()) {
         return;
     }
     $languageObject = null;
     if (!$di->get('session')->has('language')) {
         /** @var Language $languageObject */
         if ($config->installed) {
             $language = Settings::getSetting('system_default_language');
             if ($language == 'auto') {
                 $locale = \Locale::acceptFromHttp($_SERVER["HTTP_ACCEPT_LANGUAGE"]);
                 $languageObject = Language::findFirst("language = '" . $locale . "' OR locale = '" . $locale . "'");
             } else {
                 $languageObject = Language::findFirst("language = '" . $language . "'");
             }
         }
         if ($languageObject) {
             $di->get('session')->set('language', $languageObject->language);
             $di->get('session')->set('locale', $languageObject->locale);
         } else {
             $di->get('session')->set('language', Config::CONFIG_DEFAULT_LANGUAGE);
             $di->get('session')->set('locale', Config::CONFIG_DEFAULT_LOCALE);
         }
     }
     $language = $di->get('session')->get('language');
     $translate = null;
     if (!$config->application->debug || !$config->installed) {
         $messages = [];
         $directory = $config->application->languages->cacheDir;
         $extension = ".php";
         if (file_exists($directory . $language . $extension)) {
             require $directory . $language . $extension;
         } else {
             if (file_exists($directory . Config::CONFIG_DEFAULT_LANGUAGE . $extension)) {
                 // fallback to default
                 require $directory . Config::CONFIG_DEFAULT_LANGUAGE . $extension;
             }
         }
         $translate = new TranslateArray(["content" => $messages]);
     } else {
         if (!$languageObject) {
             $languageObject = Language::findFirst(['conditions' => 'language = :language:', 'bind' => ["language" => $language]]);
             if (!$languageObject) {
                 $languageObject = Language::findFirst("language = '" . Config::CONFIG_DEFAULT_LANGUAGE . "'");
             }
         }
         $translate = new TranslationDb($di, $languageObject->getId(), new LanguageTranslation());
     }
     $di->set('i18n', $translate);
 }
コード例 #4
0
ファイル: index.php プロジェクト: krishnasrikanth/smvc-php7
<?php

/**
 * Sample layout
 */
use Core\Locale;
?>

<div class="page-header">
	<h1>Sub folder called</h1>
</div>

<p><?php 
echo $data['welcome_message'];
?>
</p>

<a class="btn btn-md btn-success" href="<?php 
echo DIR;
?>
subpage">
	<?php 
echo Locale::show('open_subpage', 'Welcome');
?>
</a>