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

blog comments powered by Disqus

Contact

604-637-6396
hiATmugo.ca

#414-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

It's been a pleasure working with Mugo Web. They are fast, efficient and always helpful. They respond positively to questions and offer great solutions to technical problems.

Susan Wright, Director of Operations, Toronto Arts Council and Foundation

We've been extremely pleased with the work Mugo has done for us. They have been responsive and understanding in dealing with the complexities of our needs.

Wendy Prugh, Program Manager, The Christian Science Monitor

The team members we work with at Mugo have demonstrated a high caliber of competency in the work they do, and it instills great confidence in us to know that we have such quality professionals in our corner. Their consistent delivery has helped us develop a fluid system for enacting change and improvements on our website. We certainly look forward to continuing this relationship!

Wendy Prugh, Program Manager, The Christian Science Monitor

Thank you very much Mugo Web for the website work you've done for our company. You valued & respected our time. You produced quality work. You paid attention to detail and understood the JPLradio concept. Most importantly, we appreciate the good business ethic of our contact person your company provided. For that, I/we thank you.

Troy B. Williams, Founder & Program Director, Just Positive Lyrics Radio.com

We thoroughly enjoy our working relationship with Mugo Web. They are customer-focused, take the time to listen, give good solid advice with our best interests in mind, and have a quick turnaround time. We've had a number of compliments on the new website, which looks goods, functions well, and performs solidly.

Paul O'Sullivan, IT Specialist, New Society Publishers

Tweets

  • eZ Flow pull request merged: allowing custom attributes on manual blocks; new custom attribute select type: https://t.co/YlLvWHV9 #ezpublish
    Posted at Fri Feb 03 15:35:51 +0000 2012
  • Switched from Facebook comments to Disqus on our blog; Disqus is much nicer to work with; example with ported comments: http://t.co/oj41cd2K
    Posted at Thu Feb 02 17:14:29 +0000 2012
  • Exact image resizing in eZ Publish with custom image filters http://t.co/RbRqZS7I #ezpublish
    Posted at Wed Feb 01 15:40:21 +0000 2012
  • RT @gggeek: The ultimate content staging extension for #eZPublish is open to contributions. http://t.co/STg5DxNF
    Posted at Tue Jan 31 15:00:47 +0000 2012

Follow Mugo on Twitter