--- 2.3.5 までのコードは、gettext.so がロードされていれば *無条件に* gettext が実行されるようになっているので、Ethna 独自のメッセージカタログとの選択がわかりづらいため。
--- 2.3.5までのコードで gettext を利用している場合は、設定が明示的に必要です。
-- "ethna add-project" コマンドに [-l|locale] オプションを追加
+-- "ethna add-project" コマンドに [-e|encoding] オプションを追加
-- スケルトンの日本語コメントをすべてASCIIに変更(好みのエンコーディングで編集できるようにするため)
-- gettextを使わない場合向けに、Ethna独自のメッセージカタログを実装
--- ini ファイルライクなフォーマットで msgid と翻訳を格納する方式
* も追加してコピーする
* @param string $locale ロケール名
* (ロケール名は、ll_cc の形式。ll = 言語コード cc = 国コード)
+ * @param string $encoding プロジェクトで使用するエンコーディング
* @return bool true:成功 Ethna_Error:失敗
*/
- function generate($id, $basedir, $skeldir, $locale)
+ function generate($id, $basedir, $skeldir, $locale, $encoding)
{
$dir_list = array(
array("app", 0755),
$macro['project_prefix'] = $id;
$macro['basedir'] = realpath($basedir);
$macro['locale'] = $locale;
+ $macro['client_enc'] = $encoding;
$macro['action_class'] = '{$action_class}';
$macro['action_form'] = '{$action_form}';
*/
function perform()
{
- $r = $this->_getopt(array('basedir=', 'skeldir=', 'locale='));
+ $r = $this->_getopt(array('basedir=', 'skeldir=', 'locale=', 'encoding='));
if (Ethna::isError($r)) {
return $r;
}
$locale = 'ja_JP'; // default locale.
}
- $r = Ethna_Generator::generate('Project', null, $app_id, $basedir, $skeldir, $locale);
+ // encoding
+ if (isset($opt_list['encoding'])) {
+ $encoding = end($opt_list['encoding']);
+ if (function_exists('mb_list_encodings')) {
+ $supported_enc = mb_list_encodings();
+ if (!in_array($encoding, $supported_enc)) {
+ return Ethna::raiseError("Unknown Encoding : $encoding", 'usage');
+ }
+ }
+ } else {
+ $encoding = 'UTF-8'; // default encoding.
+ }
+
+ $r = Ethna_Generator::generate('Project', null, $app_id, $basedir, $skeldir, $locale, $encoding);
if (Ethna::isError($r)) {
printf("error occurred while generating skelton. please see also error messages given above\n\n");
return $r;
{
return <<<EOS
add new project:
- {$this->id} [-b|--basedir=dir] [-s|--skeldir] [-l|--locale] [Application id]
+ {$this->id} [-b|--basedir=dir] [-s|--skeldir] [-l|--locale] [-e|--encoding] [Application id]
EOS;
}
function getUsage()
{
return <<<EOS
-ethna {$this->id} [-b|--basedir=dir] [-s|--skeldir] [-l|--locale] [Application id]
+ethna {$this->id} [-b|--basedir=dir] [-s|--skeldir] [-l|--locale] [-e|--encoding] [Application id]
EOS;
}
}