sfFormのメッセージの日本語化
以下のようなメッセージファイルを<アプリケーション>/i18n/form.ja.xmlに用意し
<xliff version="1.0"> <file orginal="global" source-language="en_US" datatype="plaintext"> <body> <trans-unit> <source>Required.</source> <target>未入力の必須項目があります</target> </trans-unit> <trans-unit> <source>Invalid.</source> <target>入力した値を再度確認してください</target> </trans-unit> <trans-unit> <source>CSRF attack detected.</source> <target>画面遷移が確認できませんでした</target> </trans-unit> <trans-unit> <source>"%value%" does not match the date format (%date_format%).</source> <target>"%value%"が日付のフォーマット (%date_format%)に一致しません</target> </trans-unit> <trans-unit> <source>The date must be before %max%.</source> <target>日付は %max% より前を指定してください</target> </trans-unit> <trans-unit> <source>The date must be after %min%.</source> <target>日付は %min% より後を指定してください</target> </trans-unit> <trans-unit> <source>"%value%" must be less than %max%.</source> <target>"%value%" は %max% より小さい値を指定してください</target> </trans-unit> <trans-unit> <source>"%value%" must be greater than %min%.</source> <target>"%value%" は %min% より大きい値を指定してください</target> </trans-unit> <trans-unit> <source>Unexpected extra form field named "%field%".</source> <target>"%field%" という不明のフィールドがあります</target> </trans-unit> <trans-unit> <source>"%value%" is too long (%max_length% characters max).</source> <target>入力文字数がオーバーしています (%max_length%文字以下)</target> </trans-unit> <trans-unit> <source>"%value%" is too short (%min_length% characters min).</source> <target>入力文字数が不足しています (%min_length%文字以上)</target> </trans-unit> <trans-unit> <source>"%value%" does not match the time format (%time_format%).</source> <target>"%value%"が時刻のフォーマット (%time_format%)に一致しません</target> </trans-unit> <trans-unit> <source>An object with the same "%column%" already exist.</source> <target>既に登録されています</target> </trans-unit> </body> </file> </xliff>
フォームクラスで
$this->widgetSchema->getFormFormatter()->setTranslationCatalogue('form');
とすればメッセージを日本語化できます。
ただし、getErrorSchema()をechoしたものは日本語化されないですね。
また、細かなメッセージ制御は難しいのが現状。テンプレート側で制御した方が良い印象。
このあたりをメッセージファイルだけでやりとりするのは限界かな。
ただ、とりあえず動くものを作りたいのであればこの部分だけ日本語化しておくだけでも印象は違うかも。(気持ち的なことなんですけどね)