Helping ordinary people create extraordinary websites!
GET OUR NEWSLETTER
Your Email:
 

Internationalisation and my PHP Development Infrastructure

By Tony Marston
2005-07-17


My Implementation - Directory Structure

My main development infrastructure consists of a series of discrete subsystems each of which has its own directory in the file system. (Note that my sample application consists of just a single subsystem). Each of these directories will contain the following new subdirectories:

  • 'help' - for all help text. This is a departure from my existing method whereby help text is stored inside the database, but after a brief moment of reflection I decided it would be easier in the long term to maintain all translatable text in non-database files.
  • 'text' - for all field label, form title, error message and other text.

Each of these new directories will be further broken down into subdirectories where the subdirectory name matches a language code, such as:

  • 'en' - for English
  • 'en-us' - for English (United States)
  • 'fr' - for French
  • 'fr-ca' - for French (Canada)

All subdirectories except 'en' English (my native language) are optional. The files in the 'en' subdirectories identify every piece of text which can be translated, so these should be used as the patterns for any non-English translations.

Each language subdirectory will contain a copy of the file(s) containing the text for that particular language code. If there is no text for a particular language code then there should be no subdirectory for that language code - in other words, there should not be any language subdirectories which are empty.

I also decided to split the existing 'screens' directory (for the screen structure files) into language subdirectories with the intention to use these files to contain the translated field label text, but when I realised that most of the labels were duplicated I decided that it would be easier to define each field label just once in the file which contains all the other translatable text. However, I decided to keep the facility for separate versions of the screen structure files for different languages just in case it should be necessary to adjust more than the label text to suit the needs of a particular language. If no adjustments need to be made to any of the screen structure files then no additional language subdirectories will be necessary as everything will still work successfully with the original files in the 'en' subdirectory - the structures will be identical, but the label text will still be translated.



Tutorial Pages:
» Introduction
» Possible Methods
» Design Decisions
» My Implementation - Directory Structure
» My Implementation - File Names
» My Implementation - Determine User Language
» My Implementation - Locate Language Subdirectory
» My Implementation - Load Screen Structure file
» My Implementation - Get Language Text
» My Implementation - Get Language Array
» My Implementation - Handling Dates
» My Implementation - Handling Numbers
» Conclusion
» References


 | Bookmark
Related Tutorials:
» Port Scanning and Service Status Checking in PHP
» Web Database Access from Desktop Applications
» CubeCart 3.0 Installation and Configuration
» PHP Site Search Made Easy
» Installing and Configuring Drupal 6.1
» Desktop Application Development with PHP-GTK

Advertise with Us!


Tutorials Scripts Web Hosting Developer Manuals
Resources