CakePHP automating i18n extract shell process from batch file

巧了我就是萌 提交于 2019-12-08 04:40:42

问题


To create default pot file for CakePHP 2.3 i18n, in windows I created a bat file like this.

CD F:\mywork\app\View
F:\mywork\lib\Cake\Console\cake.bat i18n extract

But I get this error:

Your database configuration was not found. Take a moment to create one.
---------------------------------------------------------------
Database Configuration:
---------------------------------------------------------------
Name:
[default] >

But inside app\Config\database.php file I have database configurations and they work well. So I removed extract argument.

I created a new bat file like this.

CD F:\mywork\app\View
F:\mywork\lib\Cake\Console\cake.bat i18n

When I run bat file, I get this:

[E]xtract POT file from sources
[I]nitialize i18n database table
[H]elp
[Q]uit
What would you like to do? (E/I/H/Q)

I select E. I get this:

Current paths: None
What is the path you would like to extract?
[Q]uit [D]one
[F:\mywork\app\View\] >

I press Enter. I get this:

Current paths: F:\mywork\app\View\
What is the path you would like to extract?
[Q]uit [D]one
[D] >

I press Enter. I get this:

Would you like to extract the messages from the CakePHP core? (y/n)
[n] >

I press Enter. I get this:

What is the path you would like to output?
[Q]uit
[F:\mywork\app\View\Locale] >

I paste this: F:\mywork\app\Locale\eng\LC_MESSAGES. Than I get this:

Would you like to merge all domains strings into the default.pot file? (y/n)
[n] >

I press Enter. cake starts to process all View files. Creates pot file. Then I get this:

[E]xtract POT file from sources
[I]nitialize i18n database table
[H]elp
[Q]uit
What would you like to do? (E/I/H/Q)

I press Q and program ends.

Is it possible to automatize this process ? Setting paths beforehand and not selecting options by hand ?


回答1:


Just working on the same issue. You need to start

cake.bat i18n extract

from the /app path and not from the view path. The process can be automated for comma-seperated list of files:

cake i18n extract --files %ListOfFiles% --ignore-model-validation --output .\Locale\eng\LC_MESSAGES\ --paths .\View  --overwrite no --extract-core no --merge no

Should also work without a list of files:

cake i18n extract --ignore-model-validation --output .\Locale\eng\LC_MESSAGES --paths .\View  --overwrite no --extract-core no --merge no


来源:https://stackoverflow.com/questions/15722716/cakephp-automating-i18n-extract-shell-process-from-batch-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!