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

This commit is contained in:
Ralf Becker 2004-05-08 11:00:46 +00:00
parent e269ccb9cb
commit 5cce1585dd
2 changed files with 32 additions and 9 deletions

View File

@ -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 "<br>checking '".$fields[$n]."' against '$long_name' or '$short_name'";
if ($fields[$n] == $long_name || $fields[$n] == $short_name)
{
//echo " ==> OK<br>";
$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';

View File

@ -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 = <?php echo (int) lang('3 number of chars for day-shortcut'); ?>2;
Calendar._SDN_len = <?php echo (int) lang('3 number of chars for day-shortcut'); ?>;
Calendar._MN = new Array
(<?php // full month names
@ -271,10 +271,15 @@ Calendar._SMN = new Array
$monthnames = array('January','February','March','April','May','June','July','August','September','October','November','December');
foreach($monthnames as $n => $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 = <?php echo (int) lang('3 number of chars for month-shortcut'); ?>2;
Calendar._SMN_len = <?php echo (int) lang('3 number of chars for month-shortcut'); ?>;
// tooltips
Calendar._TT = {};