Revision: 2273
http://mrbs.svn.sourceforge.net/mrbs/?rev=2273&view=rev
Author: cimorrison
Date: 2012-03-09 12:14:11 +0000 (Fri, 09 Mar 2012)
Log Message:
-----------
Introduced the $vocab_override config variable, allowing MRBS text strings to
be customised without editing the lang files, thus making it easier to upgrade
when new versions of MRBS are released. Thanks to dwpoon. See SF ID 3499943
Modified Paths:
--------------
mrbs/trunk/INSTALL
mrbs/trunk/UPGRADE
mrbs/trunk/web/edit_area_room.php
mrbs/trunk/web/edit_entry.php
mrbs/trunk/web/language.inc
mrbs/trunk/web/systemdefaults.inc.php
Modified: mrbs/trunk/INSTALL
===================================================================
--- mrbs/trunk/INSTALL 2012-02-15 17:30:05 UTC (rev 2272)
+++ mrbs/trunk/INSTALL 2012-03-09 12:14:11 UTC (rev 2273)
@@ -188,7 +188,8 @@
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 @@
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,11 +434,18 @@
---------------------------------------------------------------------------
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
---------------------------------------------------------------------------
Modified: mrbs/trunk/UPGRADE
===================================================================
--- mrbs/trunk/UPGRADE 2012-02-15 17:30:05 UTC (rev 2272)
+++ mrbs/trunk/UPGRADE 2012-03-09 12:14:11 UTC (rev 2273)
@@ -26,7 +26,15 @@
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
===============================
Modified: mrbs/trunk/web/edit_area_room.php
===================================================================
--- mrbs/trunk/web/edit_area_room.php 2012-02-15 17:30:05 UTC (rev 2272)
+++ mrbs/trunk/web/edit_area_room.php 2012-03-09 12:14:11 UTC (rev 2273)
@@ -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";
Modified: mrbs/trunk/web/edit_entry.php
===================================================================
--- mrbs/trunk/web/edit_entry.php 2012-02-15 17:30:05 UTC (rev 2272)
+++ mrbs/trunk/web/edit_entry.php 2012-03-09 12:14:11 UTC (rev 2273)
@@ -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";
Modified: mrbs/trunk/web/language.inc
===================================================================
--- mrbs/trunk/web/language.inc 2012-02-15 17:30:05 UTC (rev 2272)
+++ mrbs/trunk/web/language.inc 2012-03-09 12:14:11 UTC (rev 2273)
@@ -352,11 +352,9 @@
// 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
$mail_settings['area_admin_on_bookings'] or
@@ -367,7 +365,7 @@
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 (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 (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 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';
Modified: mrbs/trunk/web/systemdefaults.inc.php
===================================================================
--- mrbs/trunk/web/systemdefaults.inc.php 2012-02-15 17:30:05 UTC (rev
2272)
+++ mrbs/trunk/web/systemdefaults.inc.php 2012-03-09 12:14:11 UTC (rev
2273)
@@ -932,7 +932,20 @@
// 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
*************/
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits