Add new comment

warning

Warning, JavaScript is disabled!

JavaScript is not available, maybe because you disabled it globally into your browser settings or you are using an addon like NoScript.

We do not have any dangerous JavaScript running here.
Please enable JavaScript; if you're using NoScript this image will help you adding CoolSoft to your whitelist.

Thanks for your comprehension and enjoy CoolSoft.

Configure Symfony to use gettext translation files

Once finished my Symfony application, I'm now facing with the translation task.

Symfony comes with XLIFF as default translation provider; XLIFF is a good format, which manages correctly UTF-8 charsets, but its editor support is poor.
I tried some editors, most of them in Java, but none satisfied me (all of them are joung and primitives).

gettext() is a stable and well-known choice and, most of all, it has a great Eclipse integrated plugin.
Ok, let's try to configure Symfony to use gettext as translation provider.

Documentation on this argument is a bit confused and does not target version 1.2 of the framework, so this is my contribute.

Enable I18N framework in settings.yml:

#apps/<appName>/config/settings.yml
all:
  .settings:
    charset:                utf-8
    i18n:                   on
    standard_helpers:       [ ...your helpers..., I18N]

Now in documentation you'll read to create a i18n.yml file, and you'll also read that this is deprecated (with no further details on how to proceed).
The right way is to add this config params to your factories.yml file:

#apps/<appName>/config/factories.yml
all:
  i18n:
    class: sfI18N
    param:
      default_culture:  en_US
      source:           gettext

Then create language folders under apps/<appName>/:

&nbsp;apps/<appName>/i18n/<lang>

Now all the i18n related Symfony tasks should use gettext() as translation provider, including i18n:extract. 

You're done, now choose your favorite .po file editor and start translate your application.

My suggestions are: Poedit as standalone editor and gted as Eclipse plugin.

Category: 
warning

Warning, advertise blocker detected!

Advertising images can't be shown, probably due to an advertisement blocker plugin installed into your browser (like Adblock Plus for Firefox or Simple Adblock for Internet Explorer) and/or JavaScript disabled.

CoolSoft is supported by donations and a few (and non-intrusive) banners.

Please disable ad blocking for this website and enable JavaScript. If you're using Adblock for Firefox, this image will help you adding CoolSoft to your whitelist.

Thanks for your comprehension and enjoy CoolSoft.

Close chiudi