OpenLayers OpenLayers

Ticket #109: i18n.2-1.patch

File i18n.2-1.patch, 41.3 kB (added by ahocevar, 11 months ago)
  • tests/test_Lang.html

    old new  
     1<html> 
     2<head> 
     3    <script src="../lib/OpenLayers.js"></script> 
     4    <script src="../lib/OpenLayers/Lang/en-CA.js" type="text/javascript"></script> 
     5    <script src="../lib/OpenLayers/Lang/fr.js" type="text/javascript"></script> 
     6    <script type="text/javascript"> 
     7     
     8    function test_setCode(t) { 
     9        t.plan(4); 
     10        OpenLayers.Lang.code = null; 
     11         
     12        // test with no argument - this could result in the default or the 
     13        // browser language if a dictionary exists 
     14        OpenLayers.Lang.setCode(); 
     15        t.ok(OpenLayers.Lang.code != null, 
     16             "code set when no argument is sent"); 
     17         
     18        var primary = "xx"; 
     19        var subtag = "XX"; 
     20        var code = primary + "-" + subtag; 
     21        OpenLayers.Lang[code] = {}; 
     22         
     23        // test code for dictionary that exists 
     24        OpenLayers.Lang.setCode(code); 
     25        t.eq(OpenLayers.Lang.code, code, 
     26             "code properly set for existing dictionary"); 
     27         
     28        // test code for dictionary that doesn't exist 
     29        OpenLayers.Lang.setCode(primary + "-YY"); 
     30        t.eq(OpenLayers.Lang.code, OpenLayers.Lang.defaultCode, 
     31             "code set to default for non-existing dictionary"); 
     32         
     33        // test code for existing primary but missing subtag 
     34        OpenLayers.Lang[primary] = {}; 
     35        OpenLayers.Lang.setCode(primary + "-YY"); 
     36        t.eq(OpenLayers.Lang.code, primary, 
     37             "code set to primary when subtag dictionary is missing"); 
     38         
     39        // clean up 
     40        delete OpenLayers.Lang[code]; 
     41        delete OpenLayers.Lang[primary]; 
     42        OpenLayers.Lang.code = null; 
     43    } 
     44     
     45    function test_getCode(t) { 
     46        t.plan(3); 
     47        OpenLayers.Lang.code = null; 
     48         
     49        // test that a non-null value is retrieved - could be browser language 
     50        // or defaultCode 
     51        var code = OpenLayers.Lang.getCode(); 
     52        t.ok(code != null, "returns a non-null code"); 
     53        t.ok(OpenLayers.Lang.code != null, "sets the code to a non-null value"); 
     54         
     55        // test that the code is returned if non-null 
     56        OpenLayers.Lang.code = "foo"; 
     57        t.eq(OpenLayers.Lang.getCode(), "foo", "returns the code if non-null"); 
     58         
     59        // clean up 
     60        OpenLayers.Lang.code = null;         
     61    } 
     62     
     63    function test_i18n(t) { 
     64        t.plan(1);         
     65        t.ok(OpenLayers.i18n === OpenLayers.Lang.translate, 
     66             "i18n is an alias for OpenLayers.Lang.translate"); 
     67    } 
     68     
     69    function test_translate(t) { 
     70        var keys = ['test1', 'test3', 'noKey']; 
     71        var codes = ['en', 'en-CA', 'fr', 'fr-CA', 'sw']; 
     72        var result = { 
     73            'en': {'overlays':'Overlays',  
     74                   'unhandledRequest':'Unhandled request return foo',  
     75                   'noKey':'noKey'}, 
     76            'en-CA': {'overlays':'Overlays', 
     77                   'unhandledRequest':'Unhandled request return foo',  
     78                      'noKey':'noKey'}, 
     79            'fr': {'overlays':'Couches de superposition',  
     80                   'unhandledRequest':'unhandledRequest', // not translated 
     81                  'noKey':'noKey'}, 
     82            'fr-CA': {'overlays':'Couches de superposition', //this should result in 'fr' 
     83                   'unhandledRequest':'unhandledRequest', // not translated 
     84                  'noKey':'noKey'}, 
     85            'sw': {'overlays':'Overlays', //this should result in 'en' 
     86                   'unhandledRequest':'Unhandled request return foo',  
     87                  'noKey':'noKey'} 
     88        }; 
     89         
     90        t.plan(keys.length*codes.length); 
     91 
     92        for (var i=0; i<codes.length; ++i) { 
     93            var code = codes[i]; 
     94            OpenLayers.Lang.setCode(code); 
     95            t.eq(OpenLayers.Lang.translate('overlays'), result[code]['overlays'], "simple key lookup in "+code); 
     96            t.eq(OpenLayers.Lang.translate('unhandledRequest',{'statusText':'foo'}),  
     97                        result[code]['unhandledRequest'], "lookup with argument substitution in "+code); 
     98            t.eq(OpenLayers.Lang.translate('noKey'), result[code]['noKey'], "invalid key returns the key in "+code); 
     99        } 
     100    } 
     101 
     102  </script> 
     103</head> 
     104<body> 
     105</body> 
     106</html> 
  • tests/list-tests.html

    old new  
    4949    <li>Rule/test_Logical.html</li> 
    5050    <li>test_Events.html</li> 
    5151    <li>test_Util.html</li> 
     52    <li>test_Lang.html</li> 
    5253    <li>test_Layer.html</li> 
    5354    <li>test_Renderer.html</li> 
    5455    <li>Layer/test_EventPane.html</li> 
  • lib/OpenLayers/Lang/fr.js

    old new  
     1/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD 
     2 * license.  See http://svn.openlayers.org/trunk/openlayers/license.txt for the 
     3 * full text of the license. */ 
     4 
     5/** 
     6 * @requires OpenLayers/Lang.js 
     7 */ 
     8 
     9/** 
     10 * Namespace: OpenLayers.Lang["fr"] 
     11 * Dictionary for French.  Keys for entries are used in calls to 
     12 *     <OpenLayers.Lang.translate>.  Entry bodies are normal strings or 
     13 *     strings formatted for use with <OpenLayers.String.format> calls. 
     14 */ 
     15OpenLayers.Lang.fr = { 
     16 
     17    'overlays': "Couches de superposition" 
     18 
     19}; 
  • lib/OpenLayers/Lang/en.js

    old new  
     1/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD 
     2 * license.  See http://svn.openlayers.org/trunk/openlayers/license.txt for the 
     3 * full text of the license. */ 
     4 
     5/** 
     6 * @requires OpenLayers/Lang.js 
     7 */ 
     8 
     9/** 
     10 * Namespace: OpenLayers.Lang["en"] 
     11 * Dictionary for English.  Keys for entries are used in calls to 
     12 *     <OpenLayers.Lang.translate>.  Entry bodies are normal strings or 
     13 *     strings formatted for use with <OpenLayers.String.format> calls. 
     14 */ 
     15OpenLayers.Lang.en = { 
     16 
     17    'unhandledRequest': "Unhandled request return ${statusText}", 
     18 
     19    'permalink': "Permalink", 
     20 
     21    'overlays': "Overlays", 
     22 
     23    'baseLayer': "Base Layer", 
     24 
     25    'sameProjection': 
     26        "The overview map only works when it is in the same projection as the main map", 
     27 
     28    'readNotImplemented': "Read not implemented.", 
     29 
     30    'writeNotImplemented': "Write not implemented.", 
     31 
     32    'noFID': "Can't update a feature for which there is no FID.", 
     33 
     34    'errorLoadingGML': "Error in loading GML file ${url}", 
     35 
     36    'browserNotSupported': 
     37        "Your browser does not support vector rendering. Currently supported renderers are:\n${renderers}", 
     38 
     39    'componentShouldBe': "addFeatures : component should be an ${geomType}", 
     40 
     41    // console message 
     42    'getFeatureError': 
     43        "getFeatureFromEvent called on layer with no renderer. This usually means you " + 
     44        "destroyed a layer, but not some handler which is associated with it.", 
     45 
     46    // console message 
     47    'minZoomLevelError': 
     48        "The minZoomLevel property is only intended for use " + 
     49        "with the FixedZoomLevels-descendent layers. That this " + 
     50        "wfs layer checks for minZoomLevel is a relic of the" + 
     51        "past. We cannot, however, remove it without possibly " + 
     52        "breaking OL based applications that may depend on it." + 
     53        " Therefore we are deprecating it -- the minZoomLevel " + 
     54        "check below will be removed at 3.0. Please instead " + 
     55        "use min/max resolution setting as described here: " + 
     56        "http://trac.openlayers.org/wiki/SettingZoomLevels", 
     57 
     58    'commitSuccess': "WFS Transaction: SUCCESS ${response}", 
     59 
     60    'commitFailed': "WFS Transaction: FAILED ${response}", 
     61 
     62    'googleWarning': 
     63        "The Google Layer was unable to load correctly.<br><br>" + 
     64        "To get rid of this message, select a new BaseLayer " + 
     65        "in the layer switcher in the upper-right corner.<br><br>" + 
     66        "Most likely, this is because the Google Maps library " + 
     67        "script was either not included, or does not contain the " + 
     68        "correct API key for your site.<br><br>" + 
     69        "Developers: For help getting this working correctly, " + 
     70        "<a href='http://trac.openlayers.org/wiki/Google' " + 
     71        "target='_blank'>click here</a>", 
     72 
     73    'getLayerWarning': 
     74        "The ${layerType} Layer was unable to load correctly.<br><br>" + 
     75        "To get rid of this message, select a new BaseLayer " + 
     76        "in the layer switcher in the upper-right corner.<br><br>" + 
     77        "Most likely, this is because the ${layerLib} library " + 
     78        "script was either not correctly included.<br><br>" + 
     79        "Developers: For help getting this working correctly, " + 
     80        "<a href='http://trac.openlayers.org/wiki/${layerLib}' " + 
     81        "target='_blank'>click here</a>", 
     82 
     83    'scale': "Scale = 1 : ${scaleDenom}", 
     84 
     85    // console message 
     86    'layerAlreadyAdded': 
     87        "You tried to add the layer: ${layerName} to the map, but it has already been added", 
     88 
     89    // console message 
     90    'reprojectDeprecated': 
     91        "You are using the 'reproject' option " + 
     92        "on the ${layerName} layer. This option is deprecated: " + 
     93        "its use was designed to support displaying data over commercial " +  
     94        "basemaps, but that functionality should now be achieved by using " + 
     95        "Spherical Mercator support. More information is available from " + 
     96        "http://trac.openlayers.org/wiki/SphericalMercator.", 
     97 
     98    // console message 
     99    'methodDeprecated': 
     100        "This method has been deprecated and will be removed in 3.0. " + 
     101        "Please use ${newMethod} instead.", 
     102 
     103    // console message 
     104    'boundsAddError': "You must pass both x and y values to the add function.", 
     105 
     106    // console message 
     107    'lonlatAddError': "You must pass both lon and lat values to the add function.", 
     108 
     109    // console message 
     110    'pixelAddError': "You must pass both x and y values to the add function.", 
     111 
     112    // console message 
     113    'unsupportedGeometryType': "Unsupported geometry type: ${geomType}", 
     114 
     115    // console message 
     116    'pagePositionFailed': 
     117        "OpenLayers.Util.pagePosition failed: element with id ${elemId} may be misplaced.", 
     118                     
     119    'end': '' 
     120}; 
  • lib/OpenLayers/Lang/en-CA.js

    old new  
     1/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD 
     2 * license.  See http://svn.openlayers.org/trunk/openlayers/license.txt for the 
     3 * full text of the license. */ 
     4 
     5/** 
     6 * @requires OpenLayers/Lang/en.js 
     7 */ 
     8 
     9/** 
     10 * Namespace: OpenLayers.Lang["en-CA"] 
     11 * Dictionary for English-CA.  This dictionary inherits from the standard 
     12 *     English dictionary.  Override only those entries with language specific 
     13 *     to the CA region. 
     14 *      
     15 * Keys for entries are used in calls to <OpenLayers.Lang.translate>.  Entry 
     16 *     bodies are normal strings or strings formatted for use with 
     17 *     <OpenLayers.String.format> calls. 
     18 */ 
     19OpenLayers.Lang['en-CA'] = OpenLayers.Util.applyDefaults({ 
     20 
     21    // add any entries specific for this region here 
     22    // e.g. 
     23    // "someKey": "Some regionally specific value" 
     24     
     25}, OpenLayers.Lang["en"]); 
  • lib/OpenLayers/Format/GML.js

    old new  
    154154                                           this.internalProjection);  
    155155                    }                        
    156156                } else { 
    157                     OpenLayers.Console.error("Unsupported geometry type: " + 
    158                                              type); 
     157                    OpenLayers.Console.error(OpenLayers.i18n( 
     158                                "unsupportedGeometryType", {'geomType':type})); 
    159159                } 
    160160                // stop looking for different geometry types 
    161161                break; 
  • lib/OpenLayers/Format/WFS.js

    old new  
    129129     * feature - {<OpenLayers.Feature.Vector>}  
    130130     */ 
    131131    update: function(feature) { 
    132         if (!feature.fid) { alert("Can't update a feature for which there is no FID."); } 
     132        if (!feature.fid) { alert(OpenLayers.i18n("noFID")); } 
    133133        var updateNode = this.createElementNS(this.wfsns, 'wfs:Update'); 
    134134        updateNode.setAttribute("typeName", this.layerName); 
    135135 
     
    186186     */ 
    187187    remove: function(feature) { 
    188188        if (!feature.fid) {  
    189             alert("Can't delete a feature for which there is no FID.");  
     189            alert(OpenLayers.i18n("noFID"));  
    190190            return false;  
    191191        } 
    192192        var deleteNode = this.createElementNS(this.featureNS, 'wfs:Delete'); 
  • lib/OpenLayers/Format/KML.js

    old new  
    580580                                           this.internalProjection);  
    581581                    }                        
    582582                } else { 
    583                     OpenLayers.Console.error("Unsupported geometry type: " + 
    584                                              type); 
     583                    OpenLayers.Console.error(OpenLayers.i18n( 
     584                                "unsupportedGeometryType", {'geomType':type})); 
    585585                } 
    586586                // stop looking for different geometry types 
    587587                break; 
  • lib/OpenLayers/Map.js

    old new  
    726726    addLayer: function (layer) { 
    727727        for(var i=0; i < this.layers.length; i++) { 
    728728            if (this.layers[i] == layer) { 
    729                 var msg = "You tried to add the layer: " + layer.name +  
    730                           " to the map, but it has already been added"
     729                var msg = OpenLayers.i18n('layerAlreadyAdded',  
     730                                                      {'layerName':layer.name})
    731731                OpenLayers.Console.warn(msg); 
    732732                return false; 
    733733            } 
  • lib/OpenLayers/Lang.js

    old new  
     1/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD 
     2 * license.  See http://svn.openlayers.org/trunk/openlayers/license.txt for the 
     3 * full text of the license. */ 
     4 
     5 
     6/** 
     7 * Namespace: OpenLayers.Lang 
     8 * Internationalization namespace.  Contains dictionaries in various languages 
     9 *     and methods to set and get the current language. 
     10 */ 
     11OpenLayers.Lang = { 
     12     
     13    /**  
     14     * Property: code 
     15     * {String}  Current language code to use in OpenLayers.  Use the 
     16     *     <setCode> method to set this value and the <getCode> method to 
     17     *     retrieve it. 
     18     */ 
     19    code: null, 
     20 
     21    /**  
     22     * APIProperty: defaultCode 
     23     * {String} Default language to use when a specific language can't be 
     24     *     found.  Default is "en". 
     25     */ 
     26    defaultCode: "en", 
     27         
     28    /** 
     29     * APIFunction: getCode 
     30     * Get the current language code. 
     31     * 
     32     * Returns: 
     33     * The current language code. 
     34     */ 
     35    getCode: function() { 
     36        if(!OpenLayers.Lang.code) { 
     37            OpenLayers.Lang.setCode(); 
     38        } 
     39        return OpenLayers.Lang.code; 
     40    }, 
     41     
     42    /** 
     43     * APIFunction: setCode 
     44     * Set the language code for string translation.  This code is used by 
     45     *     the <OpenLayers.Lang.translate> method. 
     46     * 
     47     * Parameters- 
     48     * code - {String} These codes follow the IETF recommendations at 
     49     *     http://www.ietf.org/rfc/rfc3066.txt.  If no value is set, the 
     50     *     browser's language setting will be tested.  If no <OpenLayers.Lang> 
     51     *     dictionary exists for the code, the <OpenLayers.String.defaultLang> 
     52     *     will be used. 
     53     */ 
     54    setCode: function(code) { 
     55        var lang; 
     56        if(!code) { 
     57            code = (OpenLayers.Util.getBrowserName() == "msie") ? 
     58                navigator.userLanguage : navigator.language; 
     59        } 
     60        var parts = code.split('-'); 
     61        parts[0] = parts[0].toLowerCase(); 
     62        if(typeof OpenLayers.Lang[parts[0]] == "object") { 
     63            lang = parts[0]; 
     64        } 
     65 
     66        // check for regional extensions 
     67        if(parts[1]) { 
     68            var testLang = parts[0] + '-' + parts[1].toUpperCase(); 
     69            if(typeof OpenLayers.Lang[testLang] == "object") { 
     70                lang = testLang; 
     71            } 
     72        } 
     73        if(!lang) { 
     74            OpenLayers.Console.warn( 
     75                'Failed to find OpenLayers.Lang.' + parts.join("-") + 
     76                ' dictionary, falling back to default language' 
     77            ); 
     78            lang = OpenLayers.Lang.defaultCode 
     79        } 
     80         
     81        OpenLayers.Lang.code = lang; 
     82    }, 
     83 
     84    /** 
     85     * APIMethod: translate 
     86     * Looks up a key from a dictionary based on the current language string. 
     87     *     The value of <getCode> will be used to determine the appropriate 
     88     *     dictionary.  Dictionaries are stored in <OpenLayers.Lang>. 
     89     * 
     90     * Parameters: 
     91     * key - {String} The key for an i18n string value in the dictionary. 
     92     * context - {Object} Optional context to be used with 
     93     *     <OpenLayers.String.format>. 
     94     *  
     95     * Returns: 
     96     * {String} A internationalized string. 
     97     */ 
     98    translate: function(key, context) { 
     99        var dictionary = OpenLayers.Lang[OpenLayers.Lang.getCode()]; 
     100        var message = dictionary[key]; 
     101        if(!message) { 
     102            // Message not found, fall back to message key 
     103            message = key; 
     104        } 
     105        if(context) { 
     106            message = OpenLayers.String.format(message, context); 
     107        } 
     108        return message; 
     109    } 
     110     
     111}; 
     112 
     113 
     114/** 
     115 * APIMethod: OpenLayers.i18n 
     116 * Alias for <OpenLayers.Lang.translate>.  Looks up a key from a dictionary 
     117 *     based on the current language string. The value of 
     118 *     <OpenLayers.Lang.getCode> will be used to determine the appropriate 
     119 *     dictionary.  Dictionaries are stored in <OpenLayers.Lang>. 
     120 * 
     121 * Parameters: 
     122 * key - {String} The key for an i18n string value in the dictionary. 
     123 * context - {Object} Optional context to be used with 
     124 *     <OpenLayers.String.format>. 
     125 *  
     126 * Returns: 
     127 * {String} A internationalized string. 
     128 */ 
     129OpenLayers.i18n = OpenLayers.Lang.translate; 
  • lib/OpenLayers/Ajax.js

    old new  
    3434* @param {} request 
    3535*/ 
    3636OpenLayers.nullHandler = function(request) { 
    37     alert("Unhandled request return " + request.statusText); 
     37    alert(OpenLayers.i18n("unhandledRequest", {'statusText':request.statusText})); 
    3838}; 
    3939 
    4040/**  
  • lib/OpenLayers/BaseTypes/LonLat.js

    old new  
    8484     */ 
    8585    add:function(lon, lat) { 
    8686        if ( (lon == null) || (lat == null) ) { 
    87             var msg = "You must pass both lon and lat values " + 
    88                       "to the add function."; 
     87            var msg = OpenLayers.i18n("lonlatAddError"); 
    8988            OpenLayers.Console.error(msg); 
    9089            return null; 
    9190        } 
  • lib/OpenLayers/BaseTypes/Bounds.js

    old new  
    232232     */ 
    233233    add:function(x, y) { 
    234234        if ( (x == null) || (y == null) ) { 
    235             var msg = "You must pass both x and y values to the add function."
     235            var msg = OpenLayers.i18n("boundsAddError")
    236236            OpenLayers.Console.error(msg); 
    237237            return null; 
    238238        } 
  • lib/OpenLayers/BaseTypes/Pixel.js

    old new  
    9191     */ 
    9292    add:function(x, y) { 
    9393        if ( (x == null) || (y == null) ) { 
    94             var msg = "You must pass both x and y values to the add function."
     94            var msg = OpenLayers.i18n("pixelAddError")
    9595            OpenLayers.Console.error(msg); 
    9696            return null; 
    9797        } 
  • lib/OpenLayers/Tile.js

    old new  
    213213     * bounds - {<OpenLayers.Bounds>}  
    214214     */ 
    215215    getBoundsFromBaseLayer: function(position) { 
    216         OpenLayers.Console.warn("You are using the 'reproject' option " + 
    217           "on the " + this.layer.name + " layer. This option is deprecated: " + 
    218           "its use was designed to support displaying data over commercial " +  
    219           "basemaps, but that functionality should now be achieved by using " + 
    220           "Spherical Mercator support. More information is available from " + 
    221           "http://trac.openlayers.org/wiki/SphericalMercator.");  
     216        var msg = OpenLayers.i18n('reprojectDeprecated', 
     217                                              {'layerName':this.layer.name}); 
     218        OpenLayers.Console.warn(msg); 
    222219        var topLeft = this.layer.map.getLonLatFromLayerPx(position);  
    223220        var bottomRightPx = position.clone(); 
    224221        bottomRightPx.x += this.size.w; 
  • lib/OpenLayers/BaseTypes.js

    old new  
    99 * @requires OpenLayers/BaseTypes/Pixel.js 
    1010 * @requires OpenLayers/BaseTypes/Bounds.js 
    1111 * @requires OpenLayers/BaseTypes/Element.js 
     12 * @requires OpenLayers/Lang/en.js 
    1213 */ 
    13  
    14 /** 
     14  
     15/**  
    1516 * Header: OpenLayers Base Types 
    1617 * OpenLayers custom string, number and function functions are described here. 
    1718 */ 
     
    2324 *********************/ 
    2425 
    2526OpenLayers.String = { 
     27 
    2628    /** 
    2729     * APIFunction: OpenLayers.String.startsWith 
    2830     * Test whether a string starts with another string.  
     
    9092        } 
    9193        return camelizedString; 
    9294    }, 
    93  
     95     
    9496    /** 
    9597     * APIFunction: OpenLayers.String.format 
    9698     * Given a string with tokens in the form ${token}, return a string 
     
    141143     * {Boolean} Whether or not this string starts with the string passed in. 
    142144     */ 
    143145    String.prototype.startsWith = function(sStart) { 
    144         OpenLayers.Console.warn( 
    145             "This method has been deprecated and will be removed in 3.0. " + 
    146             "Please use OpenLayers.String.startsWith instead" 
    147         ); 
     146        OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated", 
     147                                {'newMethod':'OpenLayers.String.startsWith'})); 
    148148        return OpenLayers.String.startsWith(this, sStart); 
    149149    }; 
    150150} 
     
    161161     * {Boolean} Whether or not this string contains with the string passed in. 
    162162     */ 
    163163    String.prototype.contains = function(str) { 
    164         OpenLayers.Console.warn( 
    165             "This method has been deprecated and will be removed in 3.0. " + 
    166             "Please use OpenLayers.String.contains instead" 
    167         ); 
     164        OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated", 
     165                                  {'newMethod':'OpenLayers.String.contains'})); 
    168166        return OpenLayers.String.contains(this, str); 
    169167    }; 
    170168} 
     
    179177     *          trailing spaces removed 
    180178     */ 
    181179    String.prototype.trim = function() { 
    182         OpenLayers.Console.warn( 
    183             "This method has been deprecated and will be removed in 3.0. " + 
    184             "Please use OpenLayers.String.trim instead" 
    185         ); 
     180        OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated", 
     181                                      {'newMethod':'OpenLayers.String.trim'})); 
    186182        return OpenLayers.String.trim(this); 
    187183    }; 
    188184} 
     
    198194     * {String} The string, camelized 
    199195     */ 
    200196    String.prototype.camelize = function() { 
    201         OpenLayers.Console.warn( 
    202             "This method has been deprecated and will be removed in 3.0. " + 
    203             "Please use OpenLayers.String.camelize instead" 
    204         ); 
     197        OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated", 
     198                                  {'newMethod':'OpenLayers.String.camelize'})); 
    205199        return OpenLayers.String.camelize(this); 
    206200    }; 
    207201} 
     
    315309     *           If null, 0, or negative value passed in, returns 0 
    316310     */ 
    317311    Number.prototype.limitSigDigs = function(sig) { 
    318         OpenLayers.Console.warn( 
    319             "This method has been deprecated and will be removed in 3.0. " + 
    320             "Please use OpenLayers.Number.limitSigDigs instead" 
    321         ); 
     312        OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated", 
     313                              {'newMethod':'OpenLayers.String.limitSigDigs'})); 
    322314        return OpenLayers.Number.limitSigDigs(this, sig); 
    323315    }; 
    324316} 
     
    388380     *            argument. 
    389381     */ 
    390382    Function.prototype.bind = function() { 
    391         OpenLayers.Console.warn( 
    392             "This method has been deprecated and will be removed in 3.0. " + 
    393             "Please use OpenLayers.Function.bind instead" 
    394         ); 
     383        OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated", 
     384                                {'newMethod':'OpenLayers.String.bind'})); 
    395385        // new function takes the same arguments with this function up front 
    396386        Array.prototype.unshift.apply(arguments, [this]); 
    397387        return OpenLayers.Function.bind.apply(null, arguments); 
     
    411401     * {Function} 
    412402     */ 
    413403    Function.prototype.bindAsEventListener = function(object) { 
    414         OpenLayers.Console.warn( 
    415             "This method has been deprecated and will be removed in 3.0. " + 
    416             "Please use OpenLayers.Function.bindAsEventListener instead" 
    417         ); 
     404        OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated", 
     405                        {'newMethod':'OpenLayers.String.bindAsEventListener'})); 
    418406        return OpenLayers.Function.bindAsEventListener(this, object); 
    419407    }; 
    420408} 
  • lib/OpenLayers/Control/OverviewMap.js

    old new  
    498498        // as the base layer for the main map.  This should be made more robust. 
    499499        if(this.map.units != 'degrees') { 
    500500            if(this.ovmap.getProjection() && (this.map.getProjection() != this.ovmap.getProjection())) { 
    501                 alert('The overview map only works when it is in the same projection as the main map'); 
     501                alert(OpenLayers.i18n("sameProjection")); 
    502502            } 
    503503        } 
    504504        var pxBounds = this.getRectBoundsFromMapBounds(this.map.getExtent()); 
  • lib/OpenLayers/Control/Permalink.js

    old new  
    111111        if (!this.element) { 
    112112            this.div.className = this.displayClass; 
    113113            this.element = document.createElement("a"); 
    114             this.element.innerHTML = "Permalink"
     114            this.element.innerHTML = OpenLayers.i18n("permalink")
    115115            this.element.href=""; 
    116116            this.div.appendChild(this.element); 
    117117        } 
  • lib/OpenLayers/Control/LayerSwitcher.js

    old new  
    504504 
    505505 
    506506        this.baseLbl = document.createElement("div"); 
    507         this.baseLbl.innerHTML = "<u>Base Layer</u>"
     507        this.baseLbl.innerHTML = OpenLayers.i18n("baseLayer")
    508508        this.baseLbl.style.marginTop = "3px"; 
    509509        this.baseLbl.style.marginLeft = "3px"; 
    510510        this.baseLbl.style.marginBottom = "3px"; 
     
    517517                      
    518518 
    519519        this.dataLbl = document.createElement("div"); 
    520         this.dataLbl.innerHTML = "<u>Overlays</u>"
     520        this.dataLbl.innerHTML = OpenLayers.i18n("overlays")
    521521        this.dataLbl.style.marginTop = "3px"; 
    522522        this.dataLbl.style.marginLeft = "3px"; 
    523523        this.dataLbl.style.marginBottom = "3px"; 
  • lib/OpenLayers/Control/Scale.js

    old new  
    6868            scale = Math.round(scale); 
    6969        }     
    7070         
    71         this.element.innerHTML = "Scale = 1 : " + scale
     71        this.element.innerHTML = OpenLayers.i18n("scale", {'scaleDenom':scale})
    7272    },  
    7373 
    7474    CLASS_NAME: "OpenLayers.Control.Scale" 
  • lib/OpenLayers/Util.js

    old new  
    100100 * array - {Array} 
    101101 */ 
    102102OpenLayers.Util.clearArray = function(array) { 
    103     var msg = "OpenLayers.Util.clearArray() is Deprecated." + 
    104               " Please use 'array.length = 0' instead."; 
    105     OpenLayers.Console.warn(msg); 
     103    OpenLayers.Console.warn( 
     104        OpenLayers.i18n( 
     105            "methodDeprecated", {'newMethod': 'array = []'} 
     106        ) 
     107    ); 
    106108    array.length = 0; 
    107109}; 
    108110 
     
    866868 * {Object} An object of key/value pairs from the query string. 
    867869 */ 
    868870OpenLayers.Util.getArgs = function(url) { 
    869     var err = "The getArgs() function is deprecated and will be removed " + 
    870             "with the 3.0 version of OpenLayers. Please instead use " + 
    871             "OpenLayers.Util.getParameters()."; 
    872     OpenLayers.Console.warn(err); 
     871    OpenLayers.Console.warn( 
     872        OpenLayers.i18n( 
     873            "methodDeprecated", {'newMethod': 'OpenLayers.Util.getParameters'} 
     874        ) 
     875    ); 
    873876    return OpenLayers.Util.getParameters(url); 
    874877}; 
    875878 
     
    10421045            // wrapping this in a try/catch because IE chokes on the offsetParent 
    10431046            element = element.offsetParent; 
    10441047        } catch(e) { 
    1045             OpenLayers.Console.error( 
    1046                 "OpenLayers.Util.pagePosition failed: element with id " + 
    1047                 element.id + " may be misplaced." 
    1048             ); 
     1048            OpenLayers.Console.error(OpenLayers.i18n( 
     1049                                  "pagePositionFailed",{'elemId':element.id})); 
    10491050            break; 
    10501051        } 
    10511052    } 
  • lib/OpenLayers/Format.js

    old new  
    6868     * Depends on the subclass 
    6969     */ 
    7070    read: function(data) { 
    71         alert("Read not implemented."); 
     71        alert(OpenLayers.i18n("readNotImplemented")); 
    7272    }, 
    7373     
    7474    /** 
     
    8282     * {String} A string representation of the object. 
    8383     */ 
    8484    write: function(object) { 
    85         alert("Write not implemented."); 
     85        alert(OpenLayers.i18n("writeNotImplemented")); 
    8686    }, 
    8787 
    8888    CLASS_NAME: "OpenLayers.Format" 
  • lib/OpenLayers/Layer/VirtualEarth.js

    old new  
    137137     *          it working. 
    138138     */ 
    139139    getWarningHTML:function() { 
    140  
    141         var html = ""; 
    142         html += "The VE Layer was unable to load correctly.<br>"; 
    143         html += "<br>"; 
    144         html += "To get rid of this message, select a new BaseLayer "; 
    145         html += "in the layer switcher in the upper-right corner.<br>"; 
    146         html += "<br>"; 
    147         html += "Most likely, this is because the VE library"; 
    148         html += " script was either not correctly included.<br>"; 
    149         html += "<br>"; 
    150         html += "Developers: For help getting this working correctly, "; 
    151         html += "<a href='http://trac.openlayers.org/wiki/VirtualEarth' "; 
    152         html +=  "target='_blank'>"; 
    153         html +=     "click here"; 
    154         html += "</a>"; 
    155  
    156         return html; 
     140        return OpenLayers.i18n( 
     141            "getLayerWarning", {'layerType':'VE', 'layerLib':'VirtualEarth'} 
     142        ); 
    157143    }, 
    158144 
    159145 
  • lib/OpenLayers/Layer/Google.js

    old new  
    309309     *          it working. 
    310310     */ 
    311311    getWarningHTML:function() { 
    312  
    313         var html = ""; 
    314         html += "The Google Layer was unable to load correctly.<br>"; 
    315         html += "<br>"; 
    316         html += "To get rid of this message, select a new BaseLayer "; 
    317         html += "in the layer switcher in the upper-right corner.<br>"; 
    318         html += "<br>"; 
    319         html += "Most likely, this is because the Google Maps library"; 
    320         html += " script was either not included, or does not contain the"; 
    321         html += " correct API key for your site.<br>"; 
    322         html += "<br>"; 
    323         html += "Developers: For help getting this working correctly, "; 
    324         html += "<a href='http://trac.openlayers.org/wiki/Google' "; 
    325         html +=  "target='_blank'>"; 
    326         html +=     "click here"; 
    327         html += "</a>"; 
    328          
    329         return html; 
     312        return OpenLayers.i18n("googleWarning"); 
    330313    }, 
    331314 
    332315 
  • lib/OpenLayers/Layer/GML.js

    old new  
    157157     * request - {String}  
    158158     */ 
    159159    requestFailure: function(request) { 
    160         alert("Error in loading GML file "+this.url); 
     160        alert(OpenLayers.i18n("errorLoadingGML", {'url':this.url})); 
    161161        this.events.triggerEvent("loadend"); 
    162162    }, 
    163163 
  • lib/OpenLayers/Layer/Yahoo.js

    old new  
    155155     *          it working. 
    156156     */ 
    157157    getWarningHTML:function() { 
    158  
    159         var html = ""; 
    160         html += "The Yahoo Layer was unable to load correctly.<br>"; 
    161         html += "<br>"; 
    162         html += "To get rid of this message, select a new BaseLayer "; 
    163         html += "in the layer switcher in the upper-right corner.<br>"; 
    164         html += "<br>"; 
    165         html += "Most likely, this is because the Yahoo library"; 
    166         html += " script was either not correctly included.<br>"; 
    167         html += "<br>"; 
    168         html += "Developers: For help getting this working correctly, "; 
    169         html += "<a href='http://trac.openlayers.org/wiki/Yahoo' "; 
    170         html +=  "target='_blank'>"; 
    171         html +=     "click here"; 
    172         html += "</a>"; 
    173  
    174         return html; 
     158        return OpenLayers.i18n( 
     159            "getLayerWarning", {'layerType':'Yahoo', 'layerLib':'Yahoo'} 
     160        ); 
    175161    }, 
    176162 
    177163  /********************************************************/ 
  • lib/OpenLayers/Layer/MultiMap.js

    old new  
    9797     *          it working. 
    9898     */ 
    9999    getWarningHTML:function() { 
    100  
    101         var html = ""; 
    102         html += "The MM Layer was unable to load correctly.<br>"; 
    103         html += "<br>"; 
    104         html += "To get rid of this message, select a new BaseLayer "; 
    105         html += "in the layer switcher in the upper-right corner.<br>"; 
    106         html += "<br>"; 
    107         html += "Most likely, this is because the MM library"; 
    108         html += " script was either not correctly included.<br>"; 
    109         html += "<br>"; 
    110         html += "Demmlopers: For help getting this working correctly, "; 
    111         html += "<a href='http://trac.openlayers.org/wiki/MultiMap' "; 
    112         html +=  "target='_blank'>"; 
    113         html +=     "click here"; 
    114         html += "</a>"; 
    115  
    116         return html; 
     100        return OpenLayers.i18n( 
     101            "getLayerWarning", {'layerType':"MM", 'layerLib':"MultiMap"} 
     102        ); 
    117103    }, 
    118104 
    119105 
  • lib/OpenLayers/Layer/WFS.js

    old new  
    234234    //DEPRECATED - REMOVE IN 3.0 
    235235        // don't load data if current zoom level doesn't match 
    236236        if (this.options.minZoomLevel) { 
     237            OpenLayers.Console.warn(OpenLayers.i18n('minZoomLevelError')); 
    237238             
    238             var err = "The minZoomLevel property is only intended for use " + 
    239                     "with the FixedZoomLevels-descendent layers. That this " + 
    240                     "wfs layer checks for minZoomLevel is a relic of the" + 
    241                     "past. We cannot, however, remove it without possibly " + 
    242                     "breaking OL based applications that may depend on it." + 
    243                     " Therefore we are deprecating it -- the minZoomLevel " + 
    244                     "check below will be removed at 3.0. Please instead " + 
    245                     "use min/max resolution setting as described here: " + 
    246                     "http://trac.openlayers.org/wiki/SettingZoomLevels"; 
    247             OpenLayers.Console.warn(err); 
    248              
    249239            if (this.map.getZoom() < this.options.minZoomLevel) { 
    250240                return null; 
    251241            } 
     
    481471    commitSuccess: function(request) { 
    482472        var response = request.responseText; 
    483473        if (response.indexOf('SUCCESS') != -1) { 
    484             this.commitReport('WFS Transaction: SUCCESS', response); 
     474            this.commitReport(OpenLayers.i18n("commitSuccess", {'response':response})); 
    485475             
    486476            for(var i = 0; i < this.features.length; i++) { 
    487477                this.features[i].state = null; 
     
    490480            // foreach features: set state to null 
    491481        } else if (response.indexOf('FAILED') != -1 || 
    492482            response.indexOf('Exception') != -1) { 
    493             this.commitReport('WFS Transaction: FAILED', response); 
     483            this.commitReport(OpenLayers.i18n("commitFailed", {'response':response})); 
    494484        } 
    495485    }, 
    496486     
  • lib/OpenLayers/Layer/Vector.js

    old new  
    214214     */ 
    215215    displayError: function() { 
    216216        if (this.reportError) { 
    217             var message = "Your browser does not support vector rendering. " +  
    218                             "Currently supported renderers are:\n"; 
    219             message += this.renderers.join("\n"); 
    220             alert(message); 
     217            alert(OpenLayers.i18n("browserNotSupported",  
     218                                     {'renderers':this.renderers.join("\n")})); 
    221219        }     
    222220    }, 
    223221 
     
    309307            var feature = features[i]; 
    310308             
    311309            if (this.geometryType && 
    312                 !(feature.geometry instanceof this.geometryType)) { 
    313                     var throwStr = "addFeatures : component should be an " +  
    314                                     this.geometryType.prototype.CLASS_NAME
    315                     throw throwStr; 
    316                
     310              !(feature.geometry instanceof this.geometryType)) { 
     311        &