Important

You are browsing documentation for version 5.0 of OroCommerce, OroCRM, and OroPlatform, maintained until August 2024 and supported until March 2026. See version 5.1 (the latest LTS version) of the Oro documentation for information on latest features.

See our Release Process documentation for more information on the currently supported and upcoming releases.

Localized Values

Format Values in Twig

Use localized_value twig filter

{# mytwig.html.twig #}
localization.titles|localized_value

Format Values in Layout Configs

Use locale layout data provider and getLocalizedValue().

…/Resources/views/layouts/…/myconfig.yml
 layout:
     actions:
         - '@add':
             ...
             options:
                 ...
                 content: '=data["locale"].getLocalizedValue(data["localization"].getTitles())'

Format Values in Datagrids

Use datagrid property with type localized_value and attribute data_name to set the required property by path, for example titles, relation.subrelation.titles. If the current localization is not detected, SQL relation will be joined to the default fallback values. Otherwise, it will be received by LocalizationHelper; sorters and filters will be removed.

…/Resources/config/oro/datagrids.yml
 datagrids:
     my-localizations-grid:
         source:
             type: orm
             query:
                 select:
                     - l.id
                     - l.name
                 from:
                     - { table: Oro\Bundle\LocaleBundle\Entity\Localization, alias: l }
         properties:
             title:
                 type: localized_value # property type
                 data_name: titles # property path to localized property of an entity
         columns:
             name:
                 label: Name
             title:
                 label: Title
         sorters:
             columns:
                 name:
                     data_name: name
                 title:
                     data_name: title
         filters:
             columns:
                 name:
                     type: string
                     data_name: name
                 title:
                     type: string
                     data_name: title