From 5cce1585ddfd207039f1fd7d146881f925cc94f7 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sat, 8 May 2004 11:00:46 +0000 Subject: [PATCH] fix for month-name shortcuts different from the first 3-chars of the long name, because they would be indentical with the shortcut of an other monthname, eg. frensh Juin = Jun and Juillet = Jui --- phpgwapi/inc/class.jscalendar.inc.php | 30 +++++++++++++++++++++------ phpgwapi/inc/jscalendar-setup.php | 11 +++++++--- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/phpgwapi/inc/class.jscalendar.inc.php b/phpgwapi/inc/class.jscalendar.inc.php index 7d10aa7e86..7283f54b48 100644 --- a/phpgwapi/inc/class.jscalendar.inc.php +++ b/phpgwapi/inc/class.jscalendar.inc.php @@ -68,7 +68,12 @@ $date = date($this->dateformat,$ts = mktime(12,0,0,$month,$day,$year)); if (strpos($this->dateformat,'M') !== False) { - $date = str_replace(date('M',$ts),substr(lang(date('F',$ts)),0,3),$date); + $short = lang(date('M',$ts)); // check if we have a translation of the short-cut + if (substr($short,-1) == '*') // if not generate one by truncating the translation of the long name + { + $short = substr(lang(date('F',$ts)),0,(int) lang('3 number of chars for month-shortcut')); + } + $date = str_replace(date('M',$ts),$short,$date); } } if ($helpmsg !== '') @@ -156,17 +161,30 @@ { if (!is_numeric($fields[$n])) { + $partcial_match = 0; for($i = 1; $i <= 12; $i++) { - $long_name = date('F',mktime(12,0,0,$i,1,2000)); - $short_name = date('M',mktime(12,0,0,$i,1,2000)); - $translated = lang($long_name); - if ($fields[$n] == $long_name || $fields[$n] == $short_name || - strstr($translated,$fields[$n]) == $translated) // multibyte save + $long_name = lang(date('F',mktime(12,0,0,$i,1,2000))); + $short_name = lang(date('M',mktime(12,0,0,$i,1,2000))); // do we have a translation of the short-cut + if (substr($short_name,-1) == '*') // if not generate one by truncating the translation of the long name { + $short_name = substr($long_name,0,(int) lang('3 number of chars for month-shortcut')); + } + //echo "
checking '".$fields[$n]."' against '$long_name' or '$short_name'"; + if ($fields[$n] == $long_name || $fields[$n] == $short_name) + { + //echo " ==> OK
"; $fields[$n] = $i; break; } + if (strstr($long_name,$fields[$n]) == $long_name) // partcial match => multibyte saver + { + $partcial_match = $i; + } + } + if ($i > 12 && $partcial_match) // nothing found, but a partcial match + { + $fields[$n] = $partcial_match; } } $field = 'm'; diff --git a/phpgwapi/inc/jscalendar-setup.php b/phpgwapi/inc/jscalendar-setup.php index 4b65a9c11b..9523774f4e 100644 --- a/phpgwapi/inc/jscalendar-setup.php +++ b/phpgwapi/inc/jscalendar-setup.php @@ -255,7 +255,7 @@ foreach($day2int as $name => $n) echo "\n \"".substr(lang($name),0,(int)lang('3 number of chars for day-shortcut')).'"'.($n < 6 ? ',' : ''); } ?>); -Calendar._SDN_len = 2; +Calendar._SDN_len = ; Calendar._MN = new Array ( $name) { - echo "\n \"".substr(lang($name),0,(int)lang('3 number of chars for month-shortcut')).'"'.($n < 11 ? ',' : ''); + $short = lang(substr($name,0,3)); // test if our lang-file have a translation for the english short with 3 chars + if (substr($short,-1) == '*') // else create one by truncating the full translation to x chars + { + $short = substr(lang($name),0,(int)lang('3 number of chars for month-shortcut')); + } + echo "\n \"".$short.'"'.($n < 11 ? ',' : ''); } ?>); -Calendar._SMN_len = 2; +Calendar._SMN_len = ; // tooltips Calendar._TT = {};