Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Better page name

...

Info
titleTool for translation
On user ML, Tomislav Preksavec proposed a tool to ease translation: https://lists.apache.org/thread/h0b1bvm7lllgg74xx3kmxc2klj82tw4b
The 1st try was very successful: https://github.com/apache/ofbiz-plugins/pull/127

Introduction

OFBiz is used all over the world by companies doing business in their own country or internationally. This has been recognised early on in the project as being key to the adoption of the project and its works, and to have an internationally diverse community.

...

  • entity data translation
  • service messages translation
  • widget element translation
  • content translation


Generic construct of a translation definition

A translation definition is defined in an xml file and governed by the ofbiz-properties.xsd (see https://ofbiz.apache.org/dtds/ofbiz-properties.xsd" ). Translation definitions are also called OFBiz labels, as they are processed through the UiLabelMap services and functionality.

...

<property key="BicycleRack">
     <value xml:lang="en">Bicycle Rack</value>
     <value xml:lang="en-us">Bike Rack</value>
     <value xml:lang="nl">Fietsrek</value>
</property>


Entity data translation

The translation definition for entity data follows the general construct for a translation definition as described in the section above.

...

Info

These translations definitions are used in e.g. selection fields (like of the type check, drop-down, radio), where - to enhance the user experience - rather a descriptive field value of a data record is shown than the id value of that record. E.g.

<ProductTypeproductTypeId="1001"description="Fixed Asset Usage"/>


Service message translation

Service messages, such as error or success messages and others,  are generated by functions (in Groovy, Java, Javascript and xml files). These messages are typically shown in log files and through the render engine on screens to the user.

...

Info
titleCurrent situation (per ultimo 2021)

Currently, service message translations are incorporated in:

  • <Component>ErrorLabels.xml
  • <Component>UiLabels.xml


Widget Element Translation

A translation definition can be applied to particular widget definitions, like screen titles, form, grid, field labels, screenlet titles, container and  label text, etc. These translation definitions can be applied within both widget definitions in xml files and in Freemarker template (.ftl) files for forms, grids and fields

...

Info
titleComponent specific vs generic translation definitions

Translation definitions for widget elements are commonly domain specific, e.g. applicable to accounting, warehousing, sales, etc. 
In OFBiz these elements and thus their translation definitions are grouped through components and their applications, like the domains of PIM and WHM in the product component, and accounting and budgeting in the accounting component. 

Generic translation definitions, however, are not included in the domain oriented <component>UiLabels.xml files, but rather in the CommonUiLabels.xml file in the config folder of the common component in the framework stack


Field widget title translation

Field widget title translations (aka FormFieldTitle label) are a special case of widget translation definitions as they are related to both related to data records (based on field definitions in entity definitions, included in the <component-entitymodel.xml file in the datamodel component) and a widget element definition as defined in a <DomainOriented>Forms.xml file in the widgets folder in a component, eg PaymentManagementScreens.xml in the accounting component.

...

  1. for the field widget definition without a title element (as in '<field name="productId"><display/></field>)

    1. the render looks if a default translation definition is available for the field widget (aka the FormFieldTitle translation definition), and if none is available
    2. show the name of the  field widget ("productId") as a label in spaced camel case, meaning 'Product Id"
  2. for the field widget with a defined title
    1. (as in <field name="internalName" title="${uilLabelMap.ProductName}"><display"/></field>}, show the translation for the given translation definition (<property key="ProductName"> ..</property>)
    2. (as in <field name="product" title="${uiLabelMap.Retrieved} ${uiLabelMap.Product}"><display-entity .../><field>, the translations for each of the given translation definitions (<property key=Retrieved"> ..</property> and <property key="Product"> ..</property>)


Content Translation

Translations fo data records as generated through the content component and application is available for specific elements in other components and entities therefrom, e.g. through the association of a content object with a product object, a locale specific content object can be rendered.


How-to ensure localisation is applied to widget elements

Ensuring that the correct translation is applied by the widget engine given the user's locale is achieved through the inclusion of a property-map element in the <actions>..</actions> in a section widget of a screen widget.

...

  1. the referenced <component>UiLabels.xml file ( "ProductUiLabels", giving ProductUiLabels.xml) in the config folder of the product component
  2. the map-name, as required by the translation functions in the rendering engine and used in the various widget elements (map-name="uiLabelMap")

Best practice(s) regarding translations

First and foremost, apply common sense when considering to contribute a translation definition to the project. Translation definitions and the applications thereof in OFBiz are intended to:

...