From: Tom Hughes Date: Sun, 7 Jun 2009 08:32:39 +0000 (+0000) Subject: Rework the javascript I18n interpolation a bit - the interpolation function X-Git-Tag: live~7141 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/fc398f64416a9169d57d840855364f8eb9123e57 Rework the javascript I18n interpolation a bit - the interpolation function is now in site.js so everything can use it, and the syntax has changed a bit to avoid the need for double interpolation. --- diff --git a/app/views/browse/start.rjs b/app/views/browse/start.rjs index 64e4431a4..3043e8330 100644 --- a/app/views/browse/start.rjs +++ b/app/views/browse/start.rjs @@ -131,7 +131,7 @@ page << < '{{num_features}}')}", { num_features: browseFeatureList.length }))); + p.appendChild(document.createTextNode(i18n("#{I18n.t('browse.start_rjs.loaded_an_area_with_num_features')}", { num_features: browseFeatureList.length }))); div.appendChild(p); var input = document.createElement("input"); @@ -187,7 +187,7 @@ page << < #{APP_CONFIG['max_request_area']}) { - setStatus(i18n_js("#{I18n.t('browse.start_rjs.unable_to_load_size', :bbox_size => '{{bbox_size}}', :max_bbox_size => APP_CONFIG['max_request_area'])}", { bbox_size: size })); + setStatus(i18n("#{I18n.t('browse.start_rjs.unable_to_load_size', :max_bbox_size => APP_CONFIG['max_request_area'])}", { bbox_size: size })); } else { loadGML("/api/#{API_VERSION}/map?bbox=" + projected.toBBOX()); } @@ -421,7 +421,7 @@ page << < '{{feature}}')}", { feature: featureNameHistory(this.feature) }))); + heading.appendChild(document.createTextNode(i18n("#{I18n.t('browse.start_rjs.history_for_feature')}", { feature: featureNameHistory(this.feature) }))); tr.appendChild(heading); var td = document.createElement("td"); @@ -442,7 +442,7 @@ page << < '{{user}}', :timestamp => '{{timestamp}}')}", { user: user, timestamp: timestamp }))); + item.appendChild(document.createTextNode(i18n("#{I18n.t('browse.start_rjs.edited_by_user_at_timestamp')}", { user: user, timestamp: timestamp }))); history.appendChild(item); } div.appendChild(history); @@ -470,9 +470,9 @@ page << < '{{id}}')}", { id: feature.osm_id }); + return i18n("#{I18n.t('browse.start_rjs.object_list.selected.type.node')}", { id: feature.osm_id }); } else if (featureType(feature) == "way") { - return i18n_js("#{I18n.t('browse.start_rjs.object_list.selected.type.way', :id => '{{id}}')}", { id: feature.osm_id }); + return i18n("#{I18n.t('browse.start_rjs.object_list.selected.type.way')}", { id: feature.osm_id }); } } @@ -480,28 +480,12 @@ page << < '{{id}}')}", { id: feature.osm_id }); + return i18n("#{I18n.t('browse.start_rjs.object_list.history.type.node')}", { id: feature.osm_id }); } else if (featureType(feature) == "way") { - return i18n_js("#{I18n.t('browse.start_rjs.object_list.history.type.way', :id => '{{id}}')}", { id: feature.osm_id }); + return i18n("#{I18n.t('browse.start_rjs.object_list.history.type.way')}", { id: feature.osm_id }); } } - /* - This is a hack so that we can interpolate JavaScript variables in - translation strings from Ruby, doing the string replacement - client-side instead of on the server. - */ - function i18n_js(string, keys) { - for (var key in keys) { - var re_key = '\{\{' + key + '\}\}'; - var re = new RegExp(re_key, "g"); - - string = string.replace(re, keys[key]); - } - - return string; - } - function setStatus(status) { $("browse_status").innerHTML = status; $("browse_status").style.display = "block"; diff --git a/config/locales/de.yml b/config/locales/de.yml index 53b437771..a54078de2 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -149,16 +149,16 @@ de: zoom_or_select: "Karte vergrössern oder einen Bereich auf der Karte auswählen" drag_a_box: "Einen Rahmen über die Karte aufziehen, um einen Bereich auszuwählen" manually_select: "Einen anderen Kartenausschnitt manuell auswählen" - loaded_an_area_with_num_features: "Du hast einen Bereich geladen, der {{num_features}} Elemente enthält. Manche Browser haben Probleme bei der Darstellung einer so großen Datenmenge. Normalerweise ist es am besten, nur weniger als 100 Elemente zu betrachten; alles andere macht deinen Browser langsam bzw. lässt ihn nicht mehr auf Eingaben reagieren. Wenn du sicher bist, dass du diese Daten darstellen willst, klicke auf \'Daten laden\' unten." + loaded_an_area_with_num_features: "Du hast einen Bereich geladen, der [[num_features]] Elemente enthält. Manche Browser haben Probleme bei der Darstellung einer so großen Datenmenge. Normalerweise ist es am besten, nur weniger als 100 Elemente zu betrachten; alles andere macht deinen Browser langsam bzw. lässt ihn nicht mehr auf Eingaben reagieren. Wenn du sicher bist, dass du diese Daten darstellen willst, klicke auf \'Daten laden\' unten." load_data: "Daten laden" - unable_to_load_size: "Konnte nicht geladen werden: Bereich der Größe {{bbox_size}} ist zu groß (soll kleiner als {{max_bbox_size}} sein)" + unable_to_load_size: "Konnte nicht geladen werden: Bereich der Größe [[bbox_size]] ist zu groß (soll kleiner als {{max_bbox_size}} sein)" loading: "Laden..." show_history: "Chronik" wait: "Verarbeiten..." - history_for_feature: "Chronik für {{feature}}" + history_for_feature: "Chronik für [[feature]]" details: "Details" private_user: "Anonymer Benutzer" - edited_by_user_at_timestamp: "Bearbeitet von {{user}} am {{timestamp}}" + edited_by_user_at_timestamp: "Bearbeitet von [[user]] am [[timestamp]]" object_list: heading: "Object list" back: "Display object list" @@ -170,13 +170,13 @@ de: details: "Details" selected: type: - node: "Knoten {{id}}" - way: "Weg {{id}}" + node: "Knoten [[id]]" + way: "Weg [[id]]" # There's no 'relation' type because it isn't represented in OpenLayers history: type: - node: "Knoten {{id}}" - way: "Weg {{id}}" + node: "Knoten [[id]]" + way: "Weg [[id]]" # There's no 'relation' type because it isn't represented in OpenLayers tag_details: tags: "Tags:" diff --git a/config/locales/en.yml b/config/locales/en.yml index dbcaa65e5..ce3d51a5a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -149,16 +149,16 @@ en: zoom_or_select: "Zoom in or select an area of the map to view" drag_a_box: "Drag a box on the map to select an area" manually_select: "Manually select a different area" - loaded_an_area_with_num_features: "You have loaded an area which contains {{num_features}} features. In general, some browsers may not cope well with displaying this quantity of data. Generally, browsers work best at displaying less than 100 features at a time: doing anything else may make your browser slow/unresponsive. If you are sure you want to display this data, you may do so by clicking the button below." + loaded_an_area_with_num_features: "You have loaded an area which contains [[num_features]] features. In general, some browsers may not cope well with displaying this quantity of data. Generally, browsers work best at displaying less than 100 features at a time: doing anything else may make your browser slow/unresponsive. If you are sure you want to display this data, you may do so by clicking the button below." load_data: "Load Data" - unable_to_load_size: "Unable to load: Bounding box size of {{bbox_size}} is too large (must be smaller than {{max_bbox_size}})" + unable_to_load_size: "Unable to load: Bounding box size of [[bbox_size]] is too large (must be smaller than {{max_bbox_size}})" loading: "Loading..." show_history: "Show History" wait: "Wait..." - history_for_feature: "History for {{feature}}" + history_for_feature: "History for [[feature]]" details: "Details" private_user: "private user" - edited_by_user_at_timestamp: "Edited by {{user}} at {{timestamp}}" + edited_by_user_at_timestamp: "Edited by [[user]] at [[timestamp]]" object_list: heading: "Object list" back: "Display object list" @@ -170,13 +170,13 @@ en: details: "Details" selected: type: - node: "Node {{id}}" - way: "Way {{id}}" + node: "Node [[id]]" + way: "Way [[id]]" # There's no 'relation' type because it isn't represented in OpenLayers history: type: - node: "Node {{id}}" - way: "Way {{id}}" + node: "Node [[id]]" + way: "Way [[id]]" # There's no 'relation' type because it isn't represented in OpenLayers tag_details: tags: "Tags:" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index e844d028c..426eb40b7 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -64,16 +64,16 @@ fr: zoom_or_select: "Zoomer ou sélectionner une zone de la carte pour la visualiser" drag_a_box: "Dessiner une boite sur la carte pour sélectionner une zone" manually_select: "Sélectionner manuellement une zone différente" - loaded_an_area_with_num_features: "Vous avez chargé une zone qui contient {{num_features}} un grand nombre d'éléments. En général, les navigateurs ne supportent pas bien l'affichage de tant de données, et travaillent mieux lorsqu'ils affichent moins de 100 éléments : accepter peut rendre votre navigateur lent ou non fonctionnel. Si vous etes sûr de vouloir afficher ces données, vous pouvez le faire en appuyant sur le bouton ci-dessous." + loaded_an_area_with_num_features: "Vous avez chargé une zone qui contient [[num_features]] un grand nombre d'éléments. En général, les navigateurs ne supportent pas bien l'affichage de tant de données, et travaillent mieux lorsqu'ils affichent moins de 100 éléments : accepter peut rendre votre navigateur lent ou non fonctionnel. Si vous etes sûr de vouloir afficher ces données, vous pouvez le faire en appuyant sur le bouton ci-dessous." load_data: "Charger les données" - unable_to_load_size: "Impossible de charger les données : la Bounding box d'une taille de {{bbox_size}} est trop grande (elle doit être plus petite que {{max_bbox_size}})" + unable_to_load_size: "Impossible de charger les données : la Bounding box d'une taille de [[bbox_size]] est trop grande (elle doit être plus petite que {{max_bbox_size}})" loading: "Chargement..." show_history: "Montrer l'historique" wait: "Patienter..." - history_for_feature: "Historique pour {{feature}}" + history_for_feature: "Historique pour [[feature]]" details: "Détails" private_user: "utilisateur privé" - edited_by_user_at_timestamp: "Édité par {{user}} le {{timestamp}}" + edited_by_user_at_timestamp: "Édité par [[user]] le [[timestamp]]" diary_entry: new: title: "Nouvelle entrée du journal" diff --git a/config/locales/he.yml b/config/locales/he.yml index 886ed19ee..15fee96e3 100644 --- a/config/locales/he.yml +++ b/config/locales/he.yml @@ -145,16 +145,16 @@ he: zoom_or_select: "Zoom in or select an area of the map to view" drag_a_box: "Drag a box on the map to select an area" manually_select: "Manually select a different area" - loaded_an_area_with_num_features: "You have loaded an area which contains {{num_features}} features. In general, some browsers may not cope well with displaying this quanity of data. Generally, browsers work best at displaying less than 100 features at a time: doing anything else may make your browser slow/unresponsive. If you are sure you want to display this data, you may do so by clicking the button below." + loaded_an_area_with_num_features: "You have loaded an area which contains [[num_features]] features. In general, some browsers may not cope well with displaying this quanity of data. Generally, browsers work best at displaying less than 100 features at a time: doing anything else may make your browser slow/unresponsive. If you are sure you want to display this data, you may do so by clicking the button below." load_data: "Load Data" - unable_to_load_size: "Unable to load: Bounding box size of {{bbox_size}} is too large (must be smaller than {{max_bbox_size}})" + unable_to_load_size: "Unable to load: Bounding box size of [[bbox_size]] is too large (must be smaller than {{max_bbox_size}})" loading: "Loading..." show_history: "Show History" wait: "Wait..." - history_for_feature: "History for {{feature}}" + history_for_feature: "History for [[feature]]" details: "Details" private_user: "private user" - edited_by_user_at_timestamp: "Edited by {{user}} at {{timestamp}}" + edited_by_user_at_timestamp: "Edited by [[user]] at [[timestamp]]" tag_details: tags: "Tags:" way_details: diff --git a/config/locales/is.yml b/config/locales/is.yml index 8ccd80f16..0cf8cb432 100644 --- a/config/locales/is.yml +++ b/config/locales/is.yml @@ -149,16 +149,16 @@ is: zoom_or_select: "Þú verður að þysja að eða velja svæði á kortinu" drag_a_box: "Teiknaðu kassa á kortið til að velja svæði" manually_select: "Velja annað svæði á kortinu" - loaded_an_area_with_num_features: "Þú hefur valið svæði sem á eru {{num_features}} hlutir. Sumir vafrar höndla illa fleiri en 100 hluti í einu, en þú getur hlaðið þeim inn þrátt fyrir það ef þú telur þig geta höndlað það." + loaded_an_area_with_num_features: "Þú hefur valið svæði sem á eru [[num_features]] hlutir. Sumir vafrar höndla illa fleiri en 100 hluti í einu, en þú getur hlaðið þeim inn þrátt fyrir það ef þú telur þig geta höndlað það." load_data: "Hlaða inn gögnum" - unable_to_load_size: "Gat ekki hlaðið gögnum: Svæði af stærðinni {{bbox_size}} er of stórt, svæðið verður að vera minna en {{max_bbox_size}}" + unable_to_load_size: "Gat ekki hlaðið gögnum: Svæði af stærðinni [[bbox_size]] er of stórt, svæðið verður að vera minna en {{max_bbox_size}}" loading: "Hleð inn gögnum..." show_history: "Sýna breytingarsögu" wait: "Augnablik..." - history_for_feature: "Breytingarskrá fyrir {{feature}}" + history_for_feature: "Breytingarskrá fyrir [[feature]]" details: "Nánar" private_user: "ónafngreindum" - edited_by_user_at_timestamp: "Breytt af {{user}} klukkan {{timestamp}}" + edited_by_user_at_timestamp: "Breytt af [[user]] klukkan [[timestamp]]" object_list: heading: "Hlutir" back: "Aftur á listann yfir hluti á þessu svæði" @@ -169,13 +169,13 @@ is: details: "Nánar" selected: type: - node: "Hnútur {{id}}" - way: "Vegur {{id}}" + node: "Hnútur [[id]]" + way: "Vegur [[id]]" # There's no 'relation' type because it isn't represented in OpenLayers history: type: - node: "hnút {{id}}" - way: "veg {{id}}" + node: "hnút [[id]]" + way: "veg [[id]]" # There's no 'relation' type because it isn't represented in OpenLayers tag_details: tags: "Eigindi:" diff --git a/config/locales/it.yml b/config/locales/it.yml index 2335a99fb..1673b9e00 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -145,16 +145,16 @@ it: zoom_or_select: "Ingrandire oppure selezionare l'area della mappa che si desidera visualizzare" drag_a_box: "Tracciare un riquadro sulla mappa per selezionare un'area" manually_select: "Seleziona manualmente un'area differente" - loaded_an_area_with_num_features: "E' stata caricata un'area che contiene {{num_features}} caratteristiche. In generale, alcuni browser potrebbero non visualizzare correttamente questa quantità di dati. Generalmente i browser lavorano al meglio se si visualizzano meno di 100 caratteristiche alla volta: se si fa qualcos'altro il proprio browser potrebbe diventare lento o non rispondere più. Se si è sicuri di voler visualizzare questi dati, allora si può premere il pulsante sottostante." + loaded_an_area_with_num_features: "E' stata caricata un'area che contiene [[num_features]] caratteristiche. In generale, alcuni browser potrebbero non visualizzare correttamente questa quantità di dati. Generalmente i browser lavorano al meglio se si visualizzano meno di 100 caratteristiche alla volta: se si fa qualcos'altro il proprio browser potrebbe diventare lento o non rispondere più. Se si è sicuri di voler visualizzare questi dati, allora si può premere il pulsante sottostante." load_data: "Carica dati" - unable_to_load_size: "Impossibile caricare: la dimensione del riquadro di selezione di {{bbox_size}} è troppo grande (deve essere minore di {{max_bbox_size}})" + unable_to_load_size: "Impossibile caricare: la dimensione del riquadro di selezione di [[bbox_size]] è troppo grande (deve essere minore di {{max_bbox_size}})" loading: "Caricamento in corso..." show_history: "Visualizza storico" wait: "Attendere..." - history_for_feature: "Storico per {{feature}}" + history_for_feature: "Storico per [[feature]]" details: "Dettagli" private_user: "utente privato" - edited_by_user_at_timestamp: "Modificato da {{user}} il {{timestamp}}" + edited_by_user_at_timestamp: "Modificato da [[user]] il [[timestamp]]" tag_details: tags: "Etichette:" way_details: diff --git a/config/locales/nl.yml b/config/locales/nl.yml index b9e9299c2..d0eae6279 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -145,16 +145,16 @@ nl: zoom_or_select: "Zoom in of selecteer een gebied van de kaart om te zien" drag_a_box: "Sleep een rechthoek op de kaart om een gebied te selecteren" manually_select: "Selecteer handmatig een ander gebied" - loaded_an_area_with_num_features: "Je hebt een gebied geladen dat {{num_features}} objecten bevat. In het algemeen kunnen sommige browsers niet goed overweg met zoveel gegevens. Normaal gesproken werken browsers het best met minder dan 100 objecten: als je meer weergeeft kan de browser traag worden of niet meer reageren. Als je zeker weet dat je de gegevens wilt laten zien, kan dat met de knop hieronder." + loaded_an_area_with_num_features: "Je hebt een gebied geladen dat [[num_features]] objecten bevat. In het algemeen kunnen sommige browsers niet goed overweg met zoveel gegevens. Normaal gesproken werken browsers het best met minder dan 100 objecten: als je meer weergeeft kan de browser traag worden of niet meer reageren. Als je zeker weet dat je de gegevens wilt laten zien, kan dat met de knop hieronder." load_data: "Gegevens laden" - unable_to_load_size: "Niet mogelijk om te laden: grootte van de rechthoek ({{bbox_size}}) is te groot (moet kleiner zijn dan {{max_bbox_size}})" + unable_to_load_size: "Niet mogelijk om te laden: grootte van de rechthoek ([[bbox_size]]) is te groot (moet kleiner zijn dan {{max_bbox_size}})" loading: "Laden..." show_history: "Geschiedenis weergeven" wait: "Een ogenblik geduld a.u.b..." - history_for_feature: "Geschiedenis voor {{feature}}" + history_for_feature: "Geschiedenis voor [[feature]]" details: "Details" private_user: "private user" #to be translated - edited_by_user_at_timestamp: "Bewerkt door {{user}} op {{timestamp}}" + edited_by_user_at_timestamp: "Bewerkt door [[user]] op [[timestamp]]" tag_details: tags: "Tags:" way_details: diff --git a/config/locales/pl.yml b/config/locales/pl.yml index 3903c6f0c..6d4de8e26 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -145,16 +145,16 @@ pl: zoom_or_select: "Przybliż albo wybierz inny obszar mapy" drag_a_box: "Zaznacz prostokąt na mapie przeciągnięciem myszki aby wybrać obszar" manually_select: "Manualnie wybierz inny obszar" - loaded_an_area_with_num_features: "Załadowano obszar zawierający {{num_features}} obiektów. Przeglądarki mogą nie radzić sobie z wyświetleniem tej ilości danych -- generalnie działają optymalnie przy wyświetlaniu mniej niż 100 obiektów jednocześnie, w przeciwnym wypadku przeglądarka może działac powoli lub przestać odpowiadać. Jeśli jesteś pewien że chcesz wyświetlić dane, kliknij przycisk poniżej." + loaded_an_area_with_num_features: "Załadowano obszar zawierający [[num_features]] obiektów. Przeglądarki mogą nie radzić sobie z wyświetleniem tej ilości danych -- generalnie działają optymalnie przy wyświetlaniu mniej niż 100 obiektów jednocześnie, w przeciwnym wypadku przeglądarka może działac powoli lub przestać odpowiadać. Jeśli jesteś pewien że chcesz wyświetlić dane, kliknij przycisk poniżej." load_data: "Załaduj dane" - unable_to_load_size: "Nie można załadować: prostokąt ograniczający {{bbox_size}} jest zbyt duży (nie może przekraczać {{max_bbox_size}} stopnia)" + unable_to_load_size: "Nie można załadować: prostokąt ograniczający [[bbox_size]] jest zbyt duży (nie może przekraczać {{max_bbox_size}} stopnia)" loading: "Wczytywanie..." show_history: "Pokaż zmiany" wait: "Moment..." - history_for_feature: "Historia zmian dla {{feature}}" + history_for_feature: "Historia zmian dla [[feature]]" details: "Szczegóły" private_user: "prywatny użytkownika" - edited_by_user_at_timestamp: "Edytowany przez {{user}} ostatni raz {{timestamp}}" + edited_by_user_at_timestamp: "Edytowany przez [[user]] ostatni raz [[timestamp]]" tag_details: tags: "Tagi:" way_details: diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 8e643997a..65f35140c 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -145,16 +145,16 @@ ru: zoom_or_select: "Увеличьте или выберите область для просмотра" drag_a_box: "Для выбора области растяните рамку по карте" manually_select: "Выделить другую область" - loaded_an_area_with_num_features: "Вы загрузили область, которая содержит {{num_features}} объектов. Некоторые браузеры могут не справиться с отображением такого количества данных. Обычно браузеры лучшего всего обрабатывают до 100 объектов одновременно. Загрузка большего числа может замедлить ваш браузер или привести к зависанию. Если вы все равно хотите отобразить эти данные, нажмите на кнопку ниже." + loaded_an_area_with_num_features: "Вы загрузили область, которая содержит [[num_features]] объектов. Некоторые браузеры могут не справиться с отображением такого количества данных. Обычно браузеры лучшего всего обрабатывают до 100 объектов одновременно. Загрузка большего числа может замедлить ваш браузер или привести к зависанию. Если вы все равно хотите отобразить эти данные, нажмите на кнопку ниже." load_data: "Загрузить данные" - unable_to_load_size: "Загрузка невозможна: размер квадрата {{bbox_size}} — слишком большой (должен быть меньше {{max_bbox_size}})" + unable_to_load_size: "Загрузка невозможна: размер квадрата [[bbox_size]] — слишком большой (должен быть меньше {{max_bbox_size}})" loading: "Загрузка..." show_history: "Показать историю" wait: "Подождите..." - history_for_feature: "История {{feature}}" + history_for_feature: "История [[feature]]" details: "Детали" private_user: "частный пользователь" - edited_by_user_at_timestamp: "Изменен {{user}} в {{timestamp}}" + edited_by_user_at_timestamp: "Изменен [[user]] в [[timestamp]]" tag_details: tags: "Теги:" way_details: diff --git a/config/locales/sl.yml b/config/locales/sl.yml index 3962cae21..f1f08b9c3 100644 --- a/config/locales/sl.yml +++ b/config/locales/sl.yml @@ -145,16 +145,16 @@ sl: zoom_or_select: "Povečajte zemljevid ali izberite področje za prikaz" drag_a_box: "Za izbor področja povlecite pravokotnik na zemljevidu" manually_select: "Ročno izberite drugo področje" - loaded_an_area_with_num_features: "Naložili ste področje, ki vsebuje {{num_features}} elementov. Nekateri spletni brskalniki ne zmorejo prikaza takšne količine podatkov. Na splošno brskalniki najbolje prikazujejo 100 ali manj elementov hkrati: karkoli drugega lahko upočasni vaš brskalnik ali ga naredi neodzivnega. Če ste prepričani, da želite prikazati vse te podatke, pritisnite na spodnji gumb." + loaded_an_area_with_num_features: "Naložili ste področje, ki vsebuje [[num_features]] elementov. Nekateri spletni brskalniki ne zmorejo prikaza takšne količine podatkov. Na splošno brskalniki najbolje prikazujejo 100 ali manj elementov hkrati: karkoli drugega lahko upočasni vaš brskalnik ali ga naredi neodzivnega. Če ste prepričani, da želite prikazati vse te podatke, pritisnite na spodnji gumb." load_data: "Naloži podatke" - unable_to_load_size: "Ni mogoče naložiti: Pravokotno področje velikosti {{bbox_size}} je preveliko (mora biti manjše od {{max_bbox_size}})" + unable_to_load_size: "Ni mogoče naložiti: Pravokotno področje velikosti [[bbox_size]] je preveliko (mora biti manjše od {{max_bbox_size}})" loading: "Nalaganje..." show_history: "Prikaži zgodovino" wait: "Počakajte..." - history_for_feature: "Zgodovina {{feature}}" + history_for_feature: "Zgodovina [[feature]]" details: "Podrobnosti" private_user: "anonimni uporabnik" - edited_by_user_at_timestamp: "Uredil {{user}} ob {{timestamp}}" + edited_by_user_at_timestamp: "Uredil [[user]] ob [[timestamp]]" tag_details: tags: "Oznake:" way_details: diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml index 1541e8d5e..9962ef270 100644 --- a/config/locales/zh-CN.yml +++ b/config/locales/zh-CN.yml @@ -1,4 +1,4 @@ -"zh-CN": +zh-CN: activerecord: # Translates all the model names, which is used in error handling on the web site models: @@ -145,16 +145,16 @@ zoom_or_select: "放大或选择查看一个地图区域" drag_a_box: "通过拖曳窗口来选择区域" manually_select: "手动选择一个不同区域" - loaded_an_area_with_num_features: "你已经选择了一个区域包括了{{num_features}} features. 通常,一些浏览器不能很好显示高精度的数据。一般来讲,当像素点在100一下浏览器的显示效果最好。如果再做别的任务,可能会导致您的浏览器变慢/不响应如果您确定您想要显示这些数据,您可能要点击下面的按钮。" + loaded_an_area_with_num_features: "你已经选择了一个区域包括了[[num_features]] features. 通常,一些浏览器不能很好显示高精度的数据。一般来讲,当像素点在100一下浏览器的显示效果最好。如果再做别的任务,可能会导致您的浏览器变慢/不响应如果您确定您想要显示这些数据,您可能要点击下面的按钮。" load_data: "读取数据" - unable_to_load_size: "无法读取:限制窗口的尺寸{{bbox_size}} 过大 (需小于 {{max_bbox_size}})" + unable_to_load_size: "无法读取:限制窗口的尺寸[[bbox_size]] 过大 (需小于 {{max_bbox_size}})" loading: "读取中" show_history: "显示历史" wait: "等待中..." - history_for_feature: "历史 {{feature}}" + history_for_feature: "历史 [[feature]]" details: "细节" private_user: "个人用户" - edited_by_user_at_timestamp: "Edited by {{user}} at {{timestamp}}" + edited_by_user_at_timestamp: "Edited by [[user]] at [[timestamp]]" tag_details: tags: "标签:" way_details: diff --git a/public/javascripts/site.js b/public/javascripts/site.js index 8f9d3a035..e0c18a27b 100644 --- a/public/javascripts/site.js +++ b/public/javascripts/site.js @@ -1,5 +1,7 @@ -//Called as the user scrolls/zooms around. -//Maniplate hrefs of the view tab and various other links +/* + * Called as the user scrolls/zooms around to aniplate hrefs of the + * view tab and various other links + */ function updatelinks(lon,lat,zoom,layers,minlon,minlat,maxlon,maxlat) { var decimals = Math.pow(10, Math.floor(zoom/3)); var node; @@ -104,6 +106,9 @@ function getArgs(url) { return args; } +/* + * Called to set the arguments on a URL from the given hash. + */ function setArgs(url, args) { var queryitems = new Array(); @@ -119,6 +124,9 @@ function setArgs(url, args) { return url.replace(/\?.*$/, "") + "?" + queryitems.join("&"); } +/* + * Called to get the arguments from a URL as a hash. + */ function getStyle(el, property) { var style; @@ -132,3 +140,21 @@ function getStyle(el, property) { return style; } + +/* + * Called to interpolate JavaScript variables in strings using a + * similar syntax to rails I18n string interpolation - the only + * difference is that [[foo]] is the placeholder syntax instead + * of {{foo}} which allows the same string to be processed by both + * rails and then later by javascript. + */ +function i18n(string, keys) { + for (var key in keys) { + var re_key = '\\[\\[' + key + '\\]\\]'; + var re = new RegExp(re_key, "g"); + + string = string.replace(re, keys[key]); + } + + return string; +}