PEAK XOOPS - D3モジュール言語定数のオーバーライド in englishin japanese

Archive | RSS |
XOOPS
XOOPS : D3モジュール言語定数のオーバーライド
Poster : GIJOE on 2007-05-08 03:54:37 (12000 reads)

in englishin japanese
D3モジュールの言語定数は、XOOPS_ROOT_PATH側に言語定義ファイルを置くことで、各モジュール毎にオーバーライドできる、なんて話を書きましたが、実際に試してみたらかなり使いづらい、というのが実情です。例えば、モジュールがバージョンアップして、言語定義が増えた場合に、それを簡単に更新する術がありません。

また、仮にもCMSなのに、HTTP経由ではちょっとしたメッセージ変更すらできない、なんていうのもあまり格好良くありません。

というわけで、altsys-0.5に、言語定数オーバーライドシステムを実装してみました。その主要構成部は2つ。

- mylangadmin
myblocksadminやmytplsadminと同じく、各モジュールの管理画面から呼び出されるコントローラです。ここで上書きされた言語定数を、定数名ごとにDB(altsys_language_constants)に保存し、XOOPS_ROOT_PATH/cache/ 下にキャッシュとして書き出します。

- D3LanguageManager
モジュール/コアが言語定数を読み込むときに使うシングルトンクラスです。実際には、mylangadminによって作成されたキャッシュがあればそれを優先的に読み込むだけの処理だったりします。
以下のように呼び出します。


require_once XOOPS_TRUST_PATH.'/libs/altsys/class/D3LanguageManager.class.php' ;
$langman =& D3LanguageManager::getInstance() ;
$langman->read( 'main.php' , $mydirname , $mytrustdirname ) ;


とりあえずは、pico-1.31に実装してみました。言語定数を管理画面から簡単にオーバーライドできるのは、結構、快感かもしれません。

また、モジュールがバージョンアップして、言語定義が増えた場合でも、DBとキャッシュという2段構造をとっているため、言語定数管理からあらためてキャッシュ更新を行うだけで、簡単に更新できます。(もう少し自動化できたらなおベストか……onUpdate?)

現状では、言語定数を独自に読み込むD3モジュールにしか利用できませんが、言語定数読込部分を換装可能に作ってあるコア(例えばXoopsCube Legacy 2.1)であれば、mylangadminで従来型モジュールの言語定数をオーバーライドすることも難しくないでしょう。(altsys側にももう少し手を入れる必要があるでしょうが)


Related articles
Printer friendly page Send this story to a friend

Comments list

OneOfTen  Posted on 2007/5/16 4:44
Ah thanks, I didn't try yet and didn't know that the format of the cached files is the same like the normal lang-files. That's good news. Thanks for all the nice tools and your hard work!
GIJOE  Posted on 2007/5/16 2:57 | Last modified
I cannot understand what you mean.

Quote:

the user could also save the new Values in a copy of the original file?
user can find the overridden file in XOOPS_TRUST_PATH/cache/ easily.

And I believe this way using "DB and Cache" is the best way for users.
When some language constants are added, just make cache again.
This means "Easy to merge".
OneOfTen  Posted on 2007/5/15 20:16
Why didn't you make those functions (also myblocksadmin and mytplsadmin) so that the user could also save the new Values in a copy of the original file? That would make the translation work for modules and the core much easier.
Login
Username or e-mail:

Password:

Remember Me

Lost Password?

Register now!