gpt4 book ai didi

cakephp - 在CakePHP中本地化timeAgoInWords

转载 作者:行者123 更新时间:2023-12-04 18:12:37 25 4
gpt4 key购买 nike

在我的CakePHP应用程序中,
通过使用cake.bat,我创建了POT文件,并且通过使用PoEdit,我创建了PO文件。
因此,通过编写 __('myword'),我可以在我的应用程序中成功看到本地化的单词。

但是现在我需要本地化“timeAgoInWords”。
当我运行 cake i18n提取时,脚本未获得中的 _dn()单词CakeTime
http://api20.cakephp.org/view_source/cake-time#line-522

因此,我创建了一个 dummy.ctp 文件,并将粘贴内容从蛋糕时间文件复制到虚拟文件。
我运行蛋糕脚本,然后再次执行POEdit。然后它将以下实例创建到文件 app/Locale/tur/LC_MESSAGES/default.po

#: View\App\dummy.ctp:30;33
msgid "%d minute"
msgid_plural "%d minutes"
msgstr[0] "%d dakika"
msgstr[1] "%d dakika"

在core.php中,我已经将默认语言设置为土耳其语:
Configure::write('Config.language', 'tur');

但是当我检查我的申请时, timeAgoInWords 的结果是英语。

我怎样才能解决这个问题

最佳答案

Cake的消息被提取到另一个域中,在本例中为cake域。这意味着蛋糕消息将不会被提取到您的default.pot文件中,而是会进入cake.pot文件中。

令人奇怪的是,cake.pot似乎未包含在下载中,i18n shell也不允许您在提取过程中传递参数以包含cake core。但是,它仍然很容易做到(我的评论以#开头):

$:/var/www/path/app$ cake i18n extract

# if will ask you here if you want to extract from your app folder
# simply press enter to confirm
What is the path you would like to extract?
[Q]uit [D]one
[/var/www/path/app/]

# now it will ask you again, in this case enter the cake path
What is the path you would like to extract?
[Q]uit [D]one
[D] > /var/www/path/lib/Cake

# third time, just press enter
What is the path you would like to extract?
[Q]uit [D]one
[D] >

# press enter to accept the app/Locale
What is the path you would like to output?
[Q]uit
[/var/www/path/app//Locale] >

# press enter to keep translation domains deparate
Would you like to merge all domains strings into the default.pot file? (y/n)
[n] >

现在等待提取完成并享受翻译的痛苦;)

关于cakephp - 在CakePHP中本地化timeAgoInWords,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10402330/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com