magento cms

Magento Translations Module

One of best things in magento is you can easily add new language versions to the site. It's all done using CSV files - 1 file for 1 module per language. For most popular languages translations are available as free Magento modules on magento connect.

What if we want to change the translations and don't lose changes after updating magento and translations? Or if we want to have translation common independently of module? Or just list all the texts that were added by us and are not original magento texts? We can create our own very simple translations module.

You need to edit only 2 files:

  • etc/config.xml
    <?xml version="1.0"?>
    <config>
            <modules>
                    <Baobaz_Translations>
                            <version>0.1.0</version>
                    </Baobaz_Translations>
            </modules>
           
            <global>
                    <helpers>
                            <translations>
                                    <class>Baobaz_Translations_Helper</class>
                            </translations>
                    </helpers>
            </global>
           
            <frontend>
                    <translate>
                            <modules>
                                    <Baobaz_Translations>
                                            <files>
                                                    <default>Baobaz_Translations.csv</default>
                                            </files>
                                    </Baobaz_Translations>
                            </modules>
                    </translate>
            </frontend>

    </config>
  • and helper/data.php:
    class Baobaz_Translations_Helper_Data extends Mage_Core_Helper_Abstract
    {

    }

and that's it... Module must be turned on (in etc/modules) and it will work fine.

in app/locale/fr_fr/ we create file Baobaz_Translations.csv and in it we put all the new translations we need.

Then, anywhere in magento - doesn't matter if it's template, block or controller - we can use:

echo Mage::helper('translations')->__('text to translate');

Yes. It is that simple.

eZ Gento, an alternative CMS Module for Magento: Content translation [Part 2]

Content management as a tree structure in eZ-Gento is a big step forward, but it's just a small part of the new features made available.
One of the purposes of Magento store views is to allow you to define additional languages for your e-Store.
Indeed, Magento site can be visited by clients from other countries and we don't want to lose them. That's why, as you know, we can create additional store view and assign each of them to different language.
Magento allows you to duplicate CMS content pages or blocks in order to have one for each store view and therefore one for each language. Having many pages with the same ID can become confusing and hard to manage when you have many pages and/or many languages.

Now everything is easier with ezGento! eZ-Gento comes with automatic mapping between Magento store views and eZ Publish siteaccesses. It means, that when we access the "french" store view, a "french" eZ Publish siteaccess will be asked for content. So if requested page has french translation, it will be displayed.

Remember that there are two main ways of defining content translation in eZ Publish:

  • The first one is to add a translation to an exisiting page. This way one content tree has pages with two (or more) translations.
  • The second one is to define a separate content tree and have a different page structure in a new language. (This is useful when we don't want to limit or when we want to extend content comparing to the initial language.)

Of course it is possible to mix both methods and add only a few additional pages in new language, or just not to translate some of them.

What about friendly URLs? eZ Publish comes with powerful URL management. Different language has its content with proper URL. By default it's created from the page title, but it's also possible to define additional fields just for URL.

For more multilingual features please refer to eZ Publish documentation page.

All that is possible in eZ Publish is now available in Magento thanks to eZ-Gento!

See eZ Gento, an alternative CMS Module for Magento [Part 1] for more informations on eZ Gento.

eZ Gento

eZ Gento, an alternative CMS Module for Magento [Part 1]

Magento is a great software platform for web shops. It gives huge possibilities of products management, sales, promos, etc. Although some of customers demand also more advanced CMS feature. Plain pages structure is enough for sites with a few pages (like homepage, credits, legal mentions). But this might no be sufficient if you want to add more than 50 pages in different languages.
Of course it would be possible to develop additional modules, functions and blocks that will allow to group pages and store in tree structure, but that would be a very expensive part of the developement.
Therefore Baobaz has created a connection between Magento and eZ Publish Enterprise CMS. This solution allows to display eZ Publish pages directly in Magento front end

What is eZ Publish?
eZ Publish has many common points with Magento.

  • Like Magento is one of the best (if not the best) open source e-Commerce solution, eZ Publish is one of the best open source Enterprise CMS.
  • Like Magento, it is a great AMP platform for new extensions development.
  • Like Magento, it has a great community of contributors.
  • Like Magento, it has a lot of references
  • Like Magento with Varien, it was developed by eZ Systems, a strong for-profit company.
  • ...checkout http://ez.no/ for more details !

What we gain with eZ Publish?
A lot:

  • Content tree structure
  • Multilingual pages
  • Content versioning
  • Approval workflow
  • Multimedia direct insert
  • and much more...

Imagine that you can browse tree of content located next to products catalog, pages are in different languages depending on selected store view. It's also possible to define many little trees and put them in different product categories and don't have to take care about proper links placed in many templates. Everything is generated automatically each time new page has been published or exiting modified.

All above was possible thanks to merged Magento and eZ Publish called eZ-Gento. Both installations are placed side by side and contain little extensions responsible for direct communication. Each time user access any content page, Magento module passes part of url to eZ Publish and retrieves generated html content. Such html can be displayed directly on homepage, subpage or as a cms block next to product or as a product description.

So, first step done. If you want to read something more about eZ-Gento possibilities, stay tuned!

Translation in Magento

Translations between languages is quite simple in Magento. For an advanced developer, who has already worked with PHP frameworks, it is not a matter to discuss, but for a beginner it may need a few words of explanation. All texts on the page that should be translated, are stored in CSV files, in /app/locale/[language] directory. The [language] part of the path is build of language code, e. g. 'en_US'.

If you have a look at the files content, you will find that every file structure is the same, one line contains two texts: one in your default language, and one in the destination language. To use the files - also called dictionaries - they must be declared in module's config file (config.xml). You should put this code directly inside your frontend or admin node of the config file.

<translate>
        <modules>
                <companyname_modulename>
                        <files>
                        <default>CompanyName_ModuleName.csv</default>
                        </files>
                </companyname_modulename>
        </modules>
</translate>

That's all. Now, when you want to use a phrase that should be translated, use:

echo $this->__('text to translate');

Magento will look in you dictionary files for the phrase 'text to translate' and will return the corresponding text in the proper language.

How to use Magento CMS feature to create multilingual content

Magento natively integrates CMS features.

Two types of objects are available to allow you to create content in Magento:

  • Pages, which allow you to display general information such as your terms of sale, contact information, store locations, et cetera.
  • Static blocks ( "static" is not quite the appropriate term as discussed below, it means that the content of these blocks is editable directly from the back-office, without modifying php source code), which allow you to enter information to be usually displayed on several pages, such as footers, headers, but also specific informations (predictive site shut down, promotions ...).

Note that these objects, static pages or blocks, may contain elements dynamically calculated and it is relatively easy to make create new ones for the webmaster (for instance to display current date and time, number of online customers, last item sold...).

Furthermore, these blocks and pages can also contain other blocks, static (ie, whose content is changed here) or not (block articles, bestsellers block ...).

Finally, these pages and blocks fit perfectly into the Magento architecture: for the same page or static block identifier, you can (but do not have to) create one version per View Store. It becomes very easy to create specific content for each language and the system will display the version corresponding to the language of the customer without you having wrote a single line of code.

Of course the system is not without fault and we can regret:

  • The lack of a rich text editing tool,
  • The inability to manage hierarchical content,
  • The lack of online form management.

We shall see very soon how to find a workaround these deficiencies.