SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do you approach Multilang?

    Hi,

    Quick question, how do you guys nicely approach multilingual pages?
    I'm currently have an ugly quick solution (due to first draft deadline), where a variable is set depending on which language a customer has chosen. And then I fetch values from database, and here's the really ugly part, all values. Including menus and such.

    Anyway, I'd just like to see if there's anyone out there who'd like to share some wisdom?


    Yours,
    stupidknight

  2. #2
    SitePoint Enthusiast
    Join Date
    Jul 2005
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am just in the process of refactoring my web-application to provide the option of several languages.

    The solution I have decided on, and so far very happy with, is gettext using the Zend Framework. Using Zend_Translate and Zend_Locale has so far given me all the options I require, and a nice interface to program against.

    Zend_Translate
    Zend_Locale

    To work with gettext files I find poedit very useful, and for my smarty-templates I use the smartygettext plugin.

    Gettext is a bit tricky to get started with, but when you got poedit up and running translations are easy to create and maintain. If you don't know the Zend Framework this is a framework with several components where one can choose which components to use. Meaning that you don't need to adapt you application to a complete framework in order to use it (just as EZ components).

  3. #3
    SitePoint Evangelist praetor's Avatar
    Join Date
    Aug 2005
    Posts
    479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm using the old array approach (with a little twist to have code completition) mainly because it is the fastest method. ZF is just too slow (with XCache enabled).
    You might argue that a non-programmer will have a hard time to translate it. Believe me, (s)he won't. My designer doesn't know php (nor any programming), but she understood very fast(as in minutes) how to use/add/edit/delete translations.

  4. #4
    SitePoint Enthusiast
    Join Date
    Jul 2005
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not sure about performance when you use ZF, but gettext is as far as I know considered the fastest solution for multi language since it works on compiled binary files.

    Arrays are of course always an option, and you have to consider the size of the application and frequency of change. For a small web-site arrays works just fine, but for large sites/applications they become way to hard to maintain. I work on an application with around 250 templates and around 50 controllers. If I were to manage and update arrays manually for these I would get totally lost. With gettext/poedit I just update the template, and poedit gives me a list over the strings that have changed.

    To nice thing about ZF is that it gives a common interface for all these solutions. You can use Zend_Translate just as well with array translations as gettext. (For a complete list see http://framework.zend.com/manual/en/...e.adapter.html)

    My main point is that here, as most other times, you need to select an approach that fits your needs. Something that is depending on developers, writers, life-time of the application, number of languages, and size.

  5. #5
    SitePoint Enthusiast duff_beer's Avatar
    Join Date
    Jul 2003
    Location
    up in the clouds
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    With this package you can manage your translations in the database or with XML or gettext files:

    http://pear.php.net/package/Translation2/

    (documentation)

    This package handles the localization:

    http://pear.php.net/package/I18Nv2

    HTH

  6. #6
    SitePoint Addict
    Join Date
    Sep 2006
    Posts
    368
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I keep the translated strings in database

    but on first load these are loaded into an associative array and stored in APC cache in ram!

    so far performance is faster than gettext and i have a pile of other options available to me

  7. #7
    SitePoint Addict
    Join Date
    Feb 2007
    Posts
    251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I prefer gettext for the interface, but a custom database solution for user created content. If you write a CMS once with this in mind, you can generally forget about the user created stuff.

    And gettext really does make it easy to manage the translations for the interface, especially with poedit, as stadskle already mentioned.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •