简体   繁体   English

Sonata Admin Bundle中的标签

[英]Labels in Sonata Admin Bundle

I have started new with the sonata admin bundle. 我已经开始使用sonata管理包了。 its very handy and easy to setup and use , but i can't seem to get the translation fixed for the default labels 它非常方便,易于设置和使用,但我似乎无法修复默认标签的翻译

eg link_add, link_list are coming instead of proper english labels. 例如link_add,link_list来了,而不是正确的英文标签。

#SonataAdmin
    sonata_block:
    default_contexts: [cms]
    blocks:
        sonata.admin.block.admin_list:
            contexts: [admin]
        sonata.block.service.text:
        sonata.block.service.rss:

sonata_admin:
    title:      Sonata Project
    title_logo: /bundles/sonataadmin/logo_title.png
    templates:
        # default global templates
        layout:  SonataAdminBundle::standard_layout.html.twig
        ajax:    SonataAdminBundle::ajax_layout.html.twig

        # default actions templates, should extend a global templates
        list:    SonataAdminBundle:CRUD:list.html.twig
        show:    SonataAdminBundle:CRUD:show.html.twig
        edit:    SonataAdminBundle:CRUD:edit.html.twig

    dashboard:
        blocks:
            # display a dashboard block
            - { position: left, type: sonata.admin.block.admin_list }

This is my config file and these are the basic default settings provided by the documentation. 这是我的配置文件,这些是文档提供的基本默认设置。 what am i missing here to enable labels for the default view params ? 我在这里缺少什么来为默认视图参数启用标签? can anybody help 任何人都可以帮忙

for translate menu and forms override file: SonataAdminBundle.[your_language].xliff (with content from: vendor/sonata-project/admin-bundle/Sonata/AdminBundle/Resources/translations/SonataAdminBundle.[your_language].xliff ), put file in: 翻译菜单和表单覆盖文件: SonataAdminBundle.[your_language].xliff (内容来自: vendor/sonata-project/admin-bundle/Sonata/AdminBundle/Resources/translations/SonataAdminBundle.[your_language].xliff ),将文件放入:

app/Resource/SonataAdminBundle/translations/

full path: 完整路径:

app/Resource/SonataAdminBundle/translations/SonataAdminBundle.[your_language].xliff

If you want to translate your labels for field, you must create translate file in your bundle, for example: 如果要翻译字段标签,则必须在捆绑中创建翻译文件,例如:

src/YourAlias/YourNameOfBundle/Resources/translations/YourAliasYourNameOfBundle.[your_language].xliff

if your Admin class is in 如果你的Admin类在

src/YourAlias/YourNameOfBundle/Admin/YourClassAdmin.php

Sonata use FOSUserBundle and if you want change translation for users module, you must ovverride file: FOSUserBundle.[your_language].yml in: Sonata使用FOSUserBundle ,如果你想更改用户模块的翻译,你必须ovverride文件: FOSUserBundle.[your_language].yml in:

app/Resource/FOSUSerBundle/translations/FOSUserBundle.[your_language].yml

and analogously for SonataUserBundle SonataUserBundle类似

I use that configuration and everything works! 我使用那个配置,一切正常!

Expanding on @mkjasinski's comment above, the Symfony Translation component expects to find a _locale property on the request. 扩展@ mkjasinski上面的评论,Symfony Translation组件希望在请求中找到_locale属性。 If this is missing, or no translation can be found for the specified locale, it uses a fallback value. 如果缺少此选项,或者找不到指定语言环境的转换,则会使用回退值。 However this fallback value is also blank by default hence seeing the translation labels instead of text. 但是,默认情况下,此回退值也为空,因此会看到翻译标签而不是文本。

To fix this, set the default translation locale by adding the following to config.yml : 要解决此问题,请通过将以下内容添加到config.yml来设置默认转换语言环境

framework:
  #...
  translator:
    fallback: %locale%

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM