phplanguage-agnosticlanguage-packs

Best practices for creating various language-packs on a site? PHP


I've created a language pack for a site before, but I'm not sure if what I'm doing is the best method.

Basically, all I have is a file with variables defining string constants. Usually a set of arrays where an array usually refers to a particular elements of the site.

Then the site code just includes the appropriate file based on a flag and then echo's out the appropriate array element.

What are some ways of doing this to reduce maintenance headaches and performance?


Solution

  • I suggest using Zend_Translate. It is somewhat a combination of the other suggestions people left here, only more maintainable and better designed.

    You can switch adapters depending on your preference (supports gettext, csv and a multitude of others), you don't need defines or globals polluting your global scope and it is well documented.