diff --git a/config.php b/config.php index fbd7a076440cb5db44ee112ee6c22e58571605e3..05cbf56407cba4ed7a2b316bc83b949e0e989f3a 100644 --- a/config.php +++ b/config.php @@ -16,14 +16,55 @@ $legalNotice = /* ====== i18n ====== */ +function checkAvailableLanguages ($langList) { + + foreach ($langList as $k => $v) { + + $loc = setlocale(LC_ALL, $langList[$k]['folder'], ($langList[$k]['folder'] . '.utf8')); + + if ($loc === false) { + + $langList[$k] = NULL; + + } else { + + $langList[$k]['localeCode'] = $loc; + } + } + + return $langList; +} + $availableLanguages = [ - 'fr', - 'en', - 'es', - 'va' + 'fr' => [ + 'name' => 'français', + 'folder' => 'fr_FR' + ], + 'en' => [ + 'name' => 'english', + 'folder' => 'fr_FR' + ], + 'es' => [ + 'name' => 'español', + 'folder' => 'es_ES' + ], + 'va' => [ + 'name' => 'valyrio', + 'folder' => 'en_US' + ], + /* + 'it' => [ + 'name' => 'italiano', + 'folder' => 'it_IT' + ], + */ ]; +$availableLanguages = checkAvailableLanguages($availableLanguages); + +//echo '<pre>'; print_r($availableLanguages); echo '</pre>'; + define('DEFAULT_LANG', 'fr'); include('inc/lang.php'); diff --git a/foot.php b/foot.php index 0fe69d96756bb4203238b2a325a4adfe152427a3..fc2b88bd889ae706c61f0b31a086623e30d2f481 100644 --- a/foot.php +++ b/foot.php @@ -91,35 +91,32 @@ textdomain('menu'); textdomain('menu'); - foreach ($availableLanguages as $l) + foreach ($availableLanguages as $thisLangIsoCode => $thisLang) { echo ' <li>'; - if ($l == LANG) { + if ($isoCode == LANG) { echo ' <strong> <span> - ' . $l . ' + ' . $thisLangIsoCode . ' </span> <span> - ' . getLangName($l) . ' + ' . $thisLang['name'] . ' </span> </strong>'; } else { - - putenv('LC_ALL='. getGetTextFolder($l)); - setlocale(LC_ALL, getGetTextFolder($l) . '.utf8'); echo ' - <a href="'. $rootURL .'/'. $l . _($pagePermalink) .'"> + <a href="'. $rootURL .'/'. $thisLangIsoCode . _($pagePermalink) .'"> <span> - ' . $l . ' + ' . $thisLangIsoCode . ' </span> <span> - ' . getLangName($l) . ' + ' . $thisLang['name'] . ' </span> </a>'; @@ -128,9 +125,6 @@ textdomain('menu'); echo ' </li>'; } - - putenv('LC_ALL='. L10N_FOLDER); - setlocale(LC_ALL, L10N_FOLDER . '.utf8'); ?> </ul> </nav> diff --git a/head.php b/head.php index bda221cf8c97307034ae3355be98bba2eeb99661..4b5b2a334fd15f4795bf413b287cf13bf696767c 100644 --- a/head.php +++ b/head.php @@ -27,20 +27,22 @@ $bodyIds = !isset($bodyIds) ? '' : $bodyIds; <meta property="og:description" content="<?php echo $pageDescription; ?>" /> <meta property="og:url" content="http://cesium.app/" /> <meta property="og:site_name" content="Cesium Ğ1" /> - <meta property="og:image" content="<?php echo $rootURL . '/i18n/' . L10N_FOLDER . '/contents' . _('/accueil') . _('/Cesium-G1-maquette.png'); ?>" /> + + <meta property="og:image" content="<?php echo $rootURL . '/i18n/' . LANG_FOLDER . '/contents' . _('/accueil') . _('/Cesium-G1-maquette.png'); ?>" /> <meta property="og:type" content="website" /> <meta name="twitter:description" content="<?php echo $pageDescription; ?>" /> <meta name="twitter:title" content="<?php echo $pageTitle; ?>" /> - <meta name="twitter:image" content="<?php echo $rootURL . '/i18n/' . L10N_FOLDER . '/contents' . _('/accueil') . _('/Cesium-G1-maquette.png'); ?>" /> + + <meta name="twitter:image" content="<?php echo $rootURL . '/i18n/' . LANG_FOLDER . '/contents' . _('/accueil') . _('/Cesium-G1-maquette.png'); ?>" /> <meta name="twitter:card" content="summary_large_image" /> <script type="text/javascript" src="<?php echo $rootURL; ?>/lib/lazyImg.min.js"></script> <?php - foreach ($availableLanguages as $l) + foreach ($availableLanguages as $isoCode => $v) { - echo '<link rel="alternate" hreflang="'. $l .'" href="'. $rootURL .'/'. $l .'/" />'; + echo '<link rel="alternate" hreflang="'. $isoCode .'" href="'. $rootURL .'/'. $isoCode .'/" />'; } ?> diff --git a/inc/lang.php b/inc/lang.php index b892d43b38427956ac639f4f52dd23461578a053..6102ef634882eb8a12ae7060c2e8d23376360852 100644 --- a/inc/lang.php +++ b/inc/lang.php @@ -1,66 +1,52 @@ <?php -function getLangName ($code) +function getLangName ($isoCode) { - switch ($code) - { - case 'fr' : - return 'français'; - case 'en' : - return 'english' ; - case 'es' : - return 'español'; - case 'va' : - return 'valyrio'; - case 'it' : - return 'italiano'; - default : - return ''; // Supposedly cannot happen - } + global $availableLanguages; + + return $availableLanguages[$isoCode]['name']; } -function getGetTextFolder ($code) +function getLocaleCode ($isoCode) { - switch ($code) - { - case 'fr' : - return 'fr_FR'; - case 'en' : - return 'en_GB'; - case 'es' : - return 'es_ES'; - case 'va' : - return 'en_US'; - case 'it' : - return 'it_IT'; - } + global $availableLanguages; + + return $availableLanguages[$isoCode]['localeCode']; +} + +function getLangFolder ($isoCode) +{ + global $availableLanguages; + + return $availableLanguages[$isoCode]['folder']; } function defineLang () { global $availableLanguages; - if (isset($_GET['lang'])) { + if (isset($_GET['lang'])) { /* From URL */ $lang = $_GET['lang']; - } else { + } else { /* From browser (if visiting root page /) */ $lang = preg_replace('/^([^,-]+).*$/', '$1', $_SERVER['HTTP_ACCEPT_LANGUAGE']); } - - if (!in_array($lang, $availableLanguages)) { + + if (!in_array($lang, array_keys($availableLanguages))) { define('LANG', DEFAULT_LANG); } else { - + define('LANG', $lang); } - define('L10N_FOLDER', getGetTextFolder(LANG)); + define('LOCALE_CODE', getLocaleCode(LANG)); + define('LANG_FOLDER', getLangFolder(LANG)); } function bindTextDomains ($textDomains) diff --git a/index.php b/index.php index e718d4ffb9e69ab3a752f8cd2418542505eb28fc..37769f6be92c06fb7e3a5c7652cbbb2a0712d995 100644 --- a/index.php +++ b/index.php @@ -3,12 +3,8 @@ include('config.php'); defineLang(); -putenv('LC_ALL='. L10N_FOLDER); - - -if (false === setlocale(LC_ALL, L10N_FOLDER . '.utf8')) { - exit (sprintf('La langue "%s" n\'est pas installée sur ce système.', L10N_FOLDER)); -} +putenv('LC_ALL='. LOCALE_CODE); +setlocale(LC_ALL, LOCALE_CODE); textdomain("menu"); diff --git a/lib/style.css b/lib/style.css index 99c7b45bfc4e9ed4b6e4543f92d4e6d16418316b..e947cc519ff3376e6d1b0b2f92caa004e34fde5e 100644 --- a/lib/style.css +++ b/lib/style.css @@ -315,6 +315,7 @@ body header:first-child > h2 order: 2; flex-grow: 1; text-align: left; + font-size: 2.25rem; } body header:first-child > :first-child a, @@ -322,7 +323,7 @@ body header:first-child > :first-child a:hover { color: white; text-decoration: none; - padding-left: 0.5em; + padding-left: 0.25em; } @@ -683,6 +684,11 @@ body#home #showcase h2#USP text-align: center; } +body#home #showcase :not(figure) { + + z-index: 666; +} + body#home #showcase h2#USP + p { margin-top: 0rem; @@ -775,7 +781,7 @@ body#home #showcase h2#USP + p body#home #showcase div { flex-direction: column; - height: calc(100vh - 120px - 1rem); + height: calc(90vh - 120px - 1rem); box-sizing: border-box; } @@ -797,7 +803,9 @@ body#home #showcase h2#USP + p body#home #showcase figure img { align-self: center; - width: 112.5%; + height: calc(90vh - 120px); + width: auto; + transform: translateY(1rem) translateX(-2vw); } } @@ -811,7 +819,8 @@ body#home #showcase h2#USP + p body#home #showcase figure img { align-self: center; - width: 125%; + height: calc(90vh - 120px); + width: auto; transform: translateY(1rem) translateX(-2vw); } } diff --git a/tpl/features.php b/tpl/features.php index d96559ab695d483186d3c62cb449ce8959b16d85..33f65747b975321b82592398124e6dd4856146a7 100644 --- a/tpl/features.php +++ b/tpl/features.php @@ -23,7 +23,7 @@ textdomain('features'); $reader = new Reader('vendor/GeoLite2-Country/GeoLite2-Country.mmdb'); $record = $reader->country(getUserIpAddress()); - $path = './i18n/' . L10N_FOLDER . '/contents' . _('/fonctionnalites'); + $path = './i18n/' . LANG_FOLDER . '/contents' . _('/fonctionnalites'); $mapFileName = _('/carte-des-utilisateurs') . _('/pays') . sprintf('/%s.png', $record->country->isoCode); if (!file_exists($path . $mapFileName)) { @@ -134,7 +134,7 @@ textdomain('features'); { echo ' <figure> - <img src="'. $rootURL .'/i18n/' . L10N_FOLDER . '/contents' . _('/fonctionnalites') . $f['img'] .'" /> + <img src="'. $rootURL .'/i18n/' . LANG_FOLDER . '/contents' . _('/fonctionnalites') . $f['img'] .'" /> <figcaption> <h2>'. $f['name'] .'</h2>'; diff --git a/tpl/home.php b/tpl/home.php index 20669fcac2933a9686bfbd9dd7649713f027bd9f..21a0863b73955cc0d5e688c617eaad7f15191849 100644 --- a/tpl/home.php +++ b/tpl/home.php @@ -13,7 +13,7 @@ textdomain('home'); <section id="showcase"> <div> <figure id="home-app-screenshot"> - <img src="<?php echo $rootURL . '/i18n/' . L10N_FOLDER . '/contents' . _('/accueil') . _('/Cesium-G1-maquette.png'); ?>" + <img src="<?php echo $rootURL . '/i18n/' . LANG_FOLDER . '/contents' . _('/accueil') . _('/Cesium-G1-maquette.png'); ?>" alt="capture d'écran de Cesium" /> </figure> @@ -143,7 +143,7 @@ textdomain('home'); <?php -$reviewsPath = './i18n/' . L10N_FOLDER . '/contents' . _('/accueil') . _('/avis') . '/'; +$reviewsPath = './i18n/' . LANG_FOLDER . '/contents' . _('/accueil') . _('/avis') . '/'; if (file_exists($reviewsPath) AND ($reviewsFiles = scandir($reviewsPath)) AND count($reviewsFiles)-2 > 0) { diff --git a/tpl/tuto.php b/tpl/tuto.php index 66b127745537980cc53a25da1773cdd1269bedb9..8e7e582f0663ab80962c1ff898ad6d9abc062448 100644 --- a/tpl/tuto.php +++ b/tpl/tuto.php @@ -10,7 +10,7 @@ if (empty($subpage)) -$tutoContentsPath = './i18n/' . L10N_FOLDER . '/contents/tuto'; +$tutoContentsPath = './i18n/' . LANG_FOLDER . '/contents/tuto'; if (file_exists($tutoContentsPath . $subpage) and !is_dir($tutoContentsPath . $subpage) ) @@ -75,7 +75,7 @@ if (file_exists($tutoContentsPath . $subpage) and !is_dir($tutoContentsPath . $s { /* === Menu === */ - $menu = './i18n/' . L10N_FOLDER . '/contents/tuto/menu.html'; + $menu = './i18n/' . LANG_FOLDER . '/contents/tuto/menu.html'; if (file_exists($menu)) { $toc = file_get_contents($menu, FILE_USE_INCLUDE_PATH);