diff --git a/INSTALL b/INSTALL index da797e3c..cff40ad8 100644 --- a/INSTALL +++ b/INSTALL @@ -188,7 +188,8 @@ PostgreSQL presents some problems in PHP when trying to process the results of a query in a database independent way, so it is more convenient to use a smallint instead of a boolean in PostgreSQL.] -Text descriptions are looked for in the lang files with the tag room.column_name, +Text descriptions are set in the config file using the $vocab_override variable +using the appropriate language(s) and with the tag room.column_name, eg room.coffee_machine, or users.phone enabling translations to be provided. If not present, the column name will be used for labels etc. If you are adding columns to the entry and repeat tables then you only need to add the @@ -201,9 +202,9 @@ coffee_machine tinyint(1) to the room table and add the line -vocab["room.coffee_machine"] = "Coffee machine"; +$vocab_override['en']['room.coffee_machine'] = "Coffee machine"; -to the lang.en file and similarly for other languages as required. MRBS +to the config file and similarly for other languages as required. MRBS should then do the rest and display your coffee machine field on the room pages. @@ -433,9 +434,16 @@ CHANGING TEXT STRINGS --------------------------------------------------------------------------- All the text strings used by MRBS, except those used on the Help page, are held in a -series of lang.* files, for example lang.en for English, or lang.fr for French. If -you want to change some of the text strings used by MRBS, for example change "Room" -to "Computer", then look for the appropriate string in the lang files and edit it. +series of lang.* files, for example lang.en for English, or lang.fr for French. They +are overridden by the $vocab_override array in the config file. If you want to change +some of the text strings used by MRBS, for example change "Room" to "Computer", then +look for the appropriate string in the lang files, remember its tag and set the +$vocab_override variable in the config file. For example + +$vocab_override['en']['ctrl_click'] = "Use Control-Click to select more than one computer"; + +Doing it this way, rather than editing the lang files, will mean that when you upgrade to +the next version of MRBS you will not have to re-edit the lang files. INTERNATIONALISATION diff --git a/UPGRADE b/UPGRADE index 7231d023..c3ea3521 100644 --- a/UPGRADE +++ b/UPGRADE @@ -26,6 +26,14 @@ the upgraded database. You may therefore choose to make a copy of the database for test purposes and check that the upgrade process works before performing the upgrade on your production database. +Upgrading from prior MRBS 1.4.9 +=============================== + +MRBS now supports the $vocab_override config variable. See +systemdefaults.inc.php for more details. If you have customised your version +of MRBS by editing the lang files, you are advised to use $vocab_override instead. +This will make future upgrades easier. + Upgrading from prior MRBS 1.4.6 =============================== diff --git a/web/edit_area_room.php b/web/edit_area_room.php index 252b2f43..4755c387 100644 --- a/web/edit_area_room.php +++ b/web/edit_area_room.php @@ -31,16 +31,18 @@ // in MySQL. // // You can put a description of the column that will be used as the label in -// the form in the appropriate lang file(s) using the tag 'room.[columnname]'. +// the form in the $vocab_override variable in the config file using the tag +// 'room.[columnname]'. +// // For example if you want to add a column specifying whether or not a room // has a coffee machine you could add a column to the room table called // 'coffee_machine' of type tinyint(1), in MySQL, or smallint in PostgreSQL. -// Then in the appropriate lang file(s) you would add the line +// Then in the config file you would add the line // -// vocab["room.coffee_machine"] = "Coffee machine"; // or appropriate translation +// $vocab_override['en']['room.coffee_machine'] = "Coffee machine"; // or appropriate translation // -// If MRBS can't find an entry for the field in the lang file, then it will use -// the fieldname, eg 'coffee_machine'. +// If MRBS can't find an entry for the field in the lang file or vocab overrides, then +// it will use the fieldname, eg 'coffee_machine'. require_once "defaultincludes.inc"; require_once "mrbs_sql.inc"; diff --git a/web/edit_entry.php b/web/edit_entry.php index f046f0d8..cdc113bd 100644 --- a/web/edit_entry.php +++ b/web/edit_entry.php @@ -34,18 +34,18 @@ // in MySQL. // // You can put a description of the column that will be used as the label in -// the form in the appropriate lang file(s) using the tag 'entry.[columnname]'. -// (Note that it is not necessary to add a 'repeat.[columnname]' tag. The -// entry tag is sufficient.) +// the form in the $vocab_override variable in the config file using the tag +// 'entry.[columnname]'. (Note that it is not necessary to add a +// 'repeat.[columnname]' tag. The entry tag is sufficient.) // // For example if you want to add a column recording the number of participants // you could add a column to the entry and repeat tables called 'participants' // of type int. Then in the appropriate lang file(s) you would add the line // -// $vocab["entry.participants"] = "Participants"; // or appropriate translation +// $vocab_override['en']['entry.participants'] = "Participants"; // or appropriate translation // -// If MRBS can't find an entry for the field in the lang file, then it will use -// the fieldname, eg 'coffee_machine'. +// If MRBS can't find an entry for the field in the lang file or $vocab_override, +// then it will use the fieldname, eg 'coffee_machine'. require_once "defaultincludes.inc"; diff --git a/web/language.inc b/web/language.inc index 960e5c12..08a84f57 100644 --- a/web/language.inc +++ b/web/language.inc @@ -352,10 +352,8 @@ $rtl_languages = array('he'); // Get a default set of language tokens, you can change this if you like. // Always include English as the fallback language, in case the selected language // is missing some translated tokens -include "lang.en"; -// include_once just to avoid reloading the 'en' file -include_once "lang." . $default_language_tokens; - +set_vocab('en'); +set_vocab($default_language_tokens); // Get first default set of language tokens for emails. $need_to_send_mail = ($mail_settings['admin_on_bookings'] or @@ -367,7 +365,7 @@ $need_to_send_mail = ($mail_settings['admin_on_bookings'] or if ($need_to_send_mail) { $web_vocab = $vocab; // Save $vocab before it gets overwritten - include "lang." . $mail_settings['admin_lang']; + set_vocab($mail_settings['admin_lang']); $mail_vocab = $vocab; $vocab = $web_vocab; // Restore $vocab } @@ -437,7 +435,7 @@ if (!$disable_automatic_language_changing || $cli_mode) } if (file_exists($lang_file)) { - include $lang_file; + set_vocab($lang); $locale = $lang; // Work out if we're using a RTL language. This variable is used // globally so that we can include the correct stylesheet @@ -463,7 +461,7 @@ if (!$disable_automatic_language_changing || $cli_mode) } if (file_exists($lang_file)) { - include $lang_file; + set_vocab(substr($lang,0,2)); // If we have found a translation, update the locale to match $locale = $lang; break; @@ -705,6 +703,24 @@ function get_datatable_lang() } +function set_vocab($lang) +{ + global $vocab, $vocab_override; + + $lang = strtolower($lang); + // Get the standard language tokens + include "lang.$lang"; + // Apply any site overrides + if (isset($vocab_override[$lang])) + { + foreach ($vocab_override[$lang] as $tag => $str) + { + $vocab[$tag] = $str; + } + } +} + + function get_charset() { return 'utf-8'; diff --git a/web/systemdefaults.inc.php b/web/systemdefaults.inc.php index 7ad34aae..127c309d 100644 --- a/web/systemdefaults.inc.php +++ b/web/systemdefaults.inc.php @@ -932,6 +932,19 @@ // Language selection when run from the command line $cli_language = "en"; +// Vocab overrides +// --------------- + +// You can override the text strings that appear in the lang.* files by setting +// $vocab_override[LANG][TOKEN] in your config file, where LANG is the language, +// for example 'en' and TOKEN is the key of the $vocab array. For example to +// alter the string "Meeting Room Booking System" in English set +// +// $vocab_override['en']['mrbs'] = "My Resource Booking System"; +// +// Applying vocab overrides in the config file rather than editing the lang files +// mean that your changes will be preserved whenb you upgrade to the next version of +// and you won't have to re-edit the lang file. /************* * Reports