L10NTest02
構成
$MT_DIR/
|__ plugins/
| |__ SettingTest02/
| |__ config.yaml
| |__ lib/
| | |__ L10NTest02
| | |__ Tag.pm
| | |__ L10N.pm
| | |__ L10N
| | |__ ja.pm
| | |__ en_us.pm
| |__ tmpl/
| | |__ system_settingtest02.tmpl
ソース
config.yaml
id: L10NTest02
key: L10NTest02
name: <__trans phrase="_PLUGIN_NAME_">
version: 1.0
description: <__trans phrase="_PLUGIN_DESCRIPTION">
author_name: <__trans phrase="_PLUGIN_AUTHOR">
author_link: http://www.example.com/about/
doc_link: http://www.example.com/docs/
# 言語対応
l10n_class: L10NTest02::L10N
# プラグイン設定画面テンプレート指定
system_config_template: system_l10ntest02.tmpl
# 設定
settings:
# 項目名
test_data:
# 初期値
default:
# スコープ
scope: system
# タグ
tags:
# ファンクションタグ定義
function:
# タグ名と呼び出されるメソッドを定義
L10NTest02Func01: $L10NTest02::L10NTest02::Tag::hdlr_func01
L10NTest02Func02: $L10NTest02::L10NTest02::Tag::hdlr_func02
L10NTest02Func03: $L10NTest02::L10NTest02::Tag::hdlr_func03
tmpl/system_l10ntest02.tmpl
<mtapp:setting id="test_data" label="<__trans phrase="_TEST_INPUT_DATA_">"
hint="<__trans phrase="_TEST_INPUT_">" show_hint=1>
<input type="text" name="test_data" id="test_data"
value="<mt:GetVar name="test_data">" />
</mtapp:setting>
lib/L10NTest02/Tag.pm
package L10NTest02::Tag;
use strict;
sub hdlr_func01{
# 引数を取得
my ($ctx, $args) = @_;
# 結果を返却
return MT->translate("_PLUGIN_NAME_");
}
sub hdlr_func02{
# 引数を取得
my ($ctx, $args) = @_;
# 結果を返却
return MT->translate("_[_1]=SAMPLE_", "Test1");
}
sub hdlr_func03{
# 引数を取得
my ($ctx, $args) = @_;
# 結果を返却
return MT->translate("_[_1]=SAMPLE__[_2]", "Test2", "aaaaaaaaaaaaaaaaaaaaa");
}
1;
lib/L10NTest02/L10N.pm
package L10NTest02::L10N;
use strict;
use base 'MT::Plugin::L10N';
1;
lib/L10NTest02/L10N/ja.pm
package L10NTest02::L10N::ja;
use strict;
use base 'L10NTest02::L10N::en_us';
use vars qw( %Lexicon );
%Lexicon = (
'_PLUGIN_NAME_' => 'L10NTest02',
'_PLUGIN_DESCRIPTION' => 'L10NTest02のテスト',
'_PLUGIN_AUTHOR' => 'プラグイン作者',
'_TEST_INPUT_DATA_' => 'テストデータ',
'_TEST_INPUT_' => 'テストデータ入力',
'_[_1]=SAMPLE_' => '[_1]=サンプル',
'_[_1]=SAMPLE__[_2]' => '[_1]=サンプル=_[_2]',
);
1;
lib/L10NTest02/L10N/en_us.pm
package L10NTest02::L10N::en_us;
use strict;
use base 'L10NTest02::L10N';
use vars qw( %Lexicon );
%Lexicon = (
'_PLUGIN_NAME_' => 'L10NTest02',
'_PLUGIN_DESCRIPTION' => 'L10NTest02 Test',
'_PLUGIN_AUTHOR' => 'Plugin author',
'_TEST_INPUT_DATA_' => 'test data',
'_TEST_INPUT_' => 'test input',
'_[_1]=SAMPLE_' => '[_1]=SAMPLE_',
'_[_1]=SAMPLE__[_2]' => '[_1]=SAMPLE=_[_2]',
);
1;
最終更新:2012年01月28日 11:25