Question

We are creating a new template and have some new text which are not yet defined anywhere.

If they would be defined before we would add some

"Mage_TheModule::Foo";"Fuh"

to the translate.csv in the theme.

What is a good way to deal with new translations?

Shall they be added just to the translate.csv plainly without a module code?

Or is it better / required to create an own module just for the translations?

Was it helpful?

Solution

The best practice depends on the intended use of the theme: Is it a theme that is going to be distributed and reused or is it a project specific theme?

1. Distributed Theme, intended for reuse

Avoid using translate.csv at all in this case. As soon as the end user adds his own translate.csv to his child theme, this will override yours (the usual them fallback mechanism applies). They would need to copy everything from the original file and keep track of changes.

Instead, use a theme module. Most themes come with one or more modules that contain mostly theme specific blocks, but also new translations. Then use Mage::helper('yourtheme')->__('your string') for translations and:

  1. You are safe from conflicts with third party modules
  2. Users can override this specific translation with Your_Theme::your string in their translate.csv

2. Project specific theme

For translations in a project specific theme, translate.csv was invented, so I would use it.

You should know that the module scope is not directly connected to existing translations in the respective CSV files. So you can use an existing translation scope without adding a new module or modifying module CSV files.

For example if I add a custom translations, that is used on the product page within a Mage_Catalog block, the translation looks like this:

"Mage_Catalog::New translation","New translation"

More on how to find out the scope of a specific translation here: Translations and hierachy of authority

(or you could use my TranslationHints extension)

OTHER TIPS

My preferred method - especially if you need module-specific translations or want to distribute the module - is to create module-specific CSV files (defined in your Module's config.xml) and drop them into app/locale's respective translation directories. Your 'theme' will figure out which one to use due to locale language settings.

If it's theme-specific, don't use Module code in translate.csv. I personally don't like translate.csv at all - but I prefer it to inline translation - and.

translate.csv should be for end-users of your product who have to make tweaks (e.g. Shopping Bag vs. Shopping Cart) to your theme.

Edit: two years later to correct an old belief I once held.

If they are theme specific, you should add them to translate.csv.
If your website is only in English, you can even ignore the translation.
If your website is in other language and the texts have meaning depending on one or more modules you should add those texts in the translation file of that specific module. (but don't modify the English files).
I usually take the second approach, because on the next "face lift" of the website I don't have to duplicate the translate.csv file of the theme.
You can also create a separate extension that will only handle the text translation, but if you do you have to call each text like this: Mage::helper('myhelper')->__('Some text'). This is ok for internal use but if you want to reuse the templates you will have to migrate the extension also from one project to an other.

Your question is rhetorical and vague at the same time.

My approach is exactly as you described in your question. If the translations are not module specific put it plain "text":"text" into the translate.csv of your theme. It will exclude module dependencies and will also make your theme re-distributable with translations.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top