williamleonard / obblm

Automatically exported from code.google.com/p/obblm
1 stars 0 forks source link

[TRANSLATION] Date format, dat of week and months #664

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Date are not translated (day of week, name of months, ...).

Here is a quick patch to show the idea.
Only thing is, at the moment it's hard-coded for each language. In the long 
run, months and days should be in the translation file.

--- a/lib/class_translations.php
+++ b/lib/class_translations.php
@@ -39,7 +39,11 @@ public function __construct($lang = false) {
 public function setLanguage($lang) {
     $this->lang = in_array($lang, self::$registeredLanguages) ? $lang : self::fallback;
 }
-
+
+public function getLanguage() {
+    return $this->lang;
+}
+

--- a/lib/misc_functions.php
+++ b/lib/misc_functions.php
@@ -236,11 +236,24 @@ function status($status, $msg = '') {
     if ($msg) {echo " : $msg\n";}
     echo "</div>";
 }
-
+
 function textdate($mysqldate, $noTime = false, $setSeconds = true) {
-    return date("D M j Y".(($noTime) ? '' : (' G:i'.(($setSeconds) ? ':s' : 
''))), strtotime($mysqldate));
-}
-
+    global $lng;
+    switch($lng->getLanguage())
+    {
+      case 'fr-FR':
+        // Hard coded days of week and months : can be put into translation 
file later if needed
+        $jour = 
array("Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi");
+        $mois = 
array("","Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Sep
tembre","Octobre","Novembre","Décembre");
+        $the_time = strtotime($mysqldate);
+        return $jour[date("w", $the_time)]." ".date("j", $the_time)." 
".$mois[date("n", $the_time)]." ".date("Y ".(($noTime) ? '' : (' 
G:i'.(($setSeconds) ? ':s' : ''))), $the_time);
+        break;
+
+      default:
+        return date("D M j Y".(($noTime) ? '' : (' G:i'.(($setSeconds) ? ':s' 
: ''))), strtotime($mysqldate));
+    }
+}
+

Original issue reported on code.google.com by bloodybo...@gmail.com on 13 Jan 2015 at 1:34

GoogleCodeExporter commented 9 years ago
Seems like you are competent to add a lot of patches from your issue 
submissions. Do you want to be added to the contributor list and make the 
changes yourself?

Original comment by nicholas...@gmail.com on 16 Jan 2015 at 2:34

GoogleCodeExporter commented 9 years ago

Original comment by bloodybo...@gmail.com on 16 Jan 2015 at 6:00

GoogleCodeExporter commented 9 years ago
If you add them to the translations file this is OK with me.

Original comment by nicholas...@gmail.com on 20 Jan 2015 at 11:19

GoogleCodeExporter commented 9 years ago
I will add months/days to the translation file.

There is just a problem with the order of D/M/Y or Y/M/D, if you are english, 
french, etc.... each country display the date in a different order. So I think 
we still need to have a hard coded order for each language in the translation 
class.

What do you think ?

Original comment by bloodybo...@gmail.com on 21 Jan 2015 at 7:59

GoogleCodeExporter commented 9 years ago

Original comment by bloodybo...@gmail.com on 23 Jan 2015 at 7:35

GoogleCodeExporter commented 9 years ago
Fine with me putting them in translation, but maybe you could keep the D/M/Y 
format for now?

Original comment by nicholas...@gmail.com on 30 Jan 2015 at 10:03

GoogleCodeExporter commented 9 years ago
D/M/Y is not good because there is the day of the week too.

I'll put months and days of week in translation file, then hard-code the order 
in misc_functions.php (as shown in the code example up on this page).

Original comment by bloodybo...@gmail.com on 30 Jan 2015 at 10:14

GoogleCodeExporter commented 9 years ago
Added in revision 1014.

Original comment by bloodybo...@gmail.com on 5 Feb 2015 at 8:35