Más contenido relacionado La actualidad más candente (12) Similar a テンプレート管理ツール r3 (20) テンプレート管理ツール r34. r3とは
• Yahoo!からオープンソースで公開され
たテンプレート管理システム
–「テンプレートエンジン」では無い
–PHP以外のテンプレやCSS・JS等もOK
• 社内で利用されていたRosettaという
ツールを元にゼロから書き直し
• 今のところアルファ版
http://www.appulsus.com/w/?p=18 7. テンプレートを生成?
• r3形式のテンプレを書いて、任意のテ
ンプレを作る。
–テンプレからテンプレを⽣成
• テンプレのプリコンパイラ的な仕組み
• 対象とするターゲット
–テンプレート (PHP/Smarty etc…)
–ヘルパー的関数ファイル (PHP) など
• ⽇付をフォーマットして出⼒する関数など、
画⾯表⽰に関わる補助的なPHPスクリプト 12. product と intl の掛け合わせ
•cookery/us
•cookery/ca
•cookery/fr
intl
product •cookery/jp
× =
•wine/us
•us
•cookery •wine/ca
•ca
•wine •wine/fr
•fr
•car •wine/jp
•jp
•car/us
12
3 4
•car/ca
•car/fr
•car/jp 14. 継承 (inheritance)
• クラスの継承と同じ考え
• 各dimension (productとintl)について、
それぞれ別の継承関係が設定できる
• intlについては、さらにdomainという
継承関係の細分があり、別に継承可能
–page (ページ)
–template (テンプレ)
–translation (翻訳) 15. プロダクトの継承の例
• ブランディングのため
の基本ルールが統⼀
• その中でも遷移上、UI
が統⼀されているプロ
ダクトもある
• 似てるけど少し違う 16. intlの継承の例
intl (4ヶ国)
•us (アメリカ) •ca (カナダ)
•fr (フランス) •jp (⽇本)
• ⾔語的視点からは、フランス語圏で、
ca(カナダ)は fr(フランス)を継承
• 地域的視点からは、北⽶エリアで、
ca(カナダ)は us(アメリカ)を継承 19. 導入
• 動作環境
–PHP5
–PDOで、MySQL or SQLiteが利用可能
• インストール
–SourceForgeからr3とsticklebackのアー
カイブをダウンロード
• sourceforge.net/projects/rthree
• sourceforge.net/projects/stickleback
–PEARでそれぞれインストール 20. r3 CLI
$ r3
usage:r3 [-c <arg>] [-u] [-x]
the r3 command line interface
-c override the default configuration, use your own
-u display utf8 chars with unicode values
-x display utf8 chars with hex values
usage general help
version r3 version
setup administrative commands
template template control
translation dictionary utilities
target target tools
generate [-a] [-v... generate targets
dimension dimension tools (dimension is one of
product,intl)
inheritance inheritance tools 22. DB設定
• デフォルトのSQLite利用なら、そのま
まコマンド叩くだけで完了
$ r3 setup installdb
installing r3 db
creating r3 db
connecting to r3 db
creating r3 tables
• MySQLを使うときは、r3conf.xmlで設
定 25. 作成するもの
• 3つの独⽴したプロダクト(だけれど、関連
がある)を4つの⾔語で作成します。
• プロダクト
– cookery (料理), wine (ワイン), cars (⾞)
• 地域
– アメリカ (us)
– フランス語圏のカナダ (ca)
– フランス (fr)
– ⽇本 (jp) 26. product と intl の掛け合わせ
•cookery/us
•cookery/ca
•cookery/fr
intl
product •cookery/jp
× =
•wine/us
•us
•cookery •wine/ca
•ca
•wine •wine/fr
•fr
•cars •wine/jp
•jp
•car/us
12
3 4
•car/ca
•car/fr
•car/jp 29. productの作成
$ r3 dimension product create generic_product
product generic_product created
$ r3 dimension product create cookery -p generic_product
product cookery created with parent generic_product for
page, template and translation domains.
$ r3 dimension product create wine -p cookery
product wine created with parent cookery for page,
template and translation domains.
$ r3 dimension product create cars -p generic_product
product cars created with parent generic_product for page,
template and translation domains. 31. intlの作成
$ r3 dimension intl create generic_intl
intl generic_intl created
$ r3 dimension intl create us -p generic_intl
intl us created with parent generic_intl for
page, template and translation domains.
$ r3 dimension intl create ca -p us
...
$ r3 dimension intl create fr -p generic_intl
$ r3 dimension intl create jp -p generic_intl 33. translationの継承設定
$ r3 dimension intl parent ca set fr -d translation
parent of intl ca changed to fr in the translation
domain
# 翻訳ドメインに基底っていらないよなってことで
# translationドメインで基底の継承関係を削除
$ r3 dimension intl parent fr unset -f -d translation
intl fr set with no parent in the translation domain
$ r3 dimension intl parent us unset -d translation
intl us set with no parent in the translation domain
$ r3 dimension intl parent jp unset -d translation
intl jp set with no parent in the translation domain 35. ターゲットの作成
• target create [location]で作成
$ r3 target create ¥
generic_product/generic_intl/index.html
page created (1)
• locationとは、product名/intl名/ペー
ジ名で構成するUNIXパス的なもの
• generic_product/generic_intl な の で 、
最上位のlocationとなる
–継承している⼦孫にも適用される 37. いっぱい出来る (4×5で20サイト)
$ r3 generate -av
generating cars/ca
cars/ca/index.html
generating cars/fr
cars/fr/index.html
generating cars/generic_intl
cars/generic_intl/index.html
generating cars/jp
cars/jp/index.html
generating cars/us
cars/us/index.html
generating cookery/ca
cookery/ca/index.html 39. テンプレートとターゲット
template target
index.php.ros index.php
include
header.ros footer.ros
include
brand.ros 41. searchpath
• ターゲットを⽣成するのに参照するパ
ス
$ r3 template searchpath cookery/us/index.html
0 cookery/us/index.html
1 cookery/us/generic
2 cookery/generic_intl/index.html
3 cookery/generic_intl/generic
4 generic_product/us/index.html
5 generic_product/us/generic
6 generic_product/generic_intl/index.html index.html.ros
7 generic_product/generic_intl/generic 43. 特殊化 (specialize)
$ r3 template specialize cookery/us/index.html
content.ros 0
Template specialised from
generic_product/generic_intl/index.html to
cookery/us/index.html
0 cookery/us/index.html content.ros
1 cookery/us/generic
2 cookery/generic_intl/index.html
3 cookery/generic_intl/generic
4 generic_product/us/index.html
5 generic_product/us/generic
6 generic_product/generic_intl/index.html content.ros
7 generic_product/generic_intl/generic 46. 翻訳ファイル
• 翻訳用のファイルは、”XLIFF”という
OASISで標準化されているローカライ
ズのXMLファイルフォーマット
• 標準化されているので、GUIツール等
もあり扱いやすい
–SunのOLT(open language tools)とか
• ⾔語ごとに分けてエクスポートできる
ので、翻訳業者さんに投げやすい 47. 翻訳ファイルの出力
• エクスポート
$ r3 translation save inherited ¥
generic_product/fr fr.xml
generic_product/fr and inherited
dictionary data saved in file 'fr.xml'
• マージ
$ r3 translation merge fr.xml
dictionary data merged from file 'fr.xml' 48. 翻訳ファイルの中身
<?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?>
<xliff version='1.1' …>
<file original='generic_product/fr/generic'
source-language='en' target-language='fr'
datatype='plaintext'>
<body>
<trans-unit id='1'>
<source>Cars Navigation</source>
<target>Cars Navigation</target>
</trans-unit>
<trans-unit id='2'>
<source>Cars Site Branding</source>
<target>Cars Site Branding</target>
</trans-unit>
</body>
</file>
</xliff> 52. 今後の機能追加予定
• Web GUI
–画⾯を修正するのに、エンジニアが介さ
なくてもOKというのが重要
• CLI及びGUI用のプラグインAPI
–例: カスタムのテンプレートタグや、出⼒
ハンドラ