Women in Technology

Hear us Roar



Article:
  Internationalization and Localization with PHP
Subject:   oh, are you mistaken...
Date:   2002-12-11 02:48:13
From:   kirkmc
As a translator, I shudder when I read articles like this. It is the type of short-sighted attitude that makes our work so hard.


As a rule, you should _never_ put strings of text that are to be localized in code of any kind. Not only does it require the translator to work in the code, taking far longer than necessary to translate simple texts, but it runs the risk of the code getting damaged in this translation processe. While some translators know enough about code to work in it, most don't. The last thing you want is for your translated code to come back and find it doesn't work. Or not find it doesn't work, until you discover your site is malfunctioning.


The best way to work with localization is to have separate files for each language, which may contain variables and definition, but which won't contain any real code. Each translator can then work on their language file, which you just roll back into your database.


Kirk

Full Threads Newest First

Showing messages 1 through 1 of 1.

  • Chris Shiflett photo Wrong perspective
    2003-03-28 13:18:08  Chris Shiflett | O'Reilly Author [View]

    It's quite short-sighted to try to launch a semantic argument like this against the merits of the article. Your logic seems to rely completely on whether this article is a tutorial or a real-world example. It is a tutorial, even though it may be based on a real-world example.



    For example, take this:




    $messages = array (
    'en_US'=> array(
    'My favorite foods are' =>
    'My favorite foods are',
    'french fries' => 'french fries',
    'biscuit' => 'biscuit',
    'candy' => 'candy',
    'potato chips' => 'potato chips',
    'cookie' => 'cookie',
    'corn' => 'corn',
    'eggplant' => 'eggplant'
    ),

    'en_GB'=> array(
    'My favorite foods are' =>
    'My favourite foods are',
    'french fries' => 'chips',
    'biscuit' => 'scone',
    'candy' => 'sweets',
    'potato chips' => 'crisps',
    'cookie' => 'biscuit',
    'corn' => 'maize',
    'eggplant' => 'aubergine'
    )
    );


    This is just example code to create the array that he demonstrates how to use. This array doesn't have to be hard-coded, but this article's scope isn't about creating a friendly interface for translators, it's about internationalization for programmers. It is trivial to make a nice little Web application that provides a friendly data entry interface for translators that stores the information in a database. This database can be used to create the array.



    There are plenty of tutorials that demonstrate how to interact with a database. This one is about internationalization and localization.