From 019577ad4f6bb4a96e6bb72f485c7806aa0725fc Mon Sep 17 00:00:00 2001
From: Boris Paing <boris.paing@laposte.net>
Date: Fri, 27 Mar 2020 18:36:50 +0100
Subject: [PATCH] FIX: local handling

---
 foot.php         | 36 +++++++++++++++---------------------
 head.php         | 20 ++++++++++----------
 tpl/download.php |  2 --
 tpl/features.php |  4 ++--
 tpl/home.php     |  5 +++--
 tpl/tuto.php     |  7 ++++---
 6 files changed, 34 insertions(+), 40 deletions(-)

diff --git a/foot.php b/foot.php
index 4b50e44..b0531f2 100644
--- a/foot.php
+++ b/foot.php
@@ -1,37 +1,31 @@
-<?php
-
-textdomain('menu');
-
-?>
-
 			</main>
 
 			<footer>
 				<div>
 					<nav id="sitemap">
 						<h5>
-							<?php echo _('Plan du site'); ?>
+							<?php echo dgettext('menu', 'Plan du site'); ?>
 						</h5>
 
 						<ul>
 							<li>
 								<a href="<?php echo parseURI('/'); ?>">
-									<?php echo _('Accueil'); ?>
+									<?php echo dgettext('menu', 'Accueil'); ?>
 								</a>
 							</li>
 							<li>
-								<a href="<?php echo parseURI(_('/fonctionnalites')); ?>">
-									<?php echo _('Fonctionnalités'); ?>
+								<a href="<?php echo parseURI(dgettext('menu', '/fonctionnalites')); ?>">
+									<?php echo dgettext('menu', 'Fonctionnalités'); ?>
 								</a>
 							</li>
 							<li>
-								<a href="<?php echo parseURI(_('/telechargement')); ?>">
-									<?php echo _('Téléchargement'); ?>
+								<a href="<?php echo parseURI(dgettext('menu', '/telechargement')); ?>">
+									<?php echo dgettext('menu', 'Téléchargement'); ?>
 								</a>
 							</li>
 							<li>
 								<a href="https://forum.duniter.org/c/support/cesium">
-									<?php echo _('Support'); ?>
+									<?php echo dgettext('menu', 'Support'); ?>
 								</a>
 							</li>
 						</ul>
@@ -39,28 +33,28 @@ textdomain('menu');
 
 					<nav id="developper-links">
 						<h5>
-							<?php echo _('Développeur ? Rejoignez-nous !');?>
+							<?php echo dgettext('menu', 'Développeur ? Rejoignez-nous !');?>
 						</h5>
 
 						<ul>
 							<li>
 								<a href="https://forum.duniter.org/c/support/cesium">
-									<?php echo _('Forum Cesium'); ?>
+									<?php echo dgettext('menu', 'Forum Cesium'); ?>
 								</a>
 							</li>
 							<li>
 								<a href="https://forum.duniter.org/c/presentations">
-									<?php echo _('Venez faire connaissance'); ?>
+									<?php echo dgettext('menu', 'Venez faire connaissance'); ?>
 								</a>
 							</li>
 							<li>
 								<a href="https://git.duniter.org/clients/cesium-grp/cesium">
-									<?php echo _('Forge GitLab de Cesium'); ?>
+									<?php echo dgettext('menu', 'Forge GitLab de Cesium'); ?>
 								</a>
 							</li>
 							<li>
 								<a href="https://git.duniter.org/clients/cesium-grp/cesium/blob/master/doc/development_guide.md">
-									<?php echo _('Guide du développement Cesium'); ?>
+									<?php echo dgettext('menu', 'Guide du développement Cesium'); ?>
 								</a>
 							</li>
 							<li>
@@ -79,12 +73,12 @@ textdomain('menu');
 						</p>
 
 						<p>
-							<a href="<?php echo $rootURL . _('/mentions-legales'); ?>">Mentions légales</a>
+							<a href="<?php echo $rootURL . dgettext('menu', '/mentions-legales'); ?>">Mentions légales</a>
 						</p>
 					</section>
 
 					<nav id="langSelector">
-						<h5><?php echo _('Choix de langue'); ?></h5>
+						<h5><?php echo dgettext('menu', 'Choix de langue'); ?></h5>
 
 						<ul>
 							<?php 
@@ -115,7 +109,7 @@ textdomain('menu');
 									} else {
 										
 										echo '
-										<a href="'. $rootURL .'/'. $thisLangIsoCode . _($pagePermalink) .'">
+										<a href="'. $rootURL .'/'. $thisLangIsoCode . dgettext('menu', $pagePermalink) .'">
 												<span>
 													' . $thisLangIsoCode . '
 												</span>
diff --git a/head.php b/head.php
index f74cd50..cb6635a 100644
--- a/head.php
+++ b/head.php
@@ -28,13 +28,13 @@ $bodyIds = !isset($bodyIds) ? '' : $bodyIds;
 		<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/' . LANG_FOLDER . '/contents' . _('/accueil') . _('/Cesium-G1-maquette.png'); ?>" />
+		<meta property="og:image" content="<?php echo $rootURL . '/i18n/' . LANG_FOLDER . '/contents' . dgettext('menu', '/accueil') . dgettext('home', '/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/' . LANG_FOLDER . '/contents' . _('/accueil') . _('/Cesium-G1-maquette.png'); ?>" />
+		<meta name="twitter:image" content="<?php echo $rootURL . '/i18n/' . LANG_FOLDER . '/contents' . dgettext('menu', '/accueil') . dgettext('home', '/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>
@@ -58,20 +58,20 @@ $bodyIds = !isset($bodyIds) ? '' : $bodyIds;
 				$menu =
 					array(
 						[
-							'uri' => _('/'), 
-							'label' => _('Accueil')
+							'uri' => dgettext('menu', '/'), 
+							'label' => dgettext('menu', 'Accueil')
 						], 
 						[
-							'uri' => _('/fonctionnalites'), 
-							'label' => _('Fonctionnalités')
+							'uri' => dgettext('menu', '/fonctionnalites'), 
+							'label' => dgettext('menu', 'Fonctionnalités')
 						], 
 						[
-							'uri' => _('/telechargement'), 
-							'label' => _('Télécharger')
+							'uri' => dgettext('menu', '/telechargement'), 
+							'label' => dgettext('menu', 'Télécharger')
 						],
 						[
-							'uri' => _('/tutoriel-cesium') . '/', 
-							'label' => _('Tutoriel')
+							'uri' => dgettext('menu', '/tutoriel-cesium') . '/', 
+							'label' => dgettext('menu', 'Tutoriel')
 						]
 					);
 			?>
diff --git a/tpl/download.php b/tpl/download.php
index 00ed327..f2f1ad4 100644
--- a/tpl/download.php
+++ b/tpl/download.php
@@ -9,8 +9,6 @@ include('cesiumDownloads.php');
 
 include('head.php');
 
-textdomain('download');
-
 ?>
 
 
diff --git a/tpl/features.php b/tpl/features.php
index 33f6574..b392305 100644
--- a/tpl/features.php
+++ b/tpl/features.php
@@ -1,12 +1,12 @@
 <?php
 
+textdomain('features');
+
 $pageTitle = _('Fonctionnalités');
 $pageDescription = _("Fonctionnalités de Cesium : gérer son comptes monnaie libre Ğ1, rechercher des membres dans l'annuaire, trouver des entreprises qui acceptent la Ğ1.");
 
 include('head.php');
 
-textdomain('features');
-
 ?>
 <article id="features">
 	
diff --git a/tpl/home.php b/tpl/home.php
index 76edefb..6f560a6 100644
--- a/tpl/home.php
+++ b/tpl/home.php
@@ -1,13 +1,14 @@
 <?php
 $bodyIds = 'home';
 
+
+textdomain('home');
+
 $pageTitle = _('Cesium Ğ1 - Site officiel');
 $pageDescription = _("Cesium est l'application la plus intuitive pour gérer votre portefeuille en monnaie-libre Ğ1.");
 
 include('head.php');
 
-textdomain('home');
-
 ?>
 
 <section id="showcase">
diff --git a/tpl/tuto.php b/tpl/tuto.php
index 8e7e582..344cb35 100644
--- a/tpl/tuto.php
+++ b/tpl/tuto.php
@@ -1,4 +1,7 @@
 <?php
+
+textdomain('tuto');
+
 $pageTitle = '';
 
 $tutoURL = $rootURL . '/' . LANG . dgettext('menu', $pagePermalink) . '/';
@@ -98,13 +101,11 @@ if (file_exists($tutoContentsPath . $subpage) and !is_dir($tutoContentsPath . $s
 
 		include('head.php');
 
-		textdomain('tuto');
-
 		?>
 
 		<section id="tuto">
 			<nav>
-				<h2>Sommaire</h2>
+				<h2><?php echo _('Sommaire'); ?></h2>
 
 				<?php echo $toc; ?>
 			</nav>
-- 
GitLab