Translating eZ Publish websites: a simple tool for template/script translations

eZ Publish is well-known as a Content Management System with built-in multi-language features. To present different translations of pages, eZ Publish uses 3 major components: content translation, content class translation, and template / script translation. In this post, we will explain these 3 components and introduce a script to help translate strings in templates.

Let's consider an example -- a product page -- to better illustrate the 3 components. A typical product page might have the main menu, a "login" link, product description text, a product image, and a product status like "Out of Stock" or "Available".

1) Content translation component

A product is represented by one content object in eZ Publish. eZ Publish provides editors with an interface to translate each content object into multiple languages. Editors would provide language-specific product description text, product name, and sometimes a different product image.

2) Content class translation

Each product content object is an instance of a product content class. eZ Publish content classes can also be translated. It is not only important for administration screens but in the case of a product status, also important for the front-end pages displayed to site visitors. The product status would usually be defined in the content class as a "Selection" field. The values "Out of Stock" and "Available" would thus be stored at the content class level and can be translated into multiple languages.

3) Template/script translation

Labels and text used in eZ Publish templates and custom (PHP) modules can be marked as translatable. Then, translations can be created for those strings in the form of XML documents on the file system. When configured correctly, eZ Publish will read the XML translation document relevant to the language that is currently being viewed, and replace the translatable strings with the equivalent translation. Examples of translatable strings at the template level include the "Login" and "Logout" links, and the label text on an HTML button.
While the content translation and content class translation components are relatively intuitive and well-documented, template/script translation warrants a closer look. In order to mark strings as translatable you have to use the "i18n" operator in templates and the "ezi18n" function in PHP scripts.

Then, you create the XML translation documents with a tool called "ezlupdate". (For more details, see this article at ez.no <http://ez.no/ezpublish/documentation/configuration/configuration/language_and_charset/creating_a_new_translation>.) However, the process of creating and maintaining (whenever there are new strings) the XML translation documents is tricky, especially on some operating systems where you would need to compile "ezlupdate" or a similar tool. The process can be painful enough that we decided to create an alternative tool in the form of a PHP command line script. This script can scan an extension directory and create the relevant XML translation documents (with alphabetically sorted elements) from the translatable strings in your templates and module files.

You still need to open the XML document and add the translations for all listed text and labels in that document. You can use your preferred editor to do so. The previously mentioned article suggests the editor "linguist", which enables you to edit the XML documents quite comfortably.

Whenever new strings are added, the command line script will generate new XML translation documents. However, because the elements are sorted alphabetically, you can run a diff comparing the old and new documents to easily see which strings are new or obsolete.

The command line script to create the XML translation documents is available here. We welcome your feedback!

Comments

Contact

604-637-6396
hiATmugo.ca

#610-207 W. Hastings St
Vancouver, BC
Canada


RSS icon Twitter icon

We have been using this team for editing, consulting, support and training services in North America for the last 3 years and we still do. The team has shown their expert knowledge of our systems, and is responsive and dedicated. The services they provide include expert consulting on eZ Publish towards large, high-traffic enterprise customers.

CEO Aleksander Farstad , eZ Systems

I relied on Mugo for the development of two complex web applications, and I was extremely impressed with their accurate estimates, consistent and timely delivery of production code, and commitment. They have the rare blend of business knowledge and deep technical expertise, and they excel at listening to business requirements and translating those requirements into intelligent and reliable software products. They are able to work on all aspects of software solutions -- front end/UI, core code, modules and extensions, application integration, and infrastructure -- and they are extremely capable in all of those areas. I highly recommend Mugo to anyone in need of a competent and dependable technology partner.

Co-Founder Graham Tillotson, Tandem, Chicago

Mugo maintains and develops new features for the Rasmussen Reports website, www.rasmussenreports.com. We are impressed with how efficiently they deliver high quality solutions that exactly fit our needs. The Mugo team understands the complexity of our high traffic website and was able to improve our site's overall performance, as well as its search engine rating. For our site's subscribers, Mugo quickly and efficiently developed many new features for our Premium Section.

The Mugo team is great to work with, and I look forward to a long and productive relationship.

Stephen W Smith, Interim CEO, Rasmussen Reports

If you ask me what is the first thing you think of about the Mugo team, I would say that they listen.

For a customer, the worst thing is to work with a partner that doesn't listen to you. That doesn't understand your points. That simply doesn't listen and try to help you.

Daniel Iribarren, ClearCap

Mugo Web is not another service provider. They are your partners.
One of the things I really like about the Mugo team is that they care about my project and myself. That is why I call them my partners.

Daniel Iribarren, ClearCap

Mugo Web is not just a group of geeks. They are a team of highly knowledgeable technology and business people.
They understand that they are helping you to design solutions to satisfy or solve business problems. And not every developer is able to deliver that. I have worked with more than 10 different let's says production centers and what they delivered to me was geek stuff. Not business solutions.
Mugo Web will help you to use geek stuff to solve business problems.

Daniel Iribarren, ClearCap