SilverCart Forum

We moderate this Forum and we're here to help. Have you already run a forum search to check if your problem has already been solved?

You can help us helping you by providing detailed error messages, screenshots and logfile entries.

SebastianRamon

Page: 1
Topic translating workflow 490481 Views

translating workflow

29 June 2011 at 8:47am

Hello,

I really like how SilverStripe and SilverCart are organized..don't know if can be called 'German engineering', but it's very clean how one puts module together, layout of the whole project etc.

There is, however, one thing which I notice in comparison with Concrete5 and that is how the translation is done in SS & SC (C5 uses gettext & *.po) by using PHP arrays.

When one uses gettext, it's easy to use some tool like poedit,emacs, vim and have decent support for doing translation, maintaining it, keeping under VCS etc. so I wonder if you can shed some light on the translation workflow?

Sincerely,
Gour

Re: translating workflow

29 June 2011 at 10:21am

Hi Gour,

SilverStripe manages its translation in a global array $lang. The array uses two key levels to identify the translation value (e.g. to relate a value to a specific template). There are a few lang files in the /silvercart/lang directory. This files are used for SilverCart only. The base files can be found in /sapphire/lang.

This is the base structure, to provide custom module translations. (/MODULDIR/lang/LOCALE.php).

The default locale to use must be set in your _config.php (e.g. /mysite/_config.php) by setting the following code (this example sets the default to American English):

i18n::enable();
i18n::set:default_locale('en_US');

To provide an own translation, not yet included into SilverCart, just copy /silvercart/lang/en_US.php to your projects lang directory (e.g. /mysite/lang) and rename the file to your custom locale.
Then, of course ;-), you have to translate the values of the copied files array.

To set custom translations on existing translation files, you can provide an i18n plugin. How to add one is described in Setting the language.

I will provide a documentation section for this issue on our techbase today.

If you are providing an own translation, perhaps for Croatia ;-), it would be great to share it with us, to get this into the default SilverCart module.

Cheers,
Sebastian

Re: translating workflow

29 June 2011 at 11:06am

SilverStripe manages its translation in a global array $lang. The array uses two key levels to identify the translation value (e.g. to relate a value to a specific template).

That's clear.

To provide an own translation, not yet included into SilverCart, just copy /silvercart/lang/en_US.php to your projects lang directory (e.g. /mysite/lang) and rename the file to your custom locale.
Then, of course ;-), you have to translate the values of the copied files array.

That's the part I was interesting about...when the system is using gettext() mechanism, one can use some dedicated tool to handle *.po files and it's very easy to see how much is translated, what is not translated etc.

However, it looks that gettext() is not used widely within PHP community, so I may have to adjust to it.

E.g. SS use web-based translation, so I cannot take advantage of po-support in my editor nor use e.g. Launchpad translation system to consult for terms which are common across many different open-source projects.

If you are providing an own translation, perhaps for Croatia ;-), it would be great to share it with us, to get this into the default SilverCart module.

Sure. I'm glad to share it and contribute back to SC a bit... :-)

Let me just become a (little) bit more familiar with the SC & SS in general.