# sfi_multilingual_udt_template # shoesforindustry.net # Russ Baldwin # This is a proposed skeleton template for a multilingual UDT. # Version 0.1 # # Use on your page with: # {sfi_multilingual_udt_template lang='en_US'} # setting the display language as appropriate # # If you do not add the 'lang' parameter: # {sfi_multilingual_udt_template} # Then the UDT will use the language set in Admin: # 'Site Admin / Global Settings / Default language' # If no language is set there, then the Tag uses the default (en_US) # # If the language specified is not in the UDT, then the UDT uses the default (en_US) # # # Get the display language parameter, if any, else use the database default (case select statement below) if (isset ($params['lang'])) { // If there is a language parameter, but it is not in the UDT list of languages, then use the default. If this is not set then use a default $setLanguage = $params['lang']; } else { // If no language parameter is specified then try and use display / frontendlang from database with global $gCms; $db = &$gCms->GetDb(); $query ="SELECT ".cms_db_prefix()."siteprefs.sitepref_value FROM ".cms_db_prefix()."siteprefs WHERE sitepref_name = 'frontendlang'"; $frontendLang= $db->GetOne($query); if (isset($frontendLang)) { //OK lang is set in the database so use this for display language $setLanguage =$frontendLang; } else { //NO lang is set in the database so use this a default (en_US) $frontendLang = "en_US"; $setLanguage =$frontendLang; } } // End check for language parameters // You can turn on a debug on which shows the set language - uncomment the line below //$UDTDebug = "

DEBUG

Display language = ". $setLanguage. "

"; //Display strings for UDT (main) alter these as required by your program/language switch($setLanguage) // Add new case statements as desired for more languages { case "de_DE": //All strings used in UDT for text displayed on a site in German / Deutsch $returnString="Dies ist die zurückgegebene Zeichenfolge aus dem sfi_multilingual_udt_template"; break; case "es_ES": //All strings used in UDT for text displayed on a site in Spanish / Español $returnString="Esta es la cadena de regresar de la sfi_multilingual_udt_template"; break; case "fr_FR": //All strings used in UDT for text displayed on a site in French / Français $returnString="Il s'agit de la chaîne retournée par la sfi_multilingual_udt_template"; break; case "nl_NL": //All strings used in UDT for text displayed on a site in Dutch /Nederlandse $returnString="Dit is de geretourneerde string uit de sfi_multilingual_udt_template"; break; default: //(en-US) All strings used in UDT for text displayed as default $setLanguage="en_US"; $returnString="This is the returned string from the sfi_multilingual_udt_template"; break; } // Get your parameters for the UDT... if any... //Your main UDT code probably goes here... this is just returning a string in specified language $returnString='

'.$returnString.'

'; //And return DEBUG infromation if set if ((isset ($UDTDebug))) { $returnString.=$UDTDebug; } #End of your code #Return localised UDT information to your page echo $returnString;