ThinkPHP 3.1 內建的分頁類(Page)在樣板設置上出了個小問題,如果分頁數大於 5 就會出現寫死在程式碼內的「上5頁、下5頁」等簡體字串,所以著手修改以配合多語系的專案。

  1. 開啟「ThinkPHP/Extend/Library/ORG/Util/Page.class.php
  2. 尋找第 34 行並修改如下

    protected $config = array('prevroll'=>'上 %n 页', 'nextroll'=>'下 %n 页', 'header'=>'条记录','prev'=>'上一页','next'=>'下一页','first'=>'第一页','last'=>'最后一页','theme'=>' %totalRow% %header% %nowPage%/%totalPage% 页 %upPage% %downPage% %first%  %prePage%  %linkPage%  %nextPage% %end%');
  3. 尋找第 119, 120 行並修改如下
    $prePage = "<a href='".str_replace('__PAGE__',$preRow,$url)."' >".str_replace('%n', $this->rollPage, $this->config['prevroll'])."</a>";
    $nextPage   =   "<a href='".str_replace('__PAGE__',$nextRow,$url)."' >".str_replace('%n', $this->rollPage, $this->config['nextroll'])."</a>";

存檔收工!