Simple Translations with Oxid eSales by Matthew Setter

Simple Translations with Oxid eSales

January 27th, 2013

You may already be all over this one, but if you’re new to Oxid eSales or new to website internationalization

You may already be all over this one, but if you’re new to Oxid eSales or new to website internationalization, then today’s tip is one not to miss.

When you’re wanting to provide language translations across multiple languages, such as German, English, French, Polish (or whatever), there’s one tag you need to know: oxmultilang.

It's a simple tag that requires next to no effort to use. So here’s how to get your content internationalized.

Step 1. Add Language Terms

Under out/ you’ll find directories for the languages that your site supports. In the default, you’ll see ‘de‘ and ‘en‘, for German and English respectively. In these directories, you’ll see a file called** lang.php**. That’s the default set of Oxid translations.

What you need to do is, essentially, copy that file, naming it** cust_lang.php** and empty it out. After that, follow the original format, adding your translation tags that you’re going to use. For example, below is a sample of what an English version of cust_lang.php could look like when I want to use a tag called PLUS_SHIPPING2.

$sLangName  = “English”;
$aLang = array(
  ‘PLUS_SHIPPING2′ => “Accessories”,
  // the rest of the translations…

Once you’ve created them for your default language, copy and translate them (if you’re multilingual) or add the translations that someone’s provided to you in your other language files.

Do a double check to make sure that they’re all correct and then move on to step 2.

Step 2. Use oxmutilang tags (instead of normal text)

With the translation tags ready, open up your templates that you’ll be adding internationalized content to and start using the oxmultilang tag.

It’s a wonderful tag that’s painfully simple to use. Remembering the sample that we added in step one, in your template, start using it as in the following example:

[{ oxmultilang ident="PLUS_SHIPPING2" }]<br />

ident is the tag name that will be used, to pull text from your translation file and put it in the generated template when it’s rendered. See, nothing could be simpler.

Step 3. Clear the /tmp Directory

Now that you’ve setup translations so that you can use them in your templates and you’ve added the oxmultilang tag to your templates, so that you are using the translations you’ve setup, there’s one step that remains.

Under the application root, you’ll see a directory called /tmp. It’s the base cache directory. It’s also, by default, the directory that the Smarty template system uses to cache it’s generated templates to.

So, delete all the files in that directory and reload your browser (on the page that you’ve added your translation too).

This time, you’ll see your internationalized string being displayed, not normal text. Of course, we need to fully test it.

This time, change to one of the other languages of your shop, which you’ve provided a translation for and check that the text changes to the translation in the translation file of your other language.

Something went wrong?

If you don’t see the text from your translation file displayed when you change languages firstly double check that you did clear out all the files in your /tmp directory.

Then check that you saved the translation files. This will sort out 99% of the issues. If you’ve done all this and it’s still not working, feel free to chat with me in the comments.

Matthew Setter. Ethical Hacker, Online Privacy Advocate, and a Software Engineer.

Matthew Setter

Software Engineer, Ethical Hacker, & Online Privacy Advocate.

Matthew Setter is a software engineer, ethical hacker, privacy advocate, & technical writer, who loves travelling. He is based in Nuremberg, Germany. When he's not doing all things tech, he's spending time with his family, and friends.