[10.0.87.dev] La config des langues est dans DATA + constante avec le path + Langues optionnelles dans init.php
@ -29,9 +29,10 @@ class common {
|
||||
const DATA_DIR = 'site/data/';
|
||||
const FILE_DIR = 'site/file/';
|
||||
const TEMP_DIR = 'site/tmp/';
|
||||
const I18N_DIR = 'site/i18n/';
|
||||
|
||||
// Numéro de version
|
||||
const ZWII_VERSION = '10.0.86.dev';
|
||||
const ZWII_VERSION = '10.0.87.dev';
|
||||
|
||||
public static $actions = [];
|
||||
public static $coreModuleIds = [
|
||||
@ -45,30 +46,6 @@ class common {
|
||||
'user',
|
||||
'i18n'
|
||||
];
|
||||
public static $i18nList = [
|
||||
'de' => 'Allemand (de)' ,
|
||||
'en' => 'Anglais (en)',
|
||||
'bg' => 'Bulgare (bg)',
|
||||
'dk' => 'Danois (dk)',
|
||||
'es' => 'Espagnol (es)',
|
||||
'fi' => 'Finnois (fi)',
|
||||
'fr' => 'Français (fr)',
|
||||
'is' => 'Islandais (is)',
|
||||
'it' => 'Italien (it)',
|
||||
'nl' => 'Néerlandais (nl)',
|
||||
'no' => 'Norvégien (no)' ,
|
||||
'pt' => 'Portugais (pt)',
|
||||
'se' => 'Suédois (se)',
|
||||
'ro' => 'Roumain (ro)',
|
||||
'cz' => 'Tchèque (cz)',
|
||||
'tr' => 'Turc (tr)',
|
||||
'eu' => 'Basque (eu)',
|
||||
'br' => 'Breton (br)',
|
||||
'co' => 'Corse (co)',
|
||||
'ha' => 'Flamand (ha)',
|
||||
'oc' => 'Occitan (oc)',
|
||||
'pi' => 'Picard (pi)'
|
||||
];
|
||||
public static $dataStage = [
|
||||
'config',
|
||||
'core',
|
||||
@ -77,6 +54,15 @@ class common {
|
||||
'user',
|
||||
'theme'
|
||||
];
|
||||
public static $i18nList = [
|
||||
'de' => 'Allemand (de)' ,
|
||||
'en' => 'Anglais (en)',
|
||||
'es' => 'Espagnol (es)',
|
||||
'fr' => 'Français (fr)',
|
||||
'it' => 'Italien (it)',
|
||||
'nl' => 'Néerlandais (nl)',
|
||||
'pt' => 'Portugais (pt)',
|
||||
];
|
||||
private $data = [];
|
||||
private $hierarchy = [
|
||||
'all' => [],
|
||||
@ -158,6 +144,10 @@ class common {
|
||||
* Constructeur commun
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
// Charger la liste des langues
|
||||
require_once (self::I18N_DIR . 'init.php');
|
||||
|
||||
// Extraction des données http
|
||||
if(isset($_POST)) {
|
||||
$this->input['_POST'] = $_POST;
|
||||
@ -2469,13 +2459,13 @@ class layout extends common {
|
||||
if (sizeof($this->i18nInstalled()) > 1) {
|
||||
$items .= '<li><form method="POST" action="' . helper::baseUrl() . 'i18n/lang" id="barFormSelectLanguage">';
|
||||
$items .= '<input type="image" alt="' . self::$i18nList[$this->geti18n()] . '(' . $this->geti18n() . ')' . '" class="flag flagSelected"';
|
||||
$items .= ' name="'.$this->geti18n().'" src="' . helper::baseUrl(false) .'core/vendor/icon-flags/png/'. $this->geti18n() .'.png" data-tippy-content="' . self::$i18nList[$this->geti18n()] . '" />';
|
||||
$items .= ' name="'.$this->geti18n().'" src="' . helper::baseUrl(false) .self::I18N_DIR . 'png/'. $this->geti18n() .'.png" data-tippy-content="' . self::$i18nList[$this->geti18n()] . '" />';
|
||||
$items .= '</form></li>';
|
||||
foreach ($this->i18nInstalled() as $itemKey => $item) {
|
||||
if ($this->geti18n() !== $itemKey ) {
|
||||
$items .= '<li><form method="POST" action="' . helper::baseUrl() . 'i18n/lang" id="barFormSelectLanguage">';
|
||||
$items .= '<input type="image" alt="'.$itemKey.'" class="flag"';
|
||||
$items .= ' name="'.$itemKey.'" src="' . helper::baseUrl(false) .'core/vendor/icon-flags/png/'. $itemKey .'.png" data-tippy-content="'. $item .'" />';
|
||||
$items .= ' name="'.$itemKey.'" src="' . helper::baseUrl(false) .self::I18N_DIR . 'png/'. $itemKey .'.png" data-tippy-content="'. $item .'" />';
|
||||
$items .= '</form></li>';
|
||||
}
|
||||
}
|
||||
|
43
site/i18n/init.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
* Pour ajouter une langue
|
||||
* Soit la langue est disponible dans la liste prédéfinie, il suffit de supprimer les deux // de commentaire
|
||||
* Soit la langue n'est pas disponible, complétez le tableau en ajoutant
|
||||
* 1 - Le code iso sur deux caractères en vous référant à cette page https://fr.wikipedia.org/wiki/ISO_3166-1
|
||||
* 2 - Le nom de la langue en texte en clair, le rappel du code iso est facultatif
|
||||
* 3 - Enfin, créez dans le dossier png le drapeau de la langue au format png dimensions 30x20 pixels
|
||||
*
|
||||
* Attention : Il s'agit bien d'un drapeau relatif à une langue etnon à un pays, on ne doit donc pas insérer de pays comme la Belgique ou la Suisse.
|
||||
*/
|
||||
|
||||
$i18nOptions = [
|
||||
//'bg' => 'Bulgare (bg)',
|
||||
'dk' => 'Danois (dk)',
|
||||
//'fi' => 'Finnois (fi)',
|
||||
//'is' => 'Islandais (is)',
|
||||
'no' => 'Norvégien (no)',
|
||||
//'se' => 'Suédois (se)',
|
||||
//'ro' => 'Roumain (ro)',
|
||||
'cz' => 'Tchèque (cz)',
|
||||
//'tr' => 'Turc (tr)',
|
||||
// Langues régionales
|
||||
//'eu' => 'Basque (eu)',
|
||||
//'br' => 'Breton (br)',
|
||||
//'co' => 'Corse (co)',
|
||||
//'ha' => 'Flamand (ha)',
|
||||
//'oc' => 'Occitan (oc)',
|
||||
//'pi' => 'Picard (pi)'
|
||||
];
|
||||
|
||||
// ----------------------------------
|
||||
// Ne rien modifier ci-dessous
|
||||
// Vérifier l'existence des drapeaux
|
||||
foreach ($i18nOptions as $itemKey => $itemValue) {
|
||||
if (file_exists(self::I18N_DIR . 'png/' . $itemKey . '.png') === false) {
|
||||
unset($i18nOptions[$itemKey]);
|
||||
}
|
||||
}
|
||||
// Incorporer les nouvelles langues valides
|
||||
self::$i18nList = array_merge (self::$i18nList, $i18nOptions);
|
Before Width: | Height: | Size: 139 B After Width: | Height: | Size: 139 B |
Before Width: | Height: | Size: 507 B After Width: | Height: | Size: 507 B |
Before Width: | Height: | Size: 744 B After Width: | Height: | Size: 744 B |
Before Width: | Height: | Size: 217 B After Width: | Height: | Size: 217 B |
Before Width: | Height: | Size: 119 B After Width: | Height: | Size: 119 B |
Before Width: | Height: | Size: 183 B After Width: | Height: | Size: 183 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 287 B After Width: | Height: | Size: 287 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 185 B After Width: | Height: | Size: 185 B |
Before Width: | Height: | Size: 96 B After Width: | Height: | Size: 96 B |
Before Width: | Height: | Size: 972 B After Width: | Height: | Size: 972 B |
Before Width: | Height: | Size: 227 B After Width: | Height: | Size: 227 B |
Before Width: | Height: | Size: 96 B After Width: | Height: | Size: 96 B |
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 108 B |
Before Width: | Height: | Size: 241 B After Width: | Height: | Size: 241 B |
Before Width: | Height: | Size: 912 B After Width: | Height: | Size: 912 B |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 395 B After Width: | Height: | Size: 395 B |
Before Width: | Height: | Size: 98 B After Width: | Height: | Size: 98 B |
Before Width: | Height: | Size: 295 B After Width: | Height: | Size: 295 B |
Before Width: | Height: | Size: 229 B After Width: | Height: | Size: 229 B |