为客户设置缺省的“中文”队列

与 OTRS 相关的各种安装配置等问题

Moderator: never

micshi
OTRS wizard
Posts: 191
Joined: 05 Jul 2011, 16:10
OTRS Version?: 3.2.2
Real Name: Micshi
Location: Beijing
Contact:

为客户设置缺省的“中文”队列

Postby micshi » 14 Sep 2011, 02:46

在wiki.otrs.org上有一篇文章,介绍了《如何为客户端应用设置缺省队列》

该文以英文队列名‘support’为例,讲解怎样修改Config.pm和CustomerTicketOverView.dtl,使客户自动将新Ticket提交给support队列。

现在,假如我们要将队列名‘support’换成中文“支持”,那我们应该怎么修改Config.pm和CustomerTicketOverView.dtl,才能使Ticket自动提交给以汉字命名的队列(支持)呢?

答案是:要将汉字“支持”转换成UTF-8编码,同时分别以两种不同的格式替换Config.pm和CustomerTicketOverView.dtl文件中的support。

具体地讲,在Config.pm文件中,要将support替换成\x{652f}\x{6301};而在CustomerTicketOverView.dtl文件中,需要将support替换成支持。

替换后的代码如下:
Config.pm

Code: Select all

   $Self->{'CustomerFrontend::Module'}->{'CustomerTicketMessage'} = {
      'Title' => 'New Ticket',
      'Description' => 'Create tickets',
      'NavBarName' => 'Ticket',
      'NavBar' => [
                   {
                     'Description' => 'Create New Ticket',
                     'Name' => 'New Ticket',
                     'Link' => 'Action=CustomerTicketMessage;Subaction=StoreNew;Expand=3;Dest=5||\x{652f}\x{6301};Expand=1',
                     'Prio' => '100',
                     'AccessKey' => 'n'
                   }
      ],
   };


CustomerTicketOverView.dtl

Code: Select all

<a class="Button" href="$Env{"Baselink"}Action=CustomerTicketMessage;Subaction=StoreNew;Expand=3;Dest=5||&#x652f;&#x6301;;Expand=1">$Text{"Create your first ticket"}</a>


最后的问题是,如何获得中文对应的UTF-8编码?请见下面的perl程序:

Code: Select all

#!/usr/bin/perl -w
use Encode;

#my $dat = shift @ARGV;
my $dat = "支持";
$str = decode ('GBK',$dat);
$char = substr($str,1,1);

@chars=split //,$str;
foreach $char (@chars) {
   $char = encode ('GBK',"$char");
   print "$char";
}
print "\n";

foreach $char (@chars) {
   printf "\\x{%x}", ord decode('GBK', $char);
}
print "\n";

for ($i=0; $i < length($str); $i++) {
   printf "&#x%x;", ord decode('GBK', encode ('GBK',substr($str,$i,1)));
}
print "\n";
OTRS 3.2.2, ITSM 3.2.2, SystemMonitor
Ubuntu, Apache2, MySQL 5
My OTRS Blog
OTRS Basic Concept Training
OTRS Demo Instance

Return to “安装和使用”

Who is online

Users browsing this forum: No registered users and 2 guests