zoukankan      html  css  js  c++  java
  • 开源的项目管理系统dotProject的汉化问题

        为了加强软件项目的管理,我公司使用了开源项目管理软件dotProject。dotProject是一个基于LAMP的开源项目管理软件。使用PHP+MySql开发实现。dotProject官方网站在这里:http://www.dotproject.net/ 目前发布的最新版本为2.0.4。官方网站上面提供的中文包也不错,我使用的是Chinese_Simplied_(GBK)_2.01_Compatible语言包,编码方式是GB2312。下载安装,安装语言包非常简单,解压缩之后是一个名为“cn”的目录,整个复制到dotProject的locales子目录中,然后做一下系统配置就搞定了。汉化的也很好。只是有一个缺点,日历功能的星期几的汉字显示有问题!页面上面显示为乱码。
        经过我的研究发现,造成此问题有下面这两个原因:
    1. 星期几名称缩写的截取函数有问题。代码中使用英文单词取前3个字符的截取方式,例如:Monday-> Mon。可是当截取汉字的时候就生成了一个半汉字。
    2. 可能是个Bug,例如原文件“dotProject\modules\calendar\calendar.class.php” 中生成标题字符串的程序代码为:
      $s .= "\n\t\t<th width=\"14%\">" . htmlentities(utf8_encode($day), ENT_COMPAT, $locale_char_set. "</th>";
        很明显,这里调用了一次utf8的编码函数,所以不论何种本地化编码方式,这里都生成了utf8的编码字符。
        至于改进方式,我采用了比较偷懒的方式,直接设置了星期几名称的数组,然后去掉第2个问题中的utf8编码函数调用,问题解决。下面是我修改后的函数代码:
    function _drawDays() {
            
    global $locale_char_set;

            
    $bow = Date_Calc::beginOfWeek( null,null,null,null,LOCALE_FIRST_DAY );
            
    $y = substr$bow, 0, 4 );
            
    $m = substr$bow, 4, 2 );
            
    $d = substr$bow, 6, 2 );
            
    $wk = Date_Calc::getCalendarWeek( $d, $m, $y, "%a", LOCALE_FIRST_DAY );
            
    if($locale_char_set=='GB2312')
                {
                    
    $wk = array('','','','','','','');
                }
            
    $s = $this->showWeek ? "\n\t\t<th>&nbsp;</th>" : "";
            
    foreach$wk as $day ) {
                
    //$s .= "\n\t\t<th width=\"14%\">" . htmlentities(utf8_encode($day), ENT_COMPAT, $locale_char_set) . "</th>";
                $s .= "\n\t\t<th align=\"center\" width=\"14%\">" . htmlentities($day, ENT_COMPAT, $locale_char_set. "</th>";
            }

            
    return "\n<tr>$s\n</tr>";
        }


  • 相关阅读:
    数据库存储过程语法及实例
    springboot2配置JavaMelody与springMVC配置JavaMelody
    org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'userId' in 'class java.lang.Integer'
    ajax表单提交执行成功但是没有执行回调函数,并且post变get了
    SpringMVC——重定向跳转传值
    thymeleaf中跳转地址的使用
    solr安装与配置
    redis集群redis-cluster搭建
    nginx安装手册
    Linux忘记root用户的密码
  • 原文地址:https://www.cnblogs.com/dajianshi/p/540617.html
Copyright © 2011-2022 走看看