2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

CakePHP4 国際化の日本語対応

Last updated at Posted at 2021-01-29

あまりまとまった方法が無かったので
国際化の日本語対応について、まとめてみました。

翻訳ファイル作成

cd Cakeフォルダ
./bin/cake i18n extract

(全部否定しないで実行する)

ファイル確認

ls -al resources/locales

以下の2ファイルが作成される。

  1. cake.pot(Cake本体システムで利用されているメッセージ)
  2. default.pot(独自で作成したメッセージ)

日本語ロケールフォルダの作成

mkdir resources/locales/ja_JP/

日本語翻訳ファイルの作成

cp resources/locales/cake.pot resources/locales/ja_JP/cake.po
cp resources/locales/default.pot resources/locales/ja_JP/default.po

出来上がったファイルが翻訳対象のファイルになります。
これをPoeditなどで開いて翻訳処理をします。

日本語翻訳ファイルの反映方法

./bin/cake cache clear_all

ローカル開発の場合の確認方法

./bin/cake server
ls -al tmp/cache/persistent/

更新方法

再度翻訳ファイルを作成して、既存のファイルに差分を取り込みする。

cd Cakeフォルダ
./bin/cake i18n extract

msgmerge -U  resources/locales/ja_JP/default.po resources/locales/default.pot
msgmerge -U  resources/locales/ja_JP/cake.po resources/locales/cake.pot
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?