Skip to content
Snippets Groups Projects
Commit 7ecd4423 authored by Reuben Turk's avatar Reuben Turk
Browse files

#317432 by nedjo, hailu, catch & stella - Allow marker type titles to be translated.

parent 644908a3
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,8 @@ If you are using the HTML filter, it will need to appear BEFORE the GMap filter;
* If you would like to use third party functionality such as mouse wheel support
or Clusterer, read thirdparty/README.txt for download links and instructions.
* If you are translating this module to a different language also see the gmap.strings.php file for further installation instructions. This is required for translation of marker type strings to work.
Google Maps and XHTML
---------------------
......
<?php
// $Id$
function gmap_marker_labels_potx() {
$marker_labels = array(
0 => t('Small Red'),
1 => t('Small Bright red'),
2 => t('Small Orange'),
3 => t('Small Pale Yellow'),
4 => t('Small Yellow'),
5 => t('Small Pale Green'),
6 => t('Small Green'),
7 => t('Small Dark Green'),
8 => t('Small Flouro Green'),
9 => t('Small Pale Blue'),
10 => t('Small Light Blue'),
11 => t('Small Blue'),
12 => t('Small Dark Blue'),
13 => t('Small Purple'),
14 => t('Small Pink'),
15 => t('Small Bright Pink'),
16 => t('Small Brown'),
17 => t('Small White'),
18 => t('Small Light Gray'),
19 => t('Small Gray'),
20 => t('Small Black'),
21 => t('Small Blue (Alternate)'),
22 => t('Small Red (Alternate)'),
23 => t('Big Blue'),
24 => t('Big Red'),
25 => t('X marks the spot'),
26 => t('Sunday'),
27 => t('Monday'),
28 => t('Tuesday'),
29 => t('Wednesday'),
30 => t('Thursday'),
31 => t('Friday'),
32 => t('Saturday'),
33 => t('Week'),
34 => t('Blank'),
35 => t('Cluster'),
36 => t('Drupal'),
37 => t('Line Vertex'),
38 => t('Letters'),
39 => t('Blue'),
40 => t('Gray'),
41 => t('Green'),
42 => t('Light Blue'),
43 => t('Orange'),
44 => t('Pink'),
45 => t('Purple'),
46 => t('White'),
47 => t('Yellow'),
48 => t('Numbers'),
49 => t('Route'),
);
return $marker_labels;
}
<?php
// $Id$
/**
* gmap.strings.php
*
* PURPOSE
*
* This is a stand-alone script which takes markers titles and wraps them in t()'s.
* The reason we want to do this is because variables can not be passed through t()
* with .pot files generated by the potx module.
*
* The result of running this script should be the creation of a file in the root of the gmap module's
* directory, called 'gmap.strings.inc', containing a function 'gmap_marker_labels' which returns an
* array holding each of the marker labels wrapped in t().
*
* INSTALLATION
*
* This script needs to be run within drupal, so the best way to accomplish this is to install and enable
* the devel module, then, enable the 'Execute PHP' block somewhere.
*
* Then, just paste this script into the text field in the Execute PHP block, and click 'Execute'!
* This will create the gmap.strings.inc file in the gmap module's directory - be sure to adjust the permissions
* of this new file appropriately!
*/
$markerdir = variable_get('gmap_markerfiles', drupal_get_path('module', 'gmap') . '/markers');
// The following routines are designed to be easy to comprehend, not fast.
// This whole process gets cached.
// Get the ini files.
$inifiles = file_scan_directory($markerdir, '.*\.ini$');
$labels = array();
foreach ($inifiles as $file) {
$icon_data = parse_ini_file($file->filename, TRUE);
foreach ($icon_data as $icon_set) {
if (isset($icon_set['name'])) {
$marker_labels[] = "t('" . $icon_set['name'] . "'),";
}
}
}
// Create a .inc file for our info.
$gmap_strings_inc_name = drupal_get_path('module', 'gmap') . '/gmap.strings.inc';
// Open our file.
$gmap_strings_inc_handle = fopen($gmap_strings_inc_name, 'w');
// Format the data.
$label_container .= "<?php\n\nfunction gmap_marker_labels_potx() {\n";
$label_container .= "\$marker_labels = array(\n";
foreach ($marker_labels as $label_key => $label) {
$label_container .= "$label_key" . ' => ' . "$label" . "\n";
}
$label_container .= ')';
$label_container .= ";\n";
$label_container .= "return \$marker_labels\n";
$label_container .= '}';
// Write file.
if (fwrite($gmap_strings_inc_handle, $label_container) !== 'FALSE') {
drupal_set_message(t('File gmap_strings.inc successfully created.'));
}
?>
......@@ -244,7 +244,7 @@ function _gmap_get_marker_titles() {
$titles = array();
foreach ($inis as $ini => $inidata) {
foreach ($inidata as $k => $v) {
$titles[$k] = $inis[$ini][$k]['name'];
$titles[$k] = t($inis[$ini][$k]['name']);
}
}
return $titles;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment