Language files

Introduction
 
The Jomres language files can be found in /jomres/languages. They follow the 'old' Joomla style of language string definitions, looking similar to the following.
 
 
define('_JOMRES_COM_MR_SHOWPROFILES','Show profiles');
 
 
You could edit that string to
 
 
define('_JOMRES_COM_MR_SHOWPROFILES','List users');
 
 
To change the button in the configuration panel from "Show profiles" to "List Users".
 
The strings are shown in the Jomres pages in one of two ways. Either by echoing the value of the definition, or by using the jr_gettext function. Two simple examples follow.
 
 
echo _JOMRES_COM_MR_SHOWPROFILES;
 
 
$variable = jr_gettext('_JOMRES_COM_MR_SHOWPROFILES',_JOMRES_COM_MR_SHOWPROFILES);
 
 
It depends on the page in Jomres as to which is used.
 
* Note, Jomres currently comes with 24 language files by default. These files are contributed back to the project by users of the software and as a result, apart from the English language files, they are invariably in different states of translation. This means that most of the non-English files will have some or many definitions which are still in their English form and it is the responsibility of the purchaser to ensure that the language file for their chosen language/languages suits their needs.
 
Discussion
 
There are quite a lot of language definitions in Jomres, somewhere in the region of 1000+. Some of them are unused as they were once used by now non-existent functionality. New language definitions are always added to the end of the language files which makes it easy for users who have upgraded to add their own definitions to the end of the file.
 
Language strings are used in two ways in Jomres, this is because some are passed through a Jomres function called jr_gettext, whereas others are used as is. In the administrator area functions the strings aren't generally passed through the jr_gettext function because they are unlikely to need much translation. Frontend, or guest facing strings, are passed through the jr_gettext function to offer us the Editing mode feature.
 
Whilst you can edit the language files, it's not the best way to translate Jomres. However, if you find that the Editing mode is a little too complex for you, or if you don't expect to upgrade Jomres in the future, then this is a good way to translate labels within the system.
 
To see more information about the PHP define function, please see the manual page http://uk2.php.net/manual/en/function.define.php
 
 
Language Context
 
Jomres offers the ability to have 'context' language files. This can be set in the administrator area's Site Configuration -> Misc tab. This feature gives you to option to set the site's 'main' language file, which is useful if you aren't selling property bookings by default.
 
As mentioned previously, language files are stored in the /jomres/language directory, however there are also sub-directories where the wording in the english language files have been modified to reflect the different property types that Jomres can offer by example.
 
When a new property type is added a new directory is added (if it doesn't already exist) so if you add a property type such as "Mountain Villa" then the directory structure /jomres/language/mountainvilla/ is created. At the same time a copy of the current language file is made in that directory, so if your currently active language file in the Jomres language switcher is German when you're doing this editing then de-DE.php is copied into the /jomres/language/mountainvilla directory. You can then copy any other files that you want in the same directory (eg. en-GB.php) to that same directory.
 
Each time Jomres starts it has to discover the current language and then which language file to use. The workflow looks like this :
 
  1. Check a variety of variables to find out what the current language is (eg de-DE.php).
  2. Next we need to see if we're looking at a specific property. If we are, then we'll look to see if that property's property type has a language file. If it does, we'll use that.
  3. If not, we'll look at the language context. Is there a language file for the context? (eg. /language/propertyrental/de-DE.php) If so, use that file.
  4. If not, we'll fall-back to the /language/ directory and use whatever language file there that corresponds to our current language (eg. /language/de-DE.php).
 
 
 
 
 
Property type specific language strings
 
Jomres offers you the ability to have different language files for different property types. When you create a new property type in the administrator area of Jomres you can give it a Title and a "Property type description". When this information is saved the Title is saved as it is entered into the relevant table but the Property type description has it's text cleaned up by removing non-latin text and spaces. Then a sub directory is created in the languages folder and a copy of the current language file is copied into this folder. This allows you to have different language files for different scenarios, and in fact Jomres comes with several different examples (campsite, propertyrental, vehiclerental and yachtbrokerage) to demonstrate this.
 
 
Upgrading Jomres
 
If you edit the language files, then obviously you'll need to back up your customised language files before you upgrade. Existing Jomres language strings will have been overwritten if they are part of the core languages.
 
If you then use the upgraded version of Jomres and use a new feature or configuration area, you might see something like the string '_JOMRES_COM_MR_LISTTARIFF_TITLE' instead of where you would expect to see a label (eg "Tariffs"). This is because the new version of the Jomres language file has definitions that your 'old' version does not, which is why it's best, when upgrading, to compare your customised language file with the core Jomres one and copy the new definitions from the core Jomres file to your customised file before replacing the core with the customised files.
 
Also note, if you have customised property types (see Property type specific language strings above) then they will not have been overwritten during the upgrade and you'll need to do the same thing to those files to ensure that you don't display unsightly text to your users.
 
A word of caution
 
You need to be careful when editing language files. A common problem is where French language users (who commonly use the ' (single quote) accidently introduce errors such as the following (My French is terrible, so translation examples will be in English).
 
 
define('_JOMRES_COM_MR_SHOWPROFILES','Show p'rofiles');
 
 
The above string will cause a fatal error within PHP because the ' after the "p" has cut short the string to "Show p" and PHP cannot parse the "rofiles" afterwards in a meaningful way.
 
If you find yourself creating this problem, there are two ways to rewrite the line to make it work correctly. You could either wrap the entire string in " (double quotes) or escape the single quote using the \ symbol. Following are both working examples.
 
 
define('_JOMRES_COM_MR_SHOWPROFILES',"Show p'rofiles");
 
 
define('_JOMRES_COM_MR_SHOWPROFILES','Show p\'rofiles');
 
 
Contributing your translations to the Jomres community
 
We don't have the resources to ensure that all of the language files are translated for each and every version of Jomres that's released, which is why some files have been translated more than others. The non-English language files have been contributed by various memebers of the Jomres community over the years, and we rely on existing members contributing their versions of the language files back to the project.
 
If you'd like to contribute a translated file back to the project, that's great. It means that your translation will appear in the next version of Jomres (meaning there's less hassle for you when you upgrade) and other users will benefit from your work. The only thing we ask is that you sign the copyright of the translation over to Woollyinwales IT so that we can ensure that we can continue using the translation in the future.
 
This document is copyright Vince Wooll/Woollyinwales IT, 2011. All rights reserved.