我在管理菜单中翻译组时遇到问题。它翻译标签但不翻译组:
服务: sonata.admin.language: class:App \ Bundle \ LanguageBundle \ Admin \ LanguageAdmin 标签: - 名称:sonata.admin manager_type:orm 组:“admin.menu.group.language” label:“admin.menu.group.item.languages” 参数: - 〜 - App \ Bundle \ LanguageBundle \ Entity \ Language - 〜
[ERROR ] FWLSE0081E: Failed synchronizing application from database. [project testApp]
Could not open JPA EntityManager for transaction; nested exception is <openjpa-1.2.2-r422266:898935 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: Communications link failure
The last packet successfully received from the server was 19 milliseconds ago. The last packet sent successfully to the server was 18 milliseconds ago.
[ERROR ] FWLSE0074E: Failed synchronizing adapters from database. [project testApp]
Could not open JPA EntityManager for transaction; nested exception is <openjpa-1.2.2-r422266:898935 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: Communications link failure
The last packet successfully received from the server was 0 milliseconds ago. The last packet sent successfully to the server was 0 milliseconds ago.
[ERROR ] FWLSE0188E: Failed to connect to MYSQL database : Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. [project testApp]
[ERROR ] Connection to the database failed
Connection to the database failed
[ERROR ] FWLSE0188E: Failed to connect to MYSQL database : Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. [project testApp]
[ERROR ] FWLSE0081E: Failed synchronizing application from database. [project testApp]
Could not open JPA EntityManager for transaction; nested exception is <openjpa-1.2.2-r422266:898935 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
[ERROR ] FWLSE0188E: Failed to connect to MYSQL database : Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. [project testApp]
[ERROR ] FWLSE0074E: Failed synchronizing adapters from database. [project testApp]
Could not open JPA EntityManager for transaction; nested exception is <openjpa-1.2.2-r422266:898935 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
任何人都可以帮忙???
答案 0 :(得分:2)
当我添加
label_catalogue: "YourBundleName"
进入“标签”部分,它可以帮助我翻译组的标签。
答案 1 :(得分:1)
不幸的是,建议的答案对我不起作用:它仍未被翻译。 这就是我必须做的事情:
由于某种原因,label_catalogue:“messages”甚至对[setTranslationDomain,[messages]]的调用都没有改变任何东西:Symfony仍然会寻找要在SonataAdminBundle.en.yml内部翻译的字符串(我使用yml文件。)
因此,在app / Resources / translations /中创建一个文件SonataAdminBundle.en.yml(或xml,无论你使用哪个),并在其中添加你的组字符串:
admin:
menu:
group:
language: Language
在config.yml中,在sonata_admin下添加以下行:
sonata_admin:
[...]
dashboard:
groups:
admin.menu.group.language: ~
清除缓存。重要!在我这样做之前,某种程度上并没有翻译它。
还可以使用Symfony转换调试器来了解它在哪里寻找一些字符串。
希望这有帮助!
答案 2 :(得分:0)
使用“ SonataAdminBundle”域翻译菜单组标签,但是使用“消息”域或在Admin类的$ translationDomain变量中定义的域来翻译项目标签。
答案 3 :(得分:0)
对我来说,@ Andrey和@Catalins答案的组合可以解决问题:
config/packages/sonata_admin.yaml
sonata_admin:
...
dashboard:
blocks:
-
position: left
type: sonata.admin.block.admin_list
groups:
app.admin.group.cms:
label: 'app.admin.group.cms'
label_catalogue: 'messages' # <--- this is not the bundle name, but the "translation domain" / filename of the translation file
items:
- app.admin.page
roles: ['ROLE_ADMIN']
...
和translations/messages.en.yml
中的
app:
admin:
group:
cms: CMS
pages:
label: Pages
答案 4 :(得分:-1)
你可以添加&#34;翻译&#34;节点:
translation: YourBundle