Skip to content

Localisation and label customisation

edewaele edited this page Nov 27, 2014 · 1 revision

#About locales Each instance of the application may support several languages, or only one, it is yours to decide.

You may wish to customise that locales either to translate the app into another language, or customise the labels in the currently available languages.

Actually, the localisation system is quite crude, it does not use a serious library, such as gettext, but the label customisation is quick and straight-forward (edit one configuration file).

Every locale is made of three files, in a subdirectory of ''locale'' :

  • labels.php: the strings used in the whole application
  • help.html: contents of the help section
  • about.php: contents of the About dialog, this is where you state who you are, and why you made this map available

#Setting labels The file labels.php contains one PHP array, with codes such as "panel.help" and values such as "Caption / Help". To change a label, all you have to do is change the value between quotes and refresh the webpage.

Parking type and attributes

The values with keys in map.parking.*** define the pieces of text that are displayed in parking popups.

When the application was written, only three types of bicycle parking were considered: stands, shed and wall loops, because other type do not exist in the author's city. You can expand the list to fit your own needs, the key here is the value of bicyce_parking in OpenStreetMap.

'map.parking.type'=>array(
		'stands'=> 'Stands',
		'shed' => 'Shed',
		'wall_loops'=>'Wall loops',
		'empty' => 'Unknown type',// 
		'other' => 'Other type'// 
),

map.parking.coveredLabel displays the information contained in OSM's key ''covered''.

The access rules (key access in OpenStreetMap) are displayed according to two arrays :

  • map.parking.accessLabel: labels for parking with no operator values set
  • map.parking.accessLabelWithOpr : labels that mention the operator when the key operator is set in OpenStreetMap, the operator name is represented by "%s"

Statistics

The values with keys in stats.*** define the labels to display in the Statistcs box.

For instance, to customise the list of parking types, you have to edit stats.byType. Just like in the popups, only stands, wall loops and shed were taken in account. The two values ("%s") are the numbers of spaces and parkings.

'stats.byType'=>array(
		"stands"=>"%s spaces on stands (%s)",
		"wall_loops"=>"%s spaces on wall loops (%s)",
		"shed"=>"%s spaces in sheds (%s)",
		"other"=>"%s spaces in other parking types (%s)",
		"unknown"=>"%s spaces in parkings of unknown type (%s)"
)

#Managing locales The file conf.php defines the list of locales available in $LOCALES. This array associates a language code (such as fr) to a subdirectory of locale (eg. fr-fr') that contains the three files cited above.

$LOCALES = array(
	'fr'=>'fr-fr',
	'default'=>'default'
);

According to the language settings of the client, their preferred language will be used if available. If none of their languages matches our list, the ''default'' locale will be used (English).

If you do not want to bother with languages, you can remove all options, except default. The files in locale/default will be used all the time.

$LOCALES = array('default'=>'default');

Clone this wiki locally