xjia1 / oj

SJTU Online Judge
http://acm.sjtu.edu.cn/OnlineJudge/
60 stars 27 forks source link

更改标点等 #28

Closed sjtufs closed 11 years ago

xjia1 commented 11 years ago

请去掉app/.routes.php.swp这个文件。

翻译没有问题了,但为了方便支持多语言,需要做一些程序结构上的修改。

main.php会在一开始载入init.php,进而载入translate.php。需要在translate.php文件中,增加一个如下结构的函数:

function T($english)
{
  static $translations = array(
    'chinese' => array(
      'You are not allowed to view the dashboard.' => '你没有进入控制台的权限。'
    )
  );
  $language = 'chinese';  // 这里先固定为 chinese,以后会修改成根据用户来决定语言
  if (isset($translations[$language][$english])) {
    return $translations[$language][$english];
  }
  return $english;
}

这样就可以在app/controllers/DashboardController.php这些文件里这样使用了:

fMessaging::create('error', T('You are not allowed to view the dashboard.'));

但是这样有一个问题,就是不能支持"Data base directory {$data_base_dir} does not exist."这样的句子。对于这样的句子,我们期望的使用方法如下:

throw new fValidationException(T('Data base directory %s does not exist.', $data_base_dir));

这可以通过使用 func_get_argssprintf 等函数来实现。

xjia1 commented 11 years ago

flourish 里使用的翻译方式和我上面所说的类似,你可以按照这个思路去看一看如何翻译 flourish 输出的信息。

sjtufs commented 11 years ago

收到

Date: Sun, 14 Oct 2012 22:27:02 -0700 From: notifications@github.com To: oj@noreply.github.com CC: sjtu_fs@outlook.com Subject: Re: [oj] 更改标点等 (#28)

flourish 里使用的翻译方式和我上面所说的类似,你可以按照这个思路去看一看如何翻译 flourish 输出的信息。

          —

          Reply to this email directly or view it on GitHub.