diff --git a/mapit/context_processors.py b/mapit/context_processors.py index 3f70ea7c..e921eb4d 100644 --- a/mapit/context_processors.py +++ b/mapit/context_processors.py @@ -1,6 +1,10 @@ +from django.core.urlresolvers import reverse from django.conf import settings +def index_url(request): + return {'INDEX_URL': reverse('mapit_index')} + def country(request): return { 'country': settings.MAPIT_COUNTRY, diff --git a/mapit/locale/it/LC_MESSAGES/django.mo b/mapit/locale/it/LC_MESSAGES/django.mo new file mode 100644 index 00000000..31484d81 Binary files /dev/null and b/mapit/locale/it/LC_MESSAGES/django.mo differ diff --git a/mapit/locale/it/LC_MESSAGES/django.po b/mapit/locale/it/LC_MESSAGES/django.po new file mode 100644 index 00000000..d9ddd63e --- /dev/null +++ b/mapit/locale/it/LC_MESSAGES/django.po @@ -0,0 +1,1081 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-03-02 16:24+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: shortcuts.py:55 templates/mapit/areas.html:6 +msgid "No matching areas found." +msgstr "Nessun area trovata" + +#: templates/404.html:4 templates/mapit/404.html:4 +msgid "404 Not Found" +msgstr "404 Non trovata" + +#: templates/404.html:8 templates/mapit/404.html:8 +msgid "Sorry, that could not be found." +msgstr "Spiacenti, impossibile trovare questo contenuto." + +#: templates/mapit/400.html:4 +msgid "400 Bad Request" +msgstr "400 Richiesta non valida" + +#: templates/mapit/400.html:8 +msgid "Sorry, you made a bad request: " +msgstr "Spiacenti, ma è stata fatta una richiesta non valida: " + +#: templates/mapit/500.html:4 +msgid "500 Internal Server Error" +msgstr "500 Errore interno del server" + +#: templates/mapit/500.html:8 +msgid "Sorry, something's gone wrong." +msgstr "Spiacenti, qualcosa è andato storto." + +#: templates/mapit/api/area.html:4 +msgid "lookup by area" +msgstr "ricerca per area" + +#: templates/mapit/api/area.html:8 +msgid "URL" +msgstr "" + +#: templates/mapit/api/area.html:11 +msgid "area ID or ONS code" +msgstr "ID dell'area o codice ONS" + +#: templates/mapit/api/area.html:13 templates/mapit/api/area.html.py:19 +#: templates/mapit/api/area.html:21 templates/mapit/api/area.html.py:22 +#: templates/mapit/api/area.html:23 templates/mapit/api/area.html.py:50 +#: templates/mapit/api/area.html:51 templates/mapit/api/area.html.py:53 +#: templates/mapit/api/area.html:54 templates/mapit/api/area.html.py:55 +#: templates/mapit/api/area.html:56 templates/mapit/api/area.html.py:57 +msgid "area ID" +msgstr "ID dell'area" + +#: templates/mapit/api/area.html:16 +msgid "OSM relation ID" +msgstr "ID della relazione OSM" + +#: templates/mapit/api/area.html:17 +msgid "OSM way ID" +msgstr "ID della via OSM" + +#: templates/mapit/api/area.html:22 +msgid "kml or geojson or wkt" +msgstr "kml o geojson o wkt" + +#: templates/mapit/api/area.html:23 +msgid "SRID" +msgstr "" + +#: templates/mapit/api/area.html:23 +msgid "kml or json or wkt" +msgstr "kml o json o wkt" + +#: templates/mapit/api/area.html:25 templates/mapit/api/area.html.py:60 +#: templates/mapit/api/areas.html:22 templates/mapit/api/postcode.html:26 +msgid "Optional query parameters" +msgstr "Parametri di ricerca opzionali" + +#: templates/mapit/api/area.html:26 +msgid "a floating point parameter to simplify the polygons returned" +msgstr "un parametro decimale, per semplificare i poligoni restituiti" + +#: templates/mapit/api/area.html:27 templates/mapit/api/area.html.py:72 +#: templates/mapit/api/areas.html:29 templates/mapit/api/generations.html:10 +#: templates/mapit/api/point.html:65 templates/mapit/api/point.html.py:87 +#: templates/mapit/api/postcode.html:13 templates/mapit/api/postcode.html:45 +msgid "Returns" +msgstr "Restituisce" + +#: templates/mapit/api/area.html:29 +msgid "" +"Information on a particular area, including name, type, parent, and any " +"associated codes (see below for details). The code " +"lookups redirect to the area URI." +msgstr "" +"Informazioni su una particolare area, includono nome, tipo, genitore, e " +"qualsiasi codice associato (vedere nel seguito per i " +"dettagli). Le ricerche per codice redirezionano alla URI dell'area." + +#: templates/mapit/api/area.html:34 +msgid "example_postcode returns a random postcode within the area specified." +msgstr "" +"example_postcode restituisce un codice postale casuale all'interno dell'area " +"specificata." + +#: templates/mapit/api/area.html:36 +msgid "geometry returns centroid, extent and area of the area." +msgstr "" +"geometry restituisce il centroide, l'estensione e l'area dell'area " +"specificata." + +#: templates/mapit/api/area.html:46 +msgid "lookup related areas" +msgstr "ricerca per aree correlate" + +#: templates/mapit/api/area.html:62 +msgid "" +"
  • type, to restrict results to a particular type or types.
  • " +msgstr "" +"
  • tipo, per restringere i risultati a un particolare tipo (o tipi)." +"
  • " + +#: templates/mapit/api/area.html:65 +msgid "" +"
  • generation, to return results from a previous generation " +"(children only).
  • " +msgstr "" +"
  • generation, per restituire risultati di una generazione " +"precedente (solo figli).
  • " + +#: templates/mapit/api/area.html:68 +msgid "" +"
  • min_generation, to return areas since that generation (children " +"only).
  • " +msgstr "" +"
  • min_generation, per restituire risultati a partire da quella " +"generazione (solo figli).
  • " + +#: templates/mapit/api/area.html:73 +msgid "A hash of areas that match the requested lookup." +msgstr "Un gruppo di aree che verifica la ricerca inviata." + +#: templates/mapit/api/areas.html:4 +msgid "lookup multiple areas" +msgstr "ricerca per aree multiple" + +#: templates/mapit/api/areas.html:10 templates/mapit/api/areas.html.py:11 +msgid "area IDs" +msgstr "ID dell'area" + +#: templates/mapit/api/areas.html:12 +msgid "type(s)" +msgstr "tipo(i)" + +#: templates/mapit/api/areas.html:13 +msgid "name prefix" +msgstr "prefisso del nome" + +#: templates/mapit/api/areas.html:15 templates/mapit/api/point.html:13 +#: templates/mapit/api/point.html.py:85 +msgid "Parameters" +msgstr "Parametri" + +#: templates/mapit/api/areas.html:16 +msgid "" +"Separate multiple parameters with commas. Name prefix means it will return " +"any area that starts with the string given." +msgstr "" +"I parametri multipli devono essere separati da virgole. Utilizzando un " +"prefisso vengono restituite tutte le aree che iniziano con il prefisso " +"inserito." + +#: templates/mapit/api/areas.html:24 +msgid "to return areas in that generation (type and name lookups only)" +msgstr "" +"per restituire aree in quella generazione (solo ricerche per tipo e nome)" + +#: templates/mapit/api/areas.html:25 +msgid "to return areas since that generation (type and name lookups only)" +msgstr "" +"per restituire aree a partire da quella generazione (solo ricerche per tipo " +"e nome)" + +#: templates/mapit/api/areas.html:26 +msgid "" +"to restrict results to a type or types (multiple separated by commas; name " +"lookup only)" +msgstr "" +"per restringere i risultati a un particolare tipo o tipi(tipi multipli " +"separati da virgole)" + +#: templates/mapit/api/areas.html:32 +msgid "" +"Information on multiple areas that match the parameters provided, as a " +"dictionary indexed by area ID. The geometry argument lets you fetch multiple " +"single area geometry results at once." +msgstr "" +"Informazioni sulle aree che verificano i parametri di ricerca forniti, come " +"un dizionario, che ha per chiave l'ID di area. L'argomento geometry, " +"permette di ottenere più di una geometria di area singola per volta." + +#: templates/mapit/api/generations.html:5 templates/mapit/generations.html:5 +#: templates/mapit/generations.html.py:9 templates/mapit/index.html:54 +msgid "Generations" +msgstr "Generazioni" + +#: templates/mapit/api/generations.html:11 +msgid "A list of all generations in this installation of MapIt." +msgstr "L'elenco di generazioni in questa installazione di MapIt." + +#: templates/mapit/api/generations.html:20 +msgid "Example" +msgstr "Esempio" + +#: templates/mapit/api/generations.html:21 +msgid "List of generations" +msgstr "Lista delle generazioni" + +#: templates/mapit/api/intro.html:3 +msgid "" +"

    The documentation below is for developers who want to use MapIt as a web " +"service, describing its REST API. If that’s all Greek to you, please " +"see our page for non-developers.

    " +msgstr "" +"

    La documentazione seguente è per sviluppatori che vogliono usare MapIt " +"come un servizio web, e descrive la API REST. Se tutto questo ti sembra " +"Greco, per favore vai alla nostra pagina per non-" +"sviluppatori.

    " + +#: templates/mapit/api/point.html:4 +msgid "lookup by point" +msgstr "ricerca per punto" + +#: templates/mapit/api/point.html:15 +msgid "" +"

    SRID is a unique number referring to a particular co-ordinate " +"system;" +msgstr "" +"

    SRID è un numero univoco, che si riferisce a un particolare " +"sistema di coordinate;" + +#: templates/mapit/api/point.html:20 +msgid "" +"the ones you probably are interested in are 27700 for British National Grid, " +"4326 for WGS84 lon/lat, and 29902 for the Irish National Grid." +msgstr "" +"quelli cui sei interessato probabilmente sono 2770, per il British National " +"Grid, 4326 per il sistema di lon/lat WGS84, e 29902 per l'Irish National " +"Grid." + +#: templates/mapit/api/point.html:26 +msgid "" +"the ones you probably are interested in are 32632 o UTM zone 32N, for Italy " +"or 4326 for WGS84 lon/lat." +msgstr "" +"quello cui sei interessato probabilmente sono 32632 o zona UTM 32N, per " +"l'Italia e 4326 per il sistema normale di lon/lat WGS84." + +#: templates/mapit/api/point.html:31 +msgid "" +"the one you probably are interested in is 4326 for WGS84 normal lon/lat." +msgstr "" +"quello cui sei interessato probabilmente è 4326 per il sistema normale di " +"lon/lat WGS84." + +#: templates/mapit/api/point.html:37 +msgid "" +"

    x and y are the co-ordinates of the point in the co-" +"ordinate system; note that x,y means longitude,latitude.

    " +msgstr "" +"

    x e y sono le coordinate del punto nel sistema di " +"coordinate; nota che x,y significa longitudine,latitudine.

    " + +#: templates/mapit/api/point.html:42 +msgid "
    Optional query parameters:
    " +msgstr "Parametri di ricerca opzionali:" + +#: templates/mapit/api/point.html:48 +msgid "" +"type, to restrict results to a particular area type or types " +"(multiple types separated by commas);" +msgstr "" +"tipo, per restringere i risultati a un particolare tipo o tipi(tipi " +"multipli separati da virgole);" + +#: templates/mapit/api/point.html:53 +msgid "generation, to return results for a previous generation." +msgstr "" +"generation, per restituire risultati di una generazione precedente." + +#: templates/mapit/api/point.html:58 +msgid "min_generation, to return results since that generation." +msgstr "" +"min_generation, per restituire risultati a partire da quella " +"generazione" + +#: templates/mapit/api/point.html:67 +msgid "" +"

    A hash of the areas that the point is contained within. If the /box " +"version is used, only the area bounding boxes are considered.

    " +msgstr "" +"

    Un gruppo di aree che contengono il punto. Se si usa la versione /box," +"sono considerate solamente le bounding box.

    " + +#: templates/mapit/api/point.html:79 +msgid "lookupnearest postcode" +msgstr "ricerca il codice postale più vicino" + +#: templates/mapit/api/point.html:86 +msgid "Same as for" +msgstr "Gli stessi di" + +#: templates/mapit/api/point.html:86 +msgid "by point" +msgstr "per punto" + +#: templates/mapit/api/point.html:88 +msgid "The postcode closest to the particular point." +msgstr "Il codice postale più vicino al punto specificato." + +#: templates/mapit/api/postcode.html:5 +msgid "lookup by postcode" +msgstr "ricerca per codice postale" + +#: templates/mapit/api/postcode.html:11 +msgid "postcode" +msgstr "codice postale" + +#: templates/mapit/api/postcode.html:15 +msgid "

    Information on a particular postcode, including its location in" +msgstr "" +"

    Informazioni su un particolare codice postale, inclusa la sua " +"localizzazione, " + +#: templates/mapit/api/postcode.html:19 +msgid "both National Grid and" +msgstr "nella National Grid" + +#: templates/mapit/api/postcode.html:20 +msgid "WGS84 latitude/longitude, and the areas it is contained within.

    " +msgstr "nel sistema WGS84 di lat/long, e le aree in cui è contenuto." + +#: templates/mapit/api/postcode.html:28 +msgid "

    generation, to return results from a previous generation.

    " +msgstr "" +"

    generation, per restituire risultati di una generazione precedente." +"

    " + +#: templates/mapit/api/postcode.html:39 +msgid "lookup by partial postcode" +msgstr "ricerca per codice postale parziale" + +#: templates/mapit/api/postcode.html:43 +msgid "partial postcode" +msgstr "codice postale parziale" + +#: templates/mapit/api/postcode.html:47 +msgid "" +"

    Geographical details for the centroid of the partial postcode specified." +msgstr "" +"

    Dettagli geografici del centroide del codice postale parziale indicato." + +#: templates/mapit/area.html:12 +msgid "Type" +msgstr "Tipo" + +#: templates/mapit/area.html:13 +msgid "Exists in generations" +msgstr "Esiste nelle generazioni" + +#: templates/mapit/area.html:15 +msgid "Country" +msgstr "Nazione" + +#: templates/mapit/area.html:18 templates/mapit/areas_item.html:8 +msgid "A child of" +msgstr "Un figlio di" + +#: templates/mapit/area.html:22 +msgid "Example postcode" +msgstr "Codice postale di esempio" + +#: templates/mapit/area.html:26 +msgid "Children" +msgstr "Figli" + +#: templates/mapit/area.html:31 templates/mapit/data.html:10 +#: templates/mapit/generations.html:12 templates/mapit/postcode.html:26 +#, python-format +msgid "Get this data as JSON" +msgstr "Prendi questi dati in formato JSON" + +#: templates/mapit/area.html:40 +msgid "Map data © OpenStreetMap contributors" +msgstr "© dei dati di mappa: contributori a OpenStreetMap" + +#: templates/mapit/area.html:76 templates/mapit/area.html.py:78 +msgid "Geometry" +msgstr "Geometria" + +#: templates/mapit/area.html:82 +msgid "on a Google Map" +msgstr "su una Google Map" + +#: templates/mapit/area.html:88 templates/mapit/postcode.html:47 +msgid "Areas" +msgstr "Aree" + +#: templates/mapit/area.html:90 +msgid "Touching this area" +msgstr "Toccano quest'area" + +#: templates/mapit/area.html:91 +msgid "Overlapping this area" +msgstr "Si sovrappongono a quest'area" + +#: templates/mapit/area.html:92 +msgid "Covered by this area" +msgstr "Coperti da quest'area" + +#: templates/mapit/area.html:93 +msgid "Covering this area" +msgstr "Coprono quest'area" + +#: templates/mapit/area.html:94 +msgid "Covered by or overlapping this area" +msgstr "Coperte da o che si sovrappongono a quest'area" + +#: templates/mapit/area.html:95 +msgid "Intersects this area" +msgstr "Intersecano quest'area" + +#: templates/mapit/area.html:100 +msgid "Codes" +msgstr "Codici" + +#: templates/mapit/area.html:111 +msgid "No codes found" +msgstr "Codici non trovati" + +#: templates/mapit/area.html:116 +msgid "Alternative Names" +msgstr "Nomi alternativi" + +#: templates/mapit/area.html:121 +msgid "No alternative names found" +msgstr "Nessun nome alternativo trovato" + +#: templates/mapit/base.html:10 +msgid "" +"MapIt: a web service that maps postcodes and geographical points to " +"administrative areas." +msgstr "" +"MapIt: un servizio web che associa codici postali e punti geografici ad aree " +"amministrative." + +#: templates/mapit/base.html:49 +msgid "MapIt is a charitable project from mySociety" +msgstr "MapIt è un progetto no-profit di mySociety" + +#: templates/mapit/base.html:54 +msgid "Keep us online, Donate Now" +msgstr "Tienici online, Dona ora!" + +#: templates/mapit/base.html:61 +msgid "Home & Documentation" +msgstr "Home e Documentazione" + +#: templates/mapit/copyright.html:2 +msgid "" +"

    You should replace the text here with copyright statements describing the " +"copyright and licenses of the data loaded into this instance of MapIt and " +"the terms under which those data may be used. For an example of such " +"statements, see mapit/templates/gb/mapit/copyright.html." +msgstr "" +"

    Dovresti sostituire questo testo con delle note sul copyright che " +"descrivano copyright e license dei dati caricati su quest'istanza di MapIt e " +"i termini con cui questi dati possano essere usati. Per un esempio di queste " +"note, si veda mapit/templates/gb/mapit/copyright.html." + +#: templates/mapit/country.html:2 +msgid "New Install" +msgstr "Nuova installazione" + +#: templates/mapit/example-postcode.html:5 +msgid "Example postcode in" +msgstr "Codice postale di esempio in" + +#: templates/mapit/example-postcode.html:9 +msgid "An example postcode for" +msgstr "Codice postale di esempio" + +#: templates/mapit/generations.html:18 +msgid "Active" +msgstr "Attiva" + +#: templates/mapit/generations.html:18 +msgid "Inactive" +msgstr "Inattiva" + +#: templates/mapit/index-others.html:2 +msgid "" +"Versions have appeared in other countries, such as Norway, and in 2012 we released a global version based on OpenStreetMap data." +msgstr "" +"Sono comparse versioni in altre nazioni, come Norway, e nel 2012 abbiamo rilasciato una versione globale basata sui dati di OpenStreetMap." + +#: templates/mapit/index-usage.html:4 +msgid "Usage & Licence" +msgstr "Utilizzo e Licenza" + +#: templates/mapit/index-usage.html:6 +msgid "" +"

    To maintain quality of service for our own websites, as well as our API " +"users, this service is rate limited to an average of 1 call per second in a " +"rolling 3 minute period.

    " +msgstr "" +"

    Per mantenere la qualità del servizio dei nostri stessi siti, nonché per " +"gli altri utenti delle nostre API, questo servizio è limitato a una media di " +"1 richiesta/sec in un periodo di 3 minuti.

    " + +#: templates/mapit/index-usage.html:12 +msgid "" +"

    If you use this service, we ask that you attribute MapIt at the point of " +"use on sites or apps. Attribution should use the text “Powered by " +"MapIt”, with a link back to this page.

    " +msgstr "" +"

    Chiediamo anche che tutti gli utenti no-profit attribuiscano MapIt lì " +"dove è utilizzato nei loro siti o nelle loro applicazioni. L'attribuzione " +"dovrebbe usare il testo “Powered by MapIt”, con un collegamento " +"a questa pagina.

    " + +#: templates/mapit/index.html:7 +msgid "MapIt : map postcodes and geographical points to administrative areas" +msgstr "" +"MapIt: associa codici postali e punti geografici ad aree amministrative" + +#: templates/mapit/index.html:23 +msgid "Try it out, enter a postcode" +msgstr "Prova, inserisci un codice postale" + +#: templates/mapit/index.html:24 +msgid "Try it out, enter a lat,lon" +msgstr "Prova, inserisci una latitudine, longitudine" + +#: templates/mapit/index.html:26 +msgid "latitude" +msgstr "latitudine" + +#: templates/mapit/index.html:26 +msgid "longitude" +msgstr "longitudine" + +#: templates/mapit/index.html:27 +msgid "Look up" +msgstr "Ricerca" + +#: templates/mapit/index.html:42 +msgid "Postcode" +msgstr "Codice postale" + +#: templates/mapit/index.html:44 +msgid "Partial postcode" +msgstr "Codice postale parziale" + +#: templates/mapit/index.html:47 +msgid "Point" +msgstr "Punto" + +#: templates/mapit/index.html:49 +msgid "Nearest postcode" +msgstr "Codice postale più vicino" + +#: templates/mapit/index.html:51 +msgid "Area" +msgstr "" + +#: templates/mapit/index.html:52 +msgid "Related areas" +msgstr "Aree correlate" + +#: templates/mapit/index.html:53 +msgid "Multiple areas" +msgstr "Aree multiple" + +#: templates/mapit/index.html:59 templates/mapit/index.html.py:82 +msgid "General information" +msgstr "Informazioni generali" + +#: templates/mapit/index.html:60 templates/mapit/index.html.py:110 +msgid "About MapIt" +msgstr "A proposito di MapIt" + +#: templates/mapit/index.html:61 +msgid "Usage & licence" +msgstr "Uso e Licenza" + +#: templates/mapit/index.html:62 +msgid "Source code" +msgstr "Codice sorgente" + +#: templates/mapit/index.html:64 +msgid "Changelog" +msgstr "Elenco dei cambiamenti" + +#: templates/mapit/index.html:84 +msgid "Format" +msgstr "Formato" + +#: templates/mapit/index.html:87 +msgid "" +"

    All calls return JSON, you can generally get an HTML representation by " +"sticking .html on the end.

    " +msgstr "" +"

    Tutte le chiamate restituiscono JSON, puoi ottenere una rappresentazione " +"HTML attaccando .html alla fine.

    " + +#: templates/mapit/index.html:92 +msgid "" +"

    Whenever an area is returned from MapIt, it is as a dictionary with the " +"following keys: id, name, country, type, parent_area, generation_low, " +"generation_high, codes.

    " +msgstr "" +"

    Quando un area viene restituita da MapIt, è un dizionario con le seguenti " +"chiavi: id, name, country, type, parent_area, generation_low, " +"generation_high, codes.

    " + +#: templates/mapit/index.html:98 +msgid "Historical areas" +msgstr "Aree storiche" + +#: templates/mapit/index.html:100 +msgid "" +"By default, calls will return active areas; for some calls you may specify a " +"previous generation to look up instead." +msgstr "" +"Per definizione, le chiamate restituiscono esclusivamente le aree attive; " +"per alcune chiamate puoi specificare di voler ricercare generazioni passate." + +#: templates/mapit/index.html:112 +msgid "" +"

    MapIt was written back in 2003 as a postcode lookup to power the original " +"mySociety sites such as WriteToThem. Over time it gained " +"features such as point lookup (for FixMyStreet), and when Ordnance Survey data became freely available " +"in 2010, it was rewritten and made public for the whole UK." +msgstr "" +"MapIt è stato scritto nel 2003 come un servizio di ricerca di codici postali " +"usato internamente da applicazioni di mySociety, come WriteToThem. Nel corso del tempo sono state aggiunte funzionalità, come la ricerca " +"per punto (per FixMyStreet), e " +"quando i dati dell Ordnance Survey sono diventati liberi, nel 2012, è stato " +"riscritto e reso pubblico per tutto il Regno Unito." + +#: templates/mapit/intro.html:3 +msgid "" +"

    MapIt is a service that maps postcodes and geographical points to " +"administrative areas. It’s useful for anyone who has the co-ordinates " +"of a particular point, and needs to find out what regions it lies within. " +"It’s also great for looking up the shapes of all those boundaries.

    " +msgstr "" + +#: templates/mapit/intro.html:10 +msgid "" +"

    MapIt is a service that maps geographical points to administrative areas. " +"It’s useful for anyone who has the co-ordinates of a particular point, " +"and needs to find out what regions it lies within. It’s also great for " +"looking up the shapes of all those boundaries.

    " +msgstr "" + +#: templates/mapit/intro.html:17 +msgid "" +"

    You can download the " +"source on Github.

    " +msgstr "" +"

    Puoi scaricare il codice " +"sorgente su Github.

    " + +#: templates/mapit/licensing.html:4 templates/mapit/licensing.html.py:8 +msgid "Usage and licensing" +msgstr "Uso e Licenza" + +#: templates/mapit/licensing.html:10 +msgid "" +"

    This service is free of charge for non-profit low volume use. ‘Non-" +"profit low volume use’ means use by registered UK charities or " +"individuals working unpaid on a non-profit project, and that does not exceed " +"50,000 calls a year. Please attribute us with the text “Powered by Mapit” " +"and a link back to the MapIt front page. If you are using the API for a " +"charitable purpose and are unsure of the likely volume please contact us in " +"advance by emailing enquiries@mysociety.org.

    All other users need to get a " +"licence. We have a range of pricing options depending on the volumes you " +"expect. Our licences cover 12 months, and we offer discounts to charities. " +"Please email us on enquiries@mysociety.org with details of your expected volumes, " +"and we will let you know the costs.

    " +msgstr "" +"

    Questo servizio è gratuito per un utilizzo no-profit e limitato.‘" +"Utilizzo no-profit e limitato’ significa utilizzo da parte di una " +"organizzazione no-profit registrata o un individuo che lavora non retribuito " +"in un progetto no-profit, con un numero di richieste che non superi le " +"50'000 per anno. Per favore menzionateci con il testo “Powered by Mapit” e " +"un link alla pagina principale di MapIt.Se usate MapIt per uno scopo no-" +"profit e non siete sicuri del probabile volume delle vostre richieste, per " +"favore contattateci in anticipo scrivendo una email a enquiries@mysociety.org.

    Tutti " +"gli altri ustenti devono ottenere una licenza. Abbiamo un range di prezzi " +"che dipendono dai volumi di richieste attesi. Le licenze coprono 12 mesi e " +"forniamo sconti per le organizzazioni no-profit. Per favore inviate una " +"email a enquiries@" +"mysociety.org col dettaglio del volume di richieste attese, e vi faremo " +"sapere i costi.

    " + +#: templates/mapit/licensing.html:26 templates/mapit/overview.html:106 +msgid "Rate limiting" +msgstr "Limite al numero di richieste" + +#: templates/mapit/licensing.html:28 +msgid "" +"

    The standard paid service is limited to an average of 1 call per second " +"in a rolling 3 minute period. If you need more than this, we can set you up " +"a dedicated service. Please get in touch.

    " +msgstr "" +"

    Il servizio standard, pagato, è limitato a una media di 1 richiesta al " +"secondo in un periodo di 3 minuti. Se hai bisogno di più richieste, possiamo " +"attivare un servizio dedicato. Per favore contattaci.

    " + +#: templates/mapit/licensing.html:34 +msgid "Self-installed versions of MapIt" +msgstr "Versioni auto-installate di MapIt" + +#: templates/mapit/licensing.html:36 +msgid "" +"

    Some organisations prefer to install their own internal version on MapIt. " +"We are happy to help with this. Depending on your needs, we can advise your " +"technical team on how to do this, or our developers can install it for you." +msgstr "" +"

    Alcune organizzazioni preferiscono installare la loro versione interna di " +"MapIt. Siamo felici di aiutare. A seconda dei vostri bisogni, possiamo " +"consigliare il vostro team di sviluppo su come farlo, oppure i nostri " +"tecnici possono farlo per voi.

    " + +#: templates/mapit/licensing.html:42 +msgid "One-off data range searches" +msgstr "Singole ricerche per grandi dati" + +#: templates/mapit/licensing.html:44 +msgid "" +"

    We also offer one-off look-ups for large data sets – this is useful " +"when you don’t need to use the API but simply have data that you need " +"matched (e.g. a list of postcodes to match to the constituencies they fall " +"into). We can do this for you quickly and easily.

    " +msgstr "" +"

    Offriamo anche singole ricerche per grandi insiemi di dati – questo " +"è utile quando non avete bisogno di usare le API continuamente, ma dovete " +"semplicemente ottenere dei dati per effettuare delle ricerche (ad esempio " +"una lista di codici postali da mettere in corrispondenza con i collegi " +"elettorali in cui ricadono). Possiamo fare questo lavoro per voi rapidamente " +"e facilmente.

    " + +#: templates/mapit/licensing.html:51 +msgid "Geometry files" +msgstr "File di geometrie" + +#: templates/mapit/licensing.html:53 +msgid "" +"

    If you need to use the API to download the MapIt geometry files, you can " +"do so for free for up to 50,000 files if you are a registered UK charity or " +"an individual working on a non-profit project. If you are not, or need more " +"than 50,000 files, we can licence them to you.

    For all " +"enquiries about licensing, please drop us a line with some information about " +"what you’re looking to do, and we’ll get in touch to discuss how we can help " +"you.

    " +msgstr "" +"

    Se avete bisogno di usare le API per scaricare i file di geometrie, " +"potete farlo gratuitamente fino a 50'000 file, se siete una organizzazione " +"no-profit registrata, o un individuo che lavora su un progetto no-profit. In " +"ogni altro caso possiamo fornirvi una licenza.

    Per tutte le " +"richieste sulle licenze, per favore inviateci una mail con qualche " +"informazione su quello che volete fare, e vi contatteremo per discutere di " +"come possiamo aiutarvi.

    " + +#: templates/mapit/overview.html:4 templates/mapit/overview.html.py:8 +msgid "MapIt for non-developers" +msgstr "MapIt per non sviluppatori" + +#: templates/mapit/overview.html:10 +msgid "" +"

    MapIt is a system that sends data about administrations and other " +"location-related data in response to requests from a website or service. " +"This is useful if you are building services that require these data, for " +"example, to identify which ward a postcode is in, what the nearest postcode " +"is to a point on a map, or what the boundaries of an administrative area are " +"– and many, many others.

    In technical terms MapIt is classed as " +"an API which stands for Application Programming Interface. It allows an " +"external service to query data held in a database and return results. This " +"removes the need to build such a database yourself – you can simply " +"use MapIt in your application or site." +msgstr "" +"

    MapIt è un sistema che invia dati sulle aree amministrative, ed altri " +"dati legati alla località, in risposta a richieste da un sito web o un " +"servizio. Può essere utile se state costruendo dei servizi che richiedano " +"questi dati, per esempio, per identificare in quale municipio si trovi un " +"codice postale, quale è il codice postale più vicino a un dato punto su una " +"mappa o quali siano i confini di un'area amministrativa e molto, molto altro." +"

    In termini tecnici, MapIt è classificabile come una API, che " +"significa Interfaccia di Programmazione Applicativa. Permette a un servizio " +"esterno di effettuare ricerche in una base dati e ottenere risultati. " +"Questo rimuove la necessità di costruire questo database da soli – " +"potete usare MapIt nelle vostre applicazioni." + +#: templates/mapit/overview.html:24 +msgid "Example applications" +msgstr "Applicazioni di esempio" + +#: templates/mapit/overview.html:26 +msgid "" +"MapIt can be used for all sorts of websites and applications. For example" +msgstr "" +"MapIt può essere usato per tutti i tipi di siti web e applicazioni. Per " +"esempio" + +#: templates/mapit/overview.html:30 +msgid "" +"

  • FixMyStreet is " +"mySociety’s street problem reporting service, which uses MapIt to find " +"the right area on the map when the user enters their postcode, and to assign " +"problem reports to the correct local authority when the user drops a pin on " +"the map to show the problem’s location. It also relies on MapIt to plot local authority " +"boundaries.
  • Land Layer is a web-based resource aimed at the strategic land professional and " +"others who need access via a single map-based tool to their business " +"information. Land Layer was launched in 2012, and combines a series of " +"functions and business information that benefits users by reducing the time " +"to enter or retrieve data either at their desk or in the field. Users can " +"quickly record information to a ‘Pin’ on a digital map, which has layers of " +"public, private and inter-company data. Users can also 'flag' on the map " +"projects where they have been involved, adding a spatially targeted " +"dimension to marketing. Land Layer uses the Mapit API to display local " +"authority boundaries and to provide information on the political control of " +"that authority.
  • PepysRd.com is " +"an innovative marketing site for the novel Capital by John Lanchester, " +"released by Faber in spring 2012. Storythings developed a 10 day experience " +"that used live data from the web and new texts from John Lanchester to tell " +"the story of the next 10 years. A core part of this experience was a series " +"of data illustrations by James Bridle, using live data to reflect on the " +"role of markets and infrastructure in our lives. Storythings used MapIt for " +"a number of these illustrations, using its fantastic location data to " +"provide unique and realtime story elements for the project.
  • GOV.UK – the UK Government’s digital " +"portal – uses an installation of MapIt to enable visitors to its " +"website find the right information on local public services based on their " +"postcode.
  • " +msgstr "" +"
  • FixMyStreet è un servizio di " +"mySociety, che permette di inviare segnalazioni su problemi stradali e di " +"circolazione. Permette di trovare l'area corretta sulla mappa, in seguito " +"all'inserimento di un codice postale, e di assegnare la segnalazione " +"all'autorità locale competente, quando l'utente indica sulla mappa il punto " +"esatto della segnalazione. Fa affidamento su MapIt anche per tracciare i confini delle " +"autorità locali .
  • GOV.UK " +"– il portale digitale del governo inglese usa un'installazione di " +"MapIt per permettere ai visitatori di trovare le informazioni sui servizi " +"pubblici locali, a partire dal loro codice di avviamento postale.
  • " + +#: templates/mapit/overview.html:68 +msgid "Possible uses" +msgstr "Possibili utilizzi" + +#: templates/mapit/overview.html:70 +msgid "MapIt can be used for the following" +msgstr "MapIt può essere usato per i seguenti scopi" + +#: templates/mapit/overview.html:74 +msgid "" +"
  • For a postcode: find the National Grid and latitude and longitude co-" +"ordinates for a postcode, and which administrative areas it belongs to, such " +"as ward, the local authority area, super output areas, the parliamentary " +"constituency, and the European region.
  • Partial postcode such as " +"SW1A: find the national grid and latitude/longitude co-ordinates for the " +"centre of that partial postcode.
  • Point: find out which " +"administrative areas a point (expressed as a latitude/longitude) is " +"contained in.
  • Nearest postcode: find the nearest postcode to a " +"point on the map.
  • By area: find data on an administrative area, " +"such as its boundaries, or an example postcode in this area. You can also " +"get “digital boundaries” to map the area, in e.g. WKT, GeoJSON or KML " +"formats, for use with maps and/or geographic information systems.
  • " +"
  • Related areas: look up which administrative areas are contained within " +"an area (e.g. all wards of a council), which areas it borders with, covers " +"and/or overlaps with.
  • Multiple areas: get information about several " +"areas at once, by type of area (e.g. city council) or area name.
  • " +"
  • Generations: shows a list of updates to MapIt information, with a unique " +"number for each update (or “generation”). This helps with instances where " +"you want to query historical data, for example.
  • " +msgstr "" +"
  • Per Codice Postale: trova latitudine e longitudine del centro " +"dell'arearinchiusa dal Codice di Avviamento Postale, trova le aree " +"amministrative cui appartiene, come: municipio, Comune, Provincia, Regione, " +"collegi elettorali e regione europea.
  • Codice Postale parziale, come " +"00100: trova latitudine e longitudine del centro dell'area corrispondente a " +"quel codice.
  • Punto: Trova quali sono le aree amministrative che " +"contengono un punto (espresso come latitudine/longitudine)
  • Codice " +"postale più vicino: trova il codice postale più vicino a un dato punto della " +"mappa.
  • Per area: trova dati di un'area, come i confini, o un codice " +"postale di esempio.Puoi anche scaricare i confini in formato digitale: WKT, " +"GeoJSON, KML, per usarli con mappe o altri sistemi informativi geografici
  • Aree correlate: cerca quali aree amministrative sono contenute in una " +"data ara (ad esempio tutti i municipi di un comune), quali aree sono " +"confinanti, quali sono quelle che la ricoprono o vi si sovrappongono.
  • Aree multiple: recupera informazioni su più di un'area " +"contemporaneamente, a partire dal tipo di area (ad esempio i Comuni), o dal " +"nome.
  • Generazioni: mostra una lista di aggiornamenti dei dati di " +"MapIt, con un numero unico per ogni aggiornamento (o \"generazione\").
  • " + +#: templates/mapit/overview.html:108 +msgid "" +"

    The service has an automatic counter that tracks the number of requests " +"sent to it by a user, and limits requests if they reach a certain volume. " +"This is set at an average of 1 call per second in a rolling 3 minute period. " +"The reason to do this is to make sure the service does not get overwhelmed " +"by huge requests volumes which could risk it going down for all users.

    " +"

    Where the limit is exceeded, the service will stop sending data until the " +"average goes back within the set limit.

    " +msgstr "" +"

    Il servizio ha un contatore automatico che tiene traccia del numero di " +"richieste inviate da un utente e limita le richieste se queste raggiungono " +"una certa soglia. Questa soglia è fissata ad una media di 1 richiesta al " +"secondo per un periodo di 3 minuti. Il motivo di questa limitazione è quello " +"di assicurare che il servizio non sia sovraccaricato da troppe richieste, " +"che rischierebbero di renderlo non più raggiungibile per tutti.

    " +"

    Quando il limite viene raggiunto, il servizio smettera di rispondere, " +"fino a quando i valori medi non siano tornati nei limiti stabiliti." + +#: templates/mapit/postcode.html:5 +msgid "Results for" +msgstr "Risultati per" + +#: templates/mapit/postcode.html:17 +msgid "WGS84 lat/lon" +msgstr "lat/lon WGS84" + +#: templates/mapit/postcode.html:19 +msgid "" +"No location information. Note this is a valid postcode (otherwise " +"you would have got a 404), just one for which we don’t know the " +"location." +msgstr "" +"Nessuna informazione sulla località. Notare che questo è un " +"codicevalido (altrimenti si sarebbe ottenuto un errore 404), si tratta solo " +"di un codice del quale non conosciamo la località." + +#: views/areas.py:56 +msgid "Bad generation specified" +msgstr "Generazione non valida o inesistente" + +#: views/areas.py:63 +msgid "Bad min_generation specified" +msgstr "min_generation invalida o inesistente" + +#: views/areas.py:99 views/areas.py:143 +msgid "Bad area ID specified" +msgstr "ID dell'area invalido o inesistente" + +#: views/areas.py:154 +msgid "Badly specified tolerance" +msgstr "Tolleranza invalida o inesistente" + +#: views/areas.py:159 views/areas.py:181 views/areas.py:268 +msgid "No polygons found" +msgstr "Nessun poligono trovato" + +#: views/areas.py:175 +#, python-format +msgid "Children of %s" +msgstr "Figli di %s" + +#: views/areas.py:195 +msgid "" +"That query was taking too long to compute - try restricting to a specific " +"type, if you weren't already doing so." +msgstr "" +"La query stava prendendo troppo tempo - prova a restringere a un " +"tipospecifico, se non lo stavi già facendo" + +#: views/areas.py:198 +msgid "There was an internal error performing that query." +msgstr "Si è verificato un errore interno durante la query" + +#: views/areas.py:206 +#, python-format +msgid "Areas touching %s" +msgstr "Aree che toccano %s" + +#: views/areas.py:211 +#, python-format +msgid "Areas overlapping %s" +msgstr "Aree che si sovrappongono a %s" + +#: views/areas.py:216 +#, python-format +msgid "Areas covered by %s" +msgstr "Aree coperte da %s" + +#: views/areas.py:221 +#, python-format +msgid "Areas covered by or overlapping %s" +msgstr "Aree coperte da o che si sovrappongono a %s" + +#: views/areas.py:226 +#, python-format +msgid "Areas that cover %s" +msgstr "Aree che coprono %s" + +#: views/areas.py:231 +#, python-format +msgid "Areas that intersect %s" +msgstr "Aree che intersecano %s" + +#: views/areas.py:238 +msgid "Areas ID lookup" +msgstr "Ricerca per ID di aree" + +#: views/areas.py:245 +#, python-format +msgid "Areas in %s" +msgstr "Aree in %s" + +#: views/areas.py:253 +#, python-format +msgid "Areas starting with %s" +msgstr "Aree che iniziano per %s" + +#: views/areas.py:313 +#, python-brace-format +msgid "No areas were found that matched code {0} = {1}." +msgstr "Nessun area trovata che verifichi il codice {0} = {1}" + +#: views/areas.py:316 +#, python-brace-format +msgid "There were multiple areas that matched code {0} = {1}." +msgstr "Più di un'area trovata che verifia il codice {0} = {1}" + +#: views/areas.py:329 +msgid "Point outside the area geometry" +msgstr "Punto fuori la geometria dell'area" + +#: views/areas.py:358 +#, python-brace-format +msgid "Areas covering the point ({0},{1})" +msgstr "Aree che coprono il punto ({0},{1})" + +#: views/areas.py:397 +msgid "No content specified" +msgstr "Contenuto non valido o inesistente" diff --git a/mapit/management/commands/mapit_export_geojson_areas.py b/mapit/management/commands/mapit_export_geojson_areas.py new file mode 100644 index 00000000..06b0afef --- /dev/null +++ b/mapit/management/commands/mapit_export_geojson_areas.py @@ -0,0 +1,185 @@ +# This script is used to export geometry information from Mapit +# as geojson (TODO: kml) +# +# Copyright (c) 2015 Openpolis. All rights reserved. +# Email: guglielmo at openpolis it; WWW: http://www.openpolis.it + + +import json +import logging +from optparse import make_option +from django.conf import settings +from django.contrib.gis.geos import Polygon, MultiPolygon +from django.core.management.base import NoArgsCommand +import sys +from mapit.models import Area + +__author__ = 'guglielmo' + + +class Command(NoArgsCommand): + help = 'Export specified areas into a geojson file' + option_list = NoArgsCommand.option_list + ( + make_option('--code-type', + dest='code_type', + help='Type of code to add as property in the geojson feature (ISTAT_COM, ...)'), + make_option('--ids', + dest='ids', + default='', + help='Comma separated list of areas ids to export'), + make_option('--filters', + dest='filters', + default='', + help='django_orm like filtering instructions (codes__code__contains:502&codes__code__lt:503'), + make_option('--simplify-tolerance', + dest='simplify_tolerance', + default=0., + help='Distance on the map within which more than 1 points will collapse.'), + make_option('--srid', + dest='srid', + default='4326', + help='The SRID'), + make_option('--outfile', + dest='outfile', + default=None, + help='Path to the output file (defaults to stdout)'), + ) + + FORMAT = "[%(asctime)s] %(levelname)s - %(message)s" + logging.basicConfig(format=FORMAT, level=logging.INFO) + logger = logging.getLogger(__name__) + + def handle(self, **options): + self.verbosity = options['verbosity'] + self.code_type = options['code_type'] + self.ids = options['ids'] + self.filters = options['filters'] + self.simplify_tolerance = float(options['simplify_tolerance']) + self.srid = options['srid'] + self.outfile = options['outfile'] + + # set log level, from verbosity + if self.verbosity == '0': + self.logger.setLevel(logging.ERROR) + elif self.verbosity == '1': + self.logger.setLevel(logging.WARNING) + elif self.verbosity == '2': + self.logger.setLevel(logging.INFO) + elif self.verbosity == '3': + self.logger.setLevel(logging.DEBUG) + + self.logger.info("Start") + + areas = Area.objects.select_related('type').all() + + if self.ids: + self.ids = map(int, self.ids.split(',')) + areas = areas.filter(id__in=self.ids) + + self.logger.debug("Filters: {0}".format(self.filters)) + if self.filters: + filters = dict(map(lambda x: x.split(":"), self.filters.split("&"))) + areas = areas.filter(**filters) + + # limit areas to 10 if no filters or ids are specified + if not self.ids and not self.filters: + areas = areas[:10] + + with (open(self.outfile, 'w') if self.outfile else sys.stdout) as out: + out.write( + self._areas_geojson(areas) + ) + + self.logger.info("End") + + def _areas_geojson(self, areas): + out = { + "type": "FeatureCollection", + "features": [] + } + for area in areas: + self.logger.info( + u"Processing {a.name} (id: {a.id})".format(a=area) + ) + try: + all_areas = area.polygons.all() + if len(all_areas) > 1: + all_areas = all_areas.collect() + elif len(all_areas) == 1: + all_areas = all_areas[0].polygon + else: + return (None, None) + + if self.srid != settings.MAPIT_AREA_SRID: + all_areas.transform(self.srid) + + num_points_before_simplification = all_areas.num_points + if self.simplify_tolerance: + n_removed_points = int( + num_points_before_simplification * + self.simplify_tolerance + ) + all_areas = self.fix_geometry( + all_areas, + self.simplify_tolerance, + area.id, area.name + ) + if all_areas.num_points == 0 and \ + num_points_before_simplification > 0: + self.logger.warning( + u"Could not add this area." + + u"Zero points after simplification." + ) + continue + else: + self.logger.debug( + u" {0} points after simplification.". + format(all_areas.num_points) + ) + + except Exception as e: + self.logger.warning( + u"Could not add this area. " + + u"Exception {0}".format(e) + ) + continue + + out['features'].append( + {"type": "Feature", + "geometry": json.loads(all_areas.geojson), + "properties": { + "nome": area.name, + "codice": area.codes.get( + type__code=self.code_type + ).code if self.code_type else None + } + } + ) + return json.dumps(out) + + + def fix_geometry(self, geom, precision, id, name): + if type(geom).__name__ == 'Polygon': + return self.fix_poly(geom, precision, id, name) + if type(geom).__name__ == 'MultiPolygon': + return self.fix_mpoly(geom, precision, id, name) + + + def fix_poly(self, poly, precision, id, name): + new_rings = [] + for ring in poly: + points = ring.simplify(precision, preserve_topology=True) + new_rings.append(points) + new_poly = Polygon(*new_rings) + return new_poly + + + def fix_mpoly(self, mpoly, precision, id, name): + new_polies = [] + for poly in mpoly: + poly = self.fix_poly(poly, precision, id, name) + new_polies.append(poly) + new_mpoly = MultiPolygon(*new_polies) + return new_mpoly + + diff --git a/mapit/management/commands/mapit_import_area_unions.py b/mapit/management/commands/mapit_import_area_unions.py index 64f5e1fe..0c1f55ff 100644 --- a/mapit/management/commands/mapit_import_area_unions.py +++ b/mapit/management/commands/mapit_import_area_unions.py @@ -6,10 +6,13 @@ # the GPL. Based on import_norway_osm.py by Matthew Somerville import csv +import logging from optparse import make_option +from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned from django.core.management.base import LabelCommand from django.contrib.gis.geos import GEOSGeometry +from django.db.models.query import EmptyQuerySet from django.utils.six import Iterator from mapit.models import Area, Generation, Geometry, Country, Type @@ -17,7 +20,7 @@ # CSV format is -# ID;code;name;area1,area2,...;email;categories +# ID;code;name;area1,area2,... # Copied from # http://www.mfasold.net/blog/2010/02/python-recipe-read-csvtsv-textfiles-and-ignore-comment-lines/ @@ -40,32 +43,59 @@ class Command(LabelCommand): help = 'Import region data' args = '' option_list = LabelCommand.option_list + ( - make_option('--commit', action='store_true', dest='commit', help='Actually update the database'), + make_option( + '--commit', action='store_true', dest='commit', help='Actually update the database' + ), + make_option( + '--country-code', dest='country_code', default='O', help='The country code to assign to created area' + ), + ) + FORMAT = "[%(asctime)s] %(levelname)s - %(message)s" + logging.basicConfig(format=FORMAT, level=logging.INFO) + logger = logging.getLogger(__name__) + def handle_label(self, filename, **options): + self.verbosity = options['verbosity'] + + # set log level, from verbosity + if self.verbosity == '0': + self.logger.setLevel(logging.ERROR) + elif self.verbosity == '1': + self.logger.setLevel(logging.WARNING) + elif self.verbosity == '2': + self.logger.setLevel(logging.INFO) + elif self.verbosity == '3': + self.logger.setLevel(logging.DEBUG) + current_generation = Generation.objects.current() new_generation = Generation.objects.new() if not new_generation: - print("Using current generation %d" % current_generation.id) + self.logger.info("Using current generation %d" % current_generation.id) new_generation = current_generation else: - print("Using new generation %d" % new_generation.id) + self.logger.info("Using new generation %d" % new_generation.id) - print("Loading file %s" % filename) + self.logger.info("Loading file %s" % filename) region_line = csv.reader(CommentedFile(open(filename, "rb")), delimiter=';') - for regionid, area_type, regionname, area_names, email, categories in region_line: - print("Building region '%s'" % regionname) - if (-2147483648 > int(regionid) or 2147483647 < int(regionid)): + for regionid, area_type, regionname, area_names in region_line: + self.logger.info("Building region '%s'" % regionname) + if regionid and regionid.trim() != "": + regionid = int(regionid) + else: + regionid = 0 + + if (-2147483648 > regionid or 2147483647 < regionid): raise Exception("Region ID %d is outside range of 32-bit integer" % regionid) if area_names: # Look up areas using the names, find their geometry # and build a geometric union to set as the geometry # of the region. - geometry = None + geometry = Geometry.objects.none() for name in area_names.split(','): name.strip() name.lstrip() @@ -73,60 +103,65 @@ def handle_label(self, filename, **options): try: # Use this to allow '123 Name' in area definition areaidnum = int(name.split()[0]) - print("Looking up ID '%d'" % areaidnum) + self.logger.debug("Looking up ID '%d'" % areaidnum) args = { 'id__exact': areaidnum, - 'generation_low__lte': current_generation, - 'generation_high__gte': new_generation, + 'generation_low__lte': current_generation.id, + 'generation_high__gte': new_generation.id, } except (ValueError, IndexError): - print("Looking up name '%s'" % name) + self.logger.debug("Looking up name '%s'" % name) args = { 'name__iexact': name, - 'generation_low__lte': current_generation, - 'generation_high__gte': new_generation, + 'generation_low__lte': current_generation.id, + 'generation_high__gte': new_generation.id, } - area_id = Area.objects.filter(**args).only('id') - if 1 < len(area_id): - raise Exception("More than one Area named %s, use area ID as well" % name) + try: - print("ID: %d" % area_id[0].id) + area = Area.objects.get(**args) + self.logger.debug("ID: %d" % area.id) args = { - 'area__exact': area_id[0].id, + 'area__exact': area.id, } - if geometry: - geometry = geometry | Geometry.objects.filter(**args) - else: - geometry = Geometry.objects.filter(**args) - except: - raise Exception("Area or geometry with name %s was not found!" % name) - unionoutline = geometry.unionagg() - - def update_or_create(): - try: - m = Area.objects.get(id=int(regionid)) - print("Updating area %s with id %d" % (regionname, int(regionid))) + except Area.MultipleObjectsReturned: + raise Exception("More than one Area named %s, use area ID as well" % name) except Area.DoesNotExist: - print("Creating new area %s with id %d" % (regionname, int(regionid))) - m = Area( - id=int(regionid), - name=regionname, - type=Type.objects.get(code=area_type), - country=Country.objects.get(code='O'), - generation_low=new_generation, - generation_high=new_generation, - ) - - if m.generation_high and current_generation \ - and m.generation_high.id < current_generation.id: - raise Exception("Area %s found, but not in current generation %s" % (m, current_generation)) - m.generation_high = new_generation - - poly = [GEOSGeometry(unionoutline).ogr] - if options['commit']: - m.save() - save_polygons({regionid: (m, poly)}) - - update_or_create() + raise Exception("Area with name %s was not found!" % name) + + geometry = geometry | Geometry.objects.filter(**args) + + + unionoutline = geometry.unionagg() + + try: + m = Area.objects.get(id=regionid) + self.logger.info("Updating area %s with id %d" % (regionname, regionid)) + except Area.DoesNotExist: + m = Area( + name=regionname, + type=Type.objects.get(code=area_type), + country=Country.objects.get(code=options['country_code']), + generation_low=new_generation, + generation_high=new_generation, + ) + + + # if id is explicitly specified + # then it is set + if regionid: + m.id = regionid + + self.logger.info("Creating new area %s with id %d" % (regionname, int(regionid))) + + if m.generation_high and current_generation \ + and m.generation_high.id < current_generation.id: + raise Exception("Area %s found, but not in current generation %s" % (m, current_generation)) + m.generation_high = new_generation + + poly = [GEOSGeometry(unionoutline).ogr] + if options['commit']: + m.save() + save_polygons({regionid: (m, poly)}) + else: raise Exception("No area names found for region with name %s!" % regionname) diff --git a/mapit/management/find_parents.py b/mapit/management/find_parents.py index 7702b203..153d913c 100644 --- a/mapit/management/find_parents.py +++ b/mapit/management/find_parents.py @@ -27,6 +27,10 @@ def handle_noargs(self, **options): generation_low__lte=new_generation, generation_high__gte=new_generation, ): parent = None + if int(options['verbosity']) >= 2: + self.stdout.write("Processing %s" % ( + self.pp_area(area) + )) for polygon in area.polygons.all(): try: args = { @@ -45,7 +49,7 @@ def handle_noargs(self, **options): if not parent: raise Exception("Area %s does not have a parent?" % (self.pp_area(area))) if area.parent_area != parent: - print("Parent for %s was %s, is now %s" % ( + self.stdout.write("Parent for %s was %s, is now %s" % ( self.pp_area(area), self.pp_area(area.parent_area), self.pp_area(parent))) if options['commit']: area.parent_area = parent diff --git a/mapit/static/mapit/img/django-logo-negative.svg b/mapit/static/mapit/img/django-logo-negative.svg new file mode 100644 index 00000000..80cbe71c --- /dev/null +++ b/mapit/static/mapit/img/django-logo-negative.svg @@ -0,0 +1,41 @@ + + + + +]> + + + + + + + + + + + + + diff --git a/mapit/static/mapit/img/openpolis-tool.png b/mapit/static/mapit/img/openpolis-tool.png new file mode 100644 index 00000000..b4b54240 Binary files /dev/null and b/mapit/static/mapit/img/openpolis-tool.png differ diff --git a/mapit/templates/404.html b/mapit/templates/404.html index 8bfebda9..b6091ec1 100644 --- a/mapit/templates/404.html +++ b/mapit/templates/404.html @@ -1,9 +1,10 @@ {% extends "mapit/base.html" %} +{% load i18n %} -{% block title %}404 Not Found{% endblock %} +{% block title %}{% trans "404 Not Found" %}{% endblock %} {% block content %} -

    Sorry, that could not be found.

    +

    {% trans "Sorry, that could not be found." %}

    {% endblock %} diff --git a/mapit/templates/mapit/400.html b/mapit/templates/mapit/400.html index 6ac85d96..d205e19c 100644 --- a/mapit/templates/mapit/400.html +++ b/mapit/templates/mapit/400.html @@ -1,9 +1,10 @@ {% extends "mapit/base.html" %} +{% load i18n %} -{% block title %}400 Bad Request{% endblock %} +{% block title %}{% trans "400 Bad Request" %}{% endblock %} {% block content %} -

    Sorry, you made a bad request: {{ error }}

    +

    {% trans "Sorry, you made a bad request: " %}{{ error }}

    {% endblock %} diff --git a/mapit/templates/mapit/404.html b/mapit/templates/mapit/404.html index 8bfebda9..b6091ec1 100644 --- a/mapit/templates/mapit/404.html +++ b/mapit/templates/mapit/404.html @@ -1,9 +1,10 @@ {% extends "mapit/base.html" %} +{% load i18n %} -{% block title %}404 Not Found{% endblock %} +{% block title %}{% trans "404 Not Found" %}{% endblock %} {% block content %} -

    Sorry, that could not be found.

    +

    {% trans "Sorry, that could not be found." %}

    {% endblock %} diff --git a/mapit/templates/mapit/500.html b/mapit/templates/mapit/500.html index d04097e3..68e69894 100644 --- a/mapit/templates/mapit/500.html +++ b/mapit/templates/mapit/500.html @@ -1,9 +1,10 @@ {% extends "mapit/base.html" %} +{% load i18n %} -{% block title %}500 Internal Server Error{% endblock %} +{% block title %}{% trans "500 Internal Server Error" %}{% endblock %} {% block content %} -

    Sorry, something's gone wrong. {{ error }}

    +

    {% trans "Sorry, something's gone wrong." %} {{ error }}

    {% endblock %} diff --git a/mapit/templates/mapit/api/area.html b/mapit/templates/mapit/api/area.html index 097923f9..33636c96 100644 --- a/mapit/templates/mapit/api/area.html +++ b/mapit/templates/mapit/api/area.html @@ -1,33 +1,41 @@ {% load url from compat %} +{% load mapit_i18n %}
    -

    lookup by area

    +

    {% blocktrans trimmed %} + lookup by area + {% endblocktrans %}

    -
    URL:
    +
    {% trans "URL" %}:
      {% if country == 'GB' %} -
    • /area/[area ID or ONS code] +
    • /area/[{% trans "area ID or ONS code" %}] {% else %} -
    • /area/[area ID] +
    • /area/[{% trans "area ID" %}] {% endif %} {% if country == 'Global' %} -
    • /code/osm_rel/[OSM relation ID] -
    • /code/osm_way/[OSM way ID] +
    • /code/osm_rel/[{% trans "OSM relation ID" %}] +
    • /code/osm_way/[{% trans "OSM way ID" %}] {% elif postcodes_available %} -
    • /area/[area ID]/example_postcode +
    • /area/[{% trans "area ID" %}]/example_postcode {% endif %} -
    • /area/[area ID]/geometry -
    • /area/[area ID].[kml or geojson or wkt] -
    • /area/[SRID]/[area ID].[kml or json or wkt] +
    • /area/[{% trans "area ID" %}]/geometry +
    • /area/[{% trans "area ID" %}].[{% trans "kml or geojson or wkt" %}] +
    • /area/[{% trans "SRID" %}]/[{% trans "area ID" %}].[{% trans "kml or json or wkt" %}]
    -
    Optional query parameters:
    -
    simplify_tolerance, a floating point parameter to simplify the polygons returned.
    -
    Returns:
    -
    Information on a particular area, including name, type, parent, and any associated codes +
    {% trans "Optional query parameters" %}:
    +
    simplify_tolerance, {% trans "a floating point parameter to simplify the polygons returned" %}.
    +
    {% trans "Returns" %}:
    +
    + {% blocktrans trimmed %} + Information on a particular area, including name, type, parent, and any associated codes (see below for details). The code lookups redirect to the area URI. + {% endblocktrans %} {% if postcodes_available %} - example_postcode returns a random postcode within the area specified. + {% trans "example_postcode returns a random postcode within the area specified." %} {% endif %} + {% blocktrans trimmed %} geometry returns centroid, extent and area of the area. + {% endblocktrans %}
    {% include "mapit/api/area-example.html" %}
    @@ -35,28 +43,34 @@

    lookup by area

    diff --git a/mapit/templates/mapit/api/areas.html b/mapit/templates/mapit/api/areas.html index 524bebd3..4e4a91ac 100644 --- a/mapit/templates/mapit/api/areas.html +++ b/mapit/templates/mapit/api/areas.html @@ -1,30 +1,38 @@ {% load url from compat %} +{% load mapit_i18n %}
    -

    lookup multiple areas

    +

    {% blocktrans trimmed %} + lookup multiple areas + {% endblocktrans %}

    URL:
      -
    • /areas/[area IDs] -
    • /areas/[area IDs]/geometry -
    • /areas/[type(s)] -
    • /areas/[name prefix] +
    • /areas/[{% trans "area IDs" %}] +
    • /areas/[{% trans "area IDs" %}]/geometry +
    • /areas/[{% trans "type(s)" %}] +
    • /areas/[{% trans "name prefix" %}]
    -
    Parameters:
    -
    Separate multiple parameters with commas. +
    {% trans "Parameters" %}:
    +
    {% blocktrans trimmed %} + Separate multiple parameters with commas. Name prefix means it will return any area that starts with the string given. + {% endblocktrans %} {% include "mapit/api/areas-types.html" %}
    -
    Optional query parameters:
    +
    {% trans "Optional query parameters" %}:
      -
    • generation, to return areas in that generation (type and name lookups only).
    • -
    • min_generation, to return areas since that generation (type and name lookups only).
    • -
    • type, to restrict results to a type or types (multiple separated by commas; name lookup only).
    • +
    • generation, {% trans "to return areas in that generation (type and name lookups only)" %}.
    • +
    • min_generation, {% trans "to return areas since that generation (type and name lookups only)" %}.
    • +
    • type, {% trans "to restrict results to a type or types (multiple separated by commas; name lookup only)" %}.
    -
    Returns:
    +
    {% trans "Returns" %}:
    -

    Information on multiple areas that match the parameters provided, as a dictionary indexed by area ID. - The geometry argument lets you fetch multiple single area geometry results at once. +

    + {% blocktrans trimmed %} + Information on multiple areas that match the parameters provided, as a dictionary indexed by area ID. + The geometry argument lets you fetch multiple single area geometry results at once. + {% endblocktrans %}

    {% include "mapit/api/areas-examples.html" %} diff --git a/mapit/templates/mapit/api/generations.html b/mapit/templates/mapit/api/generations.html index acb868ce..db0b0212 100644 --- a/mapit/templates/mapit/api/generations.html +++ b/mapit/templates/mapit/api/generations.html @@ -2,13 +2,13 @@ {% load url from compat %}
    -

    Generations

    +

    {% trans "Generations" %}

    URL:
    /generations
    -
    Returns:
    -
    A list of all generations in this installation of MapIt. +
    {% trans "Returns" %}:
    +
    {% trans "A list of all generations in this installation of MapIt." %}
    {% if country == 'GB' %} Note that only generations from 12 upwards actually exist, apart from some diff --git a/mapit/templates/mapit/api/intro.html b/mapit/templates/mapit/api/intro.html index da1cc7b1..bdbb2a1f 100644 --- a/mapit/templates/mapit/api/intro.html +++ b/mapit/templates/mapit/api/intro.html @@ -1,6 +1,9 @@ -
    -

    The documentation below is for developers who want - to use MapIt as a web service, describing its REST - API. If that’s all Greek to you, please see - our page for non-developers.

    -
    +{% load mapit_i18n %} +
    + {% blocktrans trimmed %} +

    The documentation below is for developers who want + to use MapIt as a web service, describing its REST + API. If that’s all Greek to you, please see + our page for non-developers.

    + {% endblocktrans %} +
    diff --git a/mapit/templates/mapit/api/point.html b/mapit/templates/mapit/api/point.html index fcf257a7..51d8b6ef 100644 --- a/mapit/templates/mapit/api/point.html +++ b/mapit/templates/mapit/api/point.html @@ -1,43 +1,74 @@ {% load url from compat %} +{% load mapit_i18n %}
    -

    lookup by point

    +

    {% blocktrans trimmed %} + lookup by point + {% endblocktrans %}

    URL:
    • /point/[SRID]/[x],[y]
    • /point/[SRID]/[x],[y]/box
    -
    Parameters:
    +
    {% trans "Parameters" %}:
    + {% blocktrans trimmed %}

    SRID is a unique number referring to a particular co-ordinate system; + {% endblocktrans %} {% if country == 'GB' %} + {% blocktrans trimmed %} the ones you probably are interested in are 27700 for British National Grid, 4326 for WGS84 lon/lat, and 29902 for the Irish National Grid. + {% endblocktrans %} +{% elif country == 'IT' %} + {% blocktrans trimmed %} + the ones you probably are interested in are + 32632 o UTM zone 32N, for Italy or 4326 for WGS84 lon/lat. + {% endblocktrans %} {% else %} + {% blocktrans trimmed %} the one you probably are interested in is 4326 for WGS84 normal lon/lat. + {% endblocktrans %} {% endif %}

    + {% blocktrans trimmed %}

    x and y are the co-ordinates of the point in the co-ordinate system; note that x,y means longitude,latitude.

    + {% endblocktrans %}
    + {% blocktrans trimmed %}
    Optional query parameters:
    + {% endblocktrans %}
    -
      -
    • type, to restrict results to a particular area type or types (multiple types separated by commas); -
    • generation, to return results for a previous generation. -
    • min_generation, to return results since that generation.
    • -
    +
      +
    • + {% blocktrans trimmed %} + type, to restrict results to a particular area type or types (multiple types separated by commas); + {% endblocktrans %} +
    • +
    • + {% blocktrans trimmed %} + generation, to return results for a previous generation. + {% endblocktrans %} +
    • +
    • + {% blocktrans trimmed %} + min_generation, to return results since that generation. + {% endblocktrans %} +
    • +
    -
    Returns:
    +
    {% trans "Returns" %}:
    -

    A hash of the areas that the point is contained within. If - the /box version is used, only the area bounding boxes are - considered. -

    + {% blocktrans trimmed %} +

    A hash of the areas that the point is contained within. If + the /box version is used, only the area bounding boxes are + considered.

    + {% endblocktrans %} {% include "mapit/api/point-example.html" %}
    @@ -45,14 +76,16 @@

    lookup by point

    {% if postcodes_available %}
    -

    lookupnearest postcode

    +

    {% blocktrans trimmed %} + lookupnearest postcode + {% endblocktrans %}

    URL:
    /nearest/[SRID]/[x],[y]
    -
    Parameters:
    -
    Same as for by point.
    -
    Returns:
    -
    The postcode closest to the particular point. +
    {% trans "Parameters" %}:
    +
    {% trans "Same as for" %} {% trans "by point" %}.
    +
    {% trans "Returns" %}:
    +
    {% trans "The postcode closest to the particular point." %} {% include "mapit/api/point-example-nearest.html" %}
    diff --git a/mapit/templates/mapit/api/postcode.html b/mapit/templates/mapit/api/postcode.html index b94e0e7f..5b077d46 100644 --- a/mapit/templates/mapit/api/postcode.html +++ b/mapit/templates/mapit/api/postcode.html @@ -1,40 +1,55 @@ {% load url from compat %} +{% load mapit_i18n %}
    -

    lookup by postcode

    +

    + {% blocktrans trimmed %} + lookup by postcode + {% endblocktrans %} +

    URL:
    -
    /postcode/[postcode]
    +
    /postcode/[{% trans "postcode" %}]
    -
    Returns:
    +
    {% trans "Returns" %}:
    -

    Information on a particular postcode, including its - location in - {% if country == 'GB' %}both National Grid and {% endif %} - WGS84 latitude/longitude, and the areas it is contained - within.

    + {% blocktrans trimmed %} +

    Information on a particular postcode, including its + location in + {% endblocktrans %} + {% if country == 'GB' %}{% trans "both National Grid and" %} {% endif %} + {% blocktrans trimmed %} + WGS84 latitude/longitude, and the areas it is contained + within.

    + {% endblocktrans %}
    -
    Optional query parameters:
    +
    {% trans "Optional query parameters" %}:
    -

    generation, to return results from a previous generation.

    + {% blocktrans trimmed %} +

    generation, to return results from a previous generation.

    + {% endblocktrans %}
    {% include "mapit/api/postcode-example.html" %}
    +{% if country != 'IT' %}
    -

    lookup by partial postcode

    +

    {% blocktrans trimmed %}lookup by partial postcode{% endblocktrans %}

    URL:
    -
    /postcode/partial/[partial postcode]
    +
    /postcode/partial/[{% trans "partial postcode" %}]
    -
    Returns:
    +
    {% trans "Returns" %}:
    -

    Geographical details for the centroid of the partial postcode specified.

    + {% blocktrans trimmed %} +

    Geographical details for the centroid of the partial postcode specified.

    + {% endblocktrans %}
    {% include "mapit/api/postcode-example-partial.html" %}
    +{% endif %} \ No newline at end of file diff --git a/mapit/templates/mapit/area.html b/mapit/templates/mapit/area.html index 2f402567..6faa6780 100644 --- a/mapit/templates/mapit/area.html +++ b/mapit/templates/mapit/area.html @@ -1,4 +1,5 @@ {% extends "mapit/base.html" %} +{% load i18n %} {% load url from compat %} {% block title %}{{ area.name }}{% endblock title %} @@ -8,24 +9,27 @@

    {{ area.name }} ID {{ area.id }}

    -

    Get this data as JSON

    + {% url "mapit_index" as index_url %} + {% with area.id|slugify as area_id %} +

    {% blocktrans with json_url=index_url|add:"area/"|add:area_id %}Get this data as JSON{% endblocktrans %}

    + {% endwith %}
    {% if area.polygons.count %} @@ -33,7 +37,7 @@

    {{ area.name }} ID {{ area.id }}

    + + +{% if norobots %} + +{% endif %} + +{% if GOOGLE_ANALYTICS %} + +{% endif %} + + + + + +
    + + + MapIt-it è un progetto no-profit di Openpolis + + + + Keep us online, Donate Now + + +
    + {% get_current_language as LANGUAGE_CODE %} + {% get_language_info_list for LANGUAGES as languages %} + {% with full_path=request.get_full_path lang_prefix='/'|add:LANGUAGE_CODE|add:'/' %} + {% for language in languages %}{% if language.code != LANGUAGE_CODE %} + {{ language.name_local }} + {% endif %}{% endfor %} + {% endwith %} + +
    + +
    + + + {% if request.path != INDEX_URL %} +
    + {% trans "Home & Documentation" %} +

    MapIt: {% include "mapit/country.html" %}

    +
    + +
    + {% endif %} + {% block content %} + {% endblock %} + {% if request.path != INDEX_URL %} +
    + {% endif %} + +
    +

    MapIt: {% include "mapit/country.html" %} +
    + Powered by + Django powered +

    + +
    + {% include "mapit/copyright.html" %} +
    + +
    + + + + diff --git a/mapit_it/templates/mapit/changelog.html b/mapit_it/templates/mapit/changelog.html new file mode 100644 index 00000000..d49d61a3 --- /dev/null +++ b/mapit_it/templates/mapit/changelog.html @@ -0,0 +1,16 @@ +{% extends "mapit/base.html" %} + +{% block title %}Changelog{% endblock title %} + +{% block content %} + +

    Changelog

    +

    Changes to MapIt Italy's data

    + +

    2014-12-05 - October 2014 Boundary-Line import

    + +Generation 1, containing the first import of the December 2014. + + + +{% endblock %} diff --git a/mapit_it/templates/mapit/copyright.html b/mapit_it/templates/mapit/copyright.html new file mode 100644 index 00000000..bb9ae69b --- /dev/null +++ b/mapit_it/templates/mapit/copyright.html @@ -0,0 +1,31 @@ +{% load mapit_i18n %} +

    + {% blocktrans trimmed %} + Boundaries administrative data are released by ISTAT + and downloadable in SHP format from + this link. + {% endblocktrans %} +

    + +

    + {% blocktrans trimmed %} + The MapIt platform has been developed by + MySociety, a UK registered charity + with which Openpolis cohoperate on transparency projects since years. + {% endblocktrans %} +

    + +

    + {% blocktrans trimmed %} + The application is released within the + Poplus project. + {% endblocktrans %} +

    + +

    + {% blocktrans trimmed %} + The maps are powered by Openstreetmap, + a the nominatim + geo-localization service used to identify the centroid coordinates for postal codes. + {% endblocktrans %} +

    diff --git a/mapit_it/templates/mapit/country.html b/mapit_it/templates/mapit/country.html new file mode 100644 index 00000000..20143923 --- /dev/null +++ b/mapit_it/templates/mapit/country.html @@ -0,0 +1,2 @@ +{% load i18n %} +{% trans "Italy" %} diff --git a/mapit_it/templates/mapit/index-cross-sell.html b/mapit_it/templates/mapit/index-cross-sell.html new file mode 100644 index 00000000..e69de29b diff --git a/mapit_it/templates/mapit/index-others.html b/mapit_it/templates/mapit/index-others.html new file mode 100644 index 00000000..3b7ca589 --- /dev/null +++ b/mapit_it/templates/mapit/index-others.html @@ -0,0 +1,5 @@ +{% load mapit_i18n %} +{% blocktrans trimmed %} +This version of MapIt, covering italian administrative areas, +has appeared in 2015, and is an effort of Openpolis. +{% endblocktrans %} diff --git a/mapit_it/templates/mapit/intro.html b/mapit_it/templates/mapit/intro.html new file mode 100644 index 00000000..08712e5d --- /dev/null +++ b/mapit_it/templates/mapit/intro.html @@ -0,0 +1,8 @@ +{% load mapit_i18n %} +{% blocktrans trimmed %} +

    MapIt is a service that maps postcodes and geographical points to +administrative areas. It’s useful for anyone who has a postcode or +co-ordinates of a point in Italy, and needs to find out what municpality, +province, region, or electoral constituency it lies within. +It’s also great for looking up the shapes of all those boundaries.

    +{% endblocktrans %} diff --git a/mapit_it/urls.py b/mapit_it/urls.py new file mode 100644 index 00000000..12c11a55 --- /dev/null +++ b/mapit_it/urls.py @@ -0,0 +1,7 @@ +from django.conf.urls import url + +from django.shortcuts import render + +urlpatterns = [ + url(r'^changelog$', render, {'template_name': 'mapit/changelog.html'}, 'mapit_changelog'), +] diff --git a/mapit_no/templates/mapit/api/area-example-related.html b/mapit_no/templates/mapit/api/area-example-related.html index beeeeec1..848171cb 100644 --- a/mapit_no/templates/mapit/api/area-example-related.html +++ b/mapit_no/templates/mapit/api/area-example-related.html @@ -1,8 +1,9 @@ -{% load url from future %} -
    Examples:
    +{% load url from compat %} +{% load i18n %} +
    {% trans "Examples:" %}
    diff --git a/mapit_no/templates/mapit/api/area-example.html b/mapit_no/templates/mapit/api/area-example.html index 2db3cc54..36df72f9 100644 --- a/mapit_no/templates/mapit/api/area-example.html +++ b/mapit_no/templates/mapit/api/area-example.html @@ -1,11 +1,12 @@ -{% load url from future %} -
    Examples:
    +{% load url from compat %} +{% load i18n %} +
    {% trans "Examples:" %}
    diff --git a/mapit_no/templates/mapit/api/areas-examples.html b/mapit_no/templates/mapit/api/areas-examples.html index d12e0ff1..b57eb40a 100644 --- a/mapit_no/templates/mapit/api/areas-examples.html +++ b/mapit_no/templates/mapit/api/areas-examples.html @@ -1,4 +1,4 @@ -{% load url from future %} +{% load url from compat %}
    Examples:
      diff --git a/mapit_no/templates/mapit/api/point-example-nearest.html b/mapit_no/templates/mapit/api/point-example-nearest.html index 5c3f209b..f5ff79f9 100644 --- a/mapit_no/templates/mapit/api/point-example-nearest.html +++ b/mapit_no/templates/mapit/api/point-example-nearest.html @@ -1,3 +1,4 @@ -{% load url from future %} -
      Example
      -
      Example of postcode nearest to (59,10).
      +{% load url from compat %} +{% load i18n %} +
      {% trans "Example:" %}
      +
      {% trans "Example of postcode nearest to (59,10)" %}.
      diff --git a/mapit_no/templates/mapit/api/point-example.html b/mapit_no/templates/mapit/api/point-example.html index 2c9c192f..15a4eb15 100644 --- a/mapit_no/templates/mapit/api/point-example.html +++ b/mapit_no/templates/mapit/api/point-example.html @@ -1,3 +1,4 @@ -{% load url from future %} -
      Example:
      -
      Example of areas containing (59,10).
      +{% load url from compat %} +{% load i18n %} +
      {% trans "Example:" %}
      +
      {% trans "Example of areas containing (59,10)" %}.
      diff --git a/mapit_no/templates/mapit/api/postcode-example-partial.html b/mapit_no/templates/mapit/api/postcode-example-partial.html index 45bfc89d..97419035 100644 --- a/mapit_no/templates/mapit/api/postcode-example-partial.html +++ b/mapit_no/templates/mapit/api/postcode-example-partial.html @@ -1,5 +1,7 @@ -{% load url from future %} -
      Example:
      +{% load url from compat %} +{% load i18n %} + +
      {% trans "Example:" %}
      • JSON: /postcode/partial/85 diff --git a/mapit_no/templates/mapit/api/postcode-example.html b/mapit_no/templates/mapit/api/postcode-example.html index 658c545a..2ddb580a 100644 --- a/mapit_no/templates/mapit/api/postcode-example.html +++ b/mapit_no/templates/mapit/api/postcode-example.html @@ -1,11 +1,17 @@ -{% load url from future %} -
        Example:
        +{% load url from compat %} +{% load mapit_i18n %} + +
        {% trans "Example:" %}
        + {% blocktrans trimmed %}

        If your postcode was 0373 you would load /postcode/0373 + {% endblocktrans %}

        + {% blocktrans trimmed %} By default the response is in JSON, if you want a human readable page then append ‘.html’ to the url + {% endblocktrans %} /postcode/0373.html

        diff --git a/mapit_no/templates/mapit/index-others.html b/mapit_no/templates/mapit/index-others.html index 6bfd4b0a..ff7a80a7 100644 --- a/mapit_no/templates/mapit/index-others.html +++ b/mapit_no/templates/mapit/index-others.html @@ -1,3 +1,6 @@ +{% load mapit_i18n %} +{% blocktrans trimmed %} Versions have appeared in other countries, such as this one in Norway, and in 2012 we released a global version based on OpenStreetMap data. +{% endblocktrans %} diff --git a/mapit_za/templates/mapit/api/point-example.html b/mapit_za/templates/mapit/api/point-example.html index cadad008..e707db3b 100644 --- a/mapit_za/templates/mapit/api/point-example.html +++ b/mapit_za/templates/mapit/api/point-example.html @@ -1,3 +1,3 @@ -{% load url from future %} +{% load url from compat %}
        Example:
        Example of areas containing (18.42,-33.92).
        diff --git a/project/settings.py b/project/settings.py index 74d5372a..3d153fcb 100644 --- a/project/settings.py +++ b/project/settings.py @@ -118,13 +118,18 @@ LANGUAGE_CODE = 'en' POSTCODES_AVAILABLE = True +LANGUAGES = ( + ('en', 'English'), + ('it', 'Italiano') +) + # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N = True # If you set this to False, Django will not format dates, numbers and # calendars according to the current locale. -USE_L10N = True +USE_L10N = False # If you set this to False, Django will not use timezone-aware datetimes. USE_TZ = False @@ -178,6 +183,8 @@ USE_ETAGS = False MIDDLEWARE_CLASSES = [ + # 'django.middleware.locale.LocaleMiddleware', + 'solid_i18n.middleware.SolidLocaleMiddleware', 'mapit.middleware.gzip.GZipMiddleware', # Not 'django.middleware.gzip.GZipMiddleware' to work around Django #24242 'django.middleware.http.ConditionalGetMiddleware', @@ -205,11 +212,13 @@ ) TEMPLATE_CONTEXT_PROCESSORS = ( + 'django.core.context_processors.i18n', 'django.core.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', 'mapit.context_processors.country', 'mapit.context_processors.analytics', + 'mapit.context_processors.index_url', ) if django.get_version() >= '1.8': diff --git a/project/urls.py b/project/urls.py index 208374af..9dbb0882 100644 --- a/project/urls.py +++ b/project/urls.py @@ -1,10 +1,15 @@ from django.conf.urls import include, url +from solid_i18n.urls import solid_i18n_patterns from django.contrib import admin admin.autodiscover() handler500 = 'mapit.shortcuts.json_500' urlpatterns = [ - url(r'^', include('mapit.urls')), url(r'^admin/', include(admin.site.urls)), + url(r'^i18n/', include('django.conf.urls.i18n')), ] + +urlpatterns += solid_i18n_patterns('', + url(r'^', include('mapit.urls')), +) diff --git a/setup.py b/setup.py index 9ee558d1..bacb04f4 100644 --- a/setup.py +++ b/setup.py @@ -29,6 +29,7 @@ def read_file(filename): 'psycopg2', 'PyYAML', 'Shapely', + 'solid-i18n' ], classifiers=[ 'Development Status :: 5 - Production/Stable',