? 710908-style_plugin-70.patch ? 710908-style_plugin-72.patch ? 750810-export-translation-30.patch ? 750810-export-translation-40.patch ? 820982-behavior-ui-improvements-3.patch ? DraggableLayers4.patch ? fullscreen_initially_activated.patch ? openlayers-896868_03.patch ? includes/layer_types/tilecache.inc ? includes/layer_types/js/tilecache.js Index: openlayers.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/openlayers/openlayers.module,v retrieving revision 1.69.2.81 diff -u -p -r1.69.2.81 openlayers.module --- openlayers.module 11 Aug 2010 14:42:55 -0000 1.69.2.81 +++ openlayers.module 5 Sep 2010 16:44:31 -0000 @@ -50,6 +50,50 @@ function openlayers_theme($existing, $ty ); } + /** + * Translate or update user defined string. + * + * Wrapper function for 18nstrings translation function + * so that translations can be supported even without this + * module, but in a limted way. + * + * @param $name + * Textgroup and location glued with ':'. + * @param $string + * String in default language. Default language may or may not be English. + * @param $langcode + * Optional language code if different from current request language. + * @param $textgroup + * A prefix for the $name of the string to translate. + * + * @return $string + * Translated string, $string if not found + */ +function openlayers_translate($name, $string, $langcode = NULL, $textgroup = 'openlayers') { + // Translate function. It seems like instead of tt, i18n is moving + // to il8nstrings() as the translation function. + $func = 'i18nstrings'; + + // Provide automatic prefix + $name = $textgroup . ':' . $name; + + // Statically make sure tt() is available + static $tt; + if (!isset($tt)) { + if (module_exists('18nstrings') && function_exists($func)) { + $tt = $func; + } + } + + // Translate! + if ($tt) { + return $tt($name, $string, $langcode, $update); + } + else { + return t($string); + } +} + /** * Include necessary CSS and JS for rendering maps * @@ -203,9 +247,6 @@ function openlayers_get_layer_object($la $layer_types = openlayers_layer_types(); } - $layer->title = t($layer->title); - $layer->description = t($layer->description); - // Attempt to get ctool class // class is renamed klass because of PHP keywords if (isset($layer_types[$layer->data['layer_type']]) && @@ -238,7 +279,17 @@ function openlayers_layer_export_load($n ctools_include('export'); if ($reset) ctools_export_load_object_reset('openlayers_layers'); $layers = ctools_export_load_object('openlayers_layers', 'all', array($name)); - return !empty($layers[$name]) ? $layers[$name] : FALSE; + if (empty($layers[$name])) { + return FALSE; + } + else { + // Translate title and description + $layers[$name]->title = openlayers_translate( + 'layer:' . $layers[$name]->name . ':title', $layers[$name]->title); + $layers[$name]->description = openlayers_translate( + 'layer:' . $layers[$name]->name . ':description', $layers[$name]->description); + return $layers[$name]; + } } /** @@ -254,6 +305,14 @@ function openlayers_layers_export_load($ ctools_include('export'); if ($reset) ctools_export_load_object_reset('openlayers_layers'); $layers = ctools_export_load_object('openlayers_layers', 'all', array()); + + foreach ($layers as $name => $layer) { + // Translate title and description + $layers[$name]->title = openlayers_translate( + 'layer:' . $layer->name . ':title', $layer->title); + $layers[$name]->description = openlayers_translate( + 'layer:' . $layer->name . ':description', $layer->description); + } return $layers; } @@ -271,6 +330,12 @@ function openlayers_layer_load($name, $r if ($reset) ctools_export_load_object_reset('openlayers_layers'); $layer = ctools_export_load_object('openlayers_layers', 'names', array($name)); if ($layer) { + // Translate title and description + $layer[$name]->title = openlayers_translate( + 'layer:' . $layer[$name]->name . ':title', $layer[$name]->title); + $layer[$name]->description = openlayers_translate( + 'layer:' . $layer[$name]->name . ':description', $layer[$name]->description); + $layer_object = openlayers_get_layer_object($layer[$name]); if (openlayers_layer_sanity_check($layer_object)) { return $layer_object; @@ -297,7 +362,13 @@ function openlayers_layers_load($reset = $layer_objects = array(); if ($reset) ctools_export_load_object_reset('openlayers_layers'); $layers = ctools_export_load_object('openlayers_layers', 'all', array()); - foreach ($layers as $layer) { + foreach ($layers as $layer) { + // Translate title and description + $layer->title = openlayers_translate( + 'layer:' . $layer->name . ':title', $layer->title); + $layer->description = openlayers_translate( + 'layer:' . $layer->name . ':description', $layer->description); + $layer_objects[$layer->name] = openlayers_get_layer_object($layer); } $layer_objects = array_filter($layer_objects, 'openlayers_layer_sanity_check'); @@ -463,6 +534,14 @@ function openlayers_styles($reset = FALS } $styles = ctools_export_load_object('openlayers_styles', 'all', array()); + + // Translate title and description + foreach ($styles as $name => $style) { + $styles[$name]->title = openlayers_translate( + 'style:' . $name . ':title', $styles[$name]->title); + $styles[$name]->description = openlayers_translate( + 'style:' . $name . ':description', $styles[$name]->description); + } return $styles; } @@ -539,6 +618,14 @@ function openlayers_presets($reset = FAL $presets = ctools_export_load_object( 'openlayers_map_presets', 'all', array()); + + // Translate title and description + foreach ($presets as $name => $preset) { + $presets[$name]->title = openlayers_translate( + 'preset:' . $name . ':title', $presets[$name]->title); + $presets[$name]->description = openlayers_translate( + 'preset:' . $name . ':description', $presets[$name]->description); + } return $presets; } @@ -570,6 +657,11 @@ function openlayers_preset_load($name = } else { $preset = $presets[$name]; + // Translate title and description + $preset->title = openlayers_translate( + 'preset:' . $name . ':title', $preset->title); + $preset->description = openlayers_translate( + 'preset:' . $name . ':description', $preset->description); $preset->data['preset_name'] = $name; return $preset; } Index: docs/openlayers.api.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/openlayers/docs/Attic/openlayers.api.php,v retrieving revision 1.2.2.5 diff -u -p -r1.2.2.5 openlayers.api.php --- docs/openlayers.api.php 2 Jun 2010 23:13:40 -0000 1.2.2.5 +++ docs/openlayers.api.php 5 Sep 2010 16:44:31 -0000 @@ -203,6 +203,10 @@ function hook_openlayers_behaviors() { * Ensure that you are telling CTools about this as well. * @see openlayers_example_ctools_plugin_api(). * + * Please note, that to support translation for exportable + * code for potx extraction, you should include separate code + * of translatable string. + * * @return * Return an associative array with index being a unique string * identifier, and simple objects with the following properties: @@ -215,12 +219,11 @@ function hook_openlayers_styles() { // Taken from openlayers.styles.inc $styles = array(); - $style = new stdClass(); $style->api_version = 1; $style->name = 'default'; - $style->title = t('Default style'); - $style->description = t('Basic default style.'); + $style->title = 'Default style'; + $style->description = 'Basic default style.'; $style->data = array( 'pointRadius' => '5', 'fillColor' => '#FFCC66', @@ -229,14 +232,27 @@ function hook_openlayers_styles() { 'fillOpacity' => '0.5' ); $styles[$style->name] = $style; - return $styles; + + // Extra code to support potx extractors + $potx = array( + t('Default style'), + t('Basic default style.'), + ); } /** * OpenLayers Presets * - * Define map presets. + * This hook tells OpenLayers about map presets that + * store data to display maps. + * + * Ensure that you are telling CTools about this as well. + * @see openlayers_example_ctools_plugin_api(). + * + * Please note, that to support translation for exportable + * code for potx extraction, you should include separate code + * of translatable string. * * @return * Return an associative array with index being a unique string @@ -252,8 +268,8 @@ function hook_openlayers_presets() { $default = new stdClass(); $default->api_version = 1; $default->name = 'default'; - $default->title = t('Default Map'); - $default->description = t('This is the default map preset that comes with the OpenLayers module.'); + $default->title = 'Default Map'; + $default->description = 'This is the default map preset that comes with the OpenLayers module.'; $default->data = array( 'projection' => '900913', 'width' => 'auto', @@ -281,4 +297,10 @@ function hook_openlayers_presets() { ) ); return array('default' => $default); + + // Extra code to support potx extractors + $potx = array( + t('Default Map'), + t('This is the default map preset that comes with the OpenLayers module.'), + ); } Index: includes/openlayers.presets.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/openlayers/includes/Attic/openlayers.presets.inc,v retrieving revision 1.1.2.5 diff -u -p -r1.1.2.5 openlayers.presets.inc --- includes/openlayers.presets.inc 9 Jun 2010 12:57:17 -0000 1.1.2.5 +++ includes/openlayers.presets.inc 5 Sep 2010 16:44:32 -0000 @@ -21,8 +21,8 @@ function _openlayers_openlayers_presets( $default = new stdClass(); $default->api_version = 1; $default->name = 'default'; - $default->title = t('Default Map'); - $default->description = t('This is the default map preset that comes with the OpenLayers module.'); + $default->title = 'Default Map'; + $default->description = 'This is the default map preset that comes with the OpenLayers module.'; $default->data = array( 'projection' => '900913', 'width' => 'auto', @@ -49,3 +49,15 @@ function _openlayers_openlayers_presets( ); return array('default' => $default); } + +/** + * This function is for the po editor to be able to find these strings, + * since in the codebase they are not in t()'s, because they are later + * run through t() in the layer loader function + */ +function _openlayers_openlayers_presets_i18n() { + $potx = array( + t('Default Map'), + t('This is the default map preset that comes with the OpenLayers module.'), + ); +} Index: includes/openlayers.styles.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/openlayers/includes/Attic/openlayers.styles.inc,v retrieving revision 1.3.2.5 diff -u -p -r1.3.2.5 openlayers.styles.inc --- includes/openlayers.styles.inc 7 Mar 2010 20:17:21 -0000 1.3.2.5 +++ includes/openlayers.styles.inc 5 Sep 2010 16:44:32 -0000 @@ -22,8 +22,8 @@ function _openlayers_openlayers_styles() $style = new stdClass(); $style->api_version = 1; $style->name = 'default'; - $style->title = t('Default style'); - $style->description = t('Basic default style.'); + $style->title = 'Default style'; + $style->description = 'Basic default style.'; $style->data = array( 'pointRadius' => '5', 'fillColor' => '#FFCC66', @@ -36,8 +36,8 @@ function _openlayers_openlayers_styles() $style = new stdClass(); $style->api_version = 1; $style->name = 'invisible'; - $style->title = t('Invisible style'); - $style->description = t('Invisible default style.'); + $style->title = 'Invisible style'; + $style->description = 'Invisible default style.'; $style->data = array( 'pointRadius' => '0', 'strokeWidth' => '0', @@ -48,8 +48,8 @@ function _openlayers_openlayers_styles() $style = new stdClass(); $style->api_version = 1; $style->name = 'default_select'; - $style->title = t('Default select style'); - $style->description = t('Default style for selected geometries'); + $style->title = 'Default select style'; + $style->description = 'Default style for selected geometries'; $style->data = array( 'pointRadius' => '5', 'fillColor' => '#66CCFF', @@ -61,3 +61,19 @@ function _openlayers_openlayers_styles() return $styles; } + +/** + * This function is for the po editor to be able to find these strings, + * since in the codebase they are not in t()'s, because they are later + * run through t() in the layer loader function + */ +function _openlayers_openlayers_style_i18n() { + $potx = array( + t('Default style'), + t('Basic default style.'), + t('Invisible style'), + t('Invisible default style.'), + t('Default select style'), + t('Default style for selected geometries'), + ); +} Index: tests/openlayers_test.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/openlayers/tests/Attic/openlayers_test.module,v retrieving revision 1.2.2.15 diff -u -p -r1.2.2.15 openlayers_test.module --- tests/openlayers_test.module 27 Jun 2010 15:57:01 -0000 1.2.2.15 +++ tests/openlayers_test.module 5 Sep 2010 16:44:32 -0000 @@ -62,8 +62,8 @@ function openlayers_test_openlayers_pres $behaviors_test = new stdClass(); $behaviors_test->api_version = 1; $behaviors_test->name = 'behaviors_test'; - $behaviors_test->title = t('Test: Behaviors'); - $behaviors_test->description = t('This is a test preset.'); + $behaviors_test->title = 'Test: Behaviors'; + $behaviors_test->description = 'This is a test preset.'; $behaviors_test->data = array( 'projection' => '4326', 'projection' => '900913', @@ -213,6 +213,15 @@ function openlayers_test_openlayers_pres // Return presets return $items; + + // Extra code to support potx extractors + $potx = array( + t('Test: Behaviors'), + t('This is a test preset.'), + t('Test: OpenLayers Test Views'), + t('This preset tests a custom content type with a WKT field and ' . + 'a views layer.'), + ); } /**