Internationalisation and my PHP Development Infrastructure
By Tony Marston2005-07-17
My Implementation - Load Screen Structure file
This uses the getLanguageSubDir()function to locate the relevant language subdirectory for the ./screens path before loading in the specified screen structure file.
function setScreenStructure ($xml_doc, $root, $screen, $xsl_file)
// extract screen structure from named file and insert details into XML document.
{
// get subdirectory which matches user's language code
$subdir = getLanguageSubDir ('./screens');
$screen = "$subdir/$screen"; // look in subirectory for this screen name
if (!file_exists($screen)) {
// 'File $screen cannot be found'
trigger_error(getLanguageText('sys0056', $screen), E_USER_ERROR);
} // if
require $screen; // import contents of disk file
.....
Note that it does not matter if the only subdirectory that exists for screen structure files is in the default language as all the field labels will be translated into the chosen language at a later stage.
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
