以前紹介しましたこのプラグインですが,バージョン3.7.1にて正式に日本語対応となりましたので,以下のローカライズ作業は不要となりました。

元記事:2015-02-01作成

元記事:2015-02-01作成
何をするプラグイン?
Easy TimerはWordPressのページ内にカウントダウンタイマーを表示してくれるプラグインです。
例えば,このページ内で,クーポンの使用期限まであと何日何時間かを表示してくれます。
使用例
このようなカウントダウンタイマーの方法は色いろあるのかもしれないけど,僕が探して導入したのはこのプラグインです。
上のような表示をするには,ショートコードを埋め込みます。
1 2 |
[countdown date=2015/02/06-09:59:59]2015/02/06-09:59まで あと [timer] [after]終了しました。[/countdown] |
[timer]のところに[countdown date=yyyy/mm/dd-hh:mm:ss]で設定した時間までのカウントダウンタイマーを表示してくれます。これを過ぎたら,[after]より後が代わりに表示されるようになります。
日本語へローカライズ
しかしながら,このプラグインは日本語対応ではありませんでしたので,プラグイン内のコードを探してローカライズすることにしました。
設置したWordPress内の,wp-content/plugins/easy-timer/includes/lang-js.php の冒頭の部分を編集します。
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<script type="text/javascript"> string0day = ''; string0hour = ''; string0minute = ''; string0second = ' <?php _e('0 second', 'easy-timer'); ?>'; string1day = ' <?php _e('1 day', 'easy-timer'); ?>'; string1hour = ' <?php _e('1 hour', 'easy-timer'); ?>'; string1minute = ' <?php _e('1 minute', 'easy-timer'); ?>'; string1second = ' <?php _e('1 second', 'easy-timer'); ?>'; stringNdays = ' [N] <?php _e('days', 'easy-timer'); ?>'; stringNhours = ' [N] <?php _e('hours', 'easy-timer'); ?>'; stringNminutes = ' [N] <?php _e('minutes', 'easy-timer'); ?>'; stringNseconds = ' [N] <?php _e('seconds', 'easy-timer'); ?>'; |
ハイライトした部分を次のように書き換えます。
1 2 3 4 5 6 7 8 9 |
string0second = ' <?php _e('0 秒', 'easy-timer'); ?>'; string1day = ' <?php _e('1 日', 'easy-timer'); ?>'; string1hour = ' <?php _e('1 時間', 'easy-timer'); ?>'; string1minute = ' <?php _e('1 分', 'easy-timer'); ?>'; string1second = ' <?php _e('1 秒', 'easy-timer'); ?>'; stringNdays = ' [N] <?php _e('日', 'easy-timer'); ?>'; stringNhours = ' [N] <?php _e('時間', 'easy-timer'); ?>'; stringNminutes = ' [N] <?php _e('分', 'easy-timer'); ?>'; stringNseconds = ' [N] <?php _e('秒', 'easy-timer'); ?>'; |
最初に1回だけローカライズして放置していたのですが,しばらく立ってからプラグインのバージョンアップがあったので行ったところ,元の英語に戻ってしまったので,思い出しながら直しました。