From 4b4f20461d5b284beeb54ae303327f325cf17761 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Thu, 6 Jun 2013 12:56:39 -0700 Subject: [PATCH] Interpolate "Cafe" and "Playground" translations (fixes #1578) --- data/core.yaml | 4 ++-- dist/locales/en.json | 4 ++-- js/id/ui/intro.js | 7 ++++--- js/id/ui/intro/area.js | 16 ++++++++-------- js/id/ui/intro/line.js | 22 +++++++++++----------- js/id/ui/intro/navigation.js | 8 ++++---- js/id/ui/intro/point.js | 26 +++++++++++++------------- js/id/ui/intro/start_editing.js | 4 ++-- 8 files changed, 46 insertions(+), 45 deletions(-) diff --git a/data/core.yaml b/data/core.yaml index bc9b130be..a84efbb91 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -486,7 +486,7 @@ en: add: "Points can be used to represent features such as shops, restaurants and monuments. They mark a specific location, and describe what's there. **Click the Point button to add a new point.**" place: "Click to place the point on the map. The point we are adding is a Cafe. **Place the point at the corner of This Street and That Street**" place: "The point can be placed by clicking on the map. **Place the point on top of the building.**" - search: "There are many different features that can be represented by points. The point you just added is a Cafe. **Search for 'Cafe' **" + search: "There are many different features that can be represented by points. The point you just added is a Cafe. **Search for '{name}'**" choose: "**Choose Cafe from the list.**" describe: "The point is now marked as a cafe. Using the feature editor, we can add more information about the feature. **Add a name**" close: "The feature editor can be closed by clicking on the close button. **Close the feature editor**" @@ -499,7 +499,7 @@ en: add: "Areas are a more detailed way to represent features. They provide information on the boundaries of the feature. Areas can be used for most feature types points can be used for, and are often preferred. **Click the Area button to add a new area.**" corner: "Areas are drawn by placing nodes that mark the boundary of the area. **Place the starting node on one of the corners of the playground.**" place: "Draw the area by placing more nodes. Finish the area by clicking on the starting node. **Draw an area for the playground.**" - search: "**Search for Playground.**" + search: "**Search for '{name}'.**" choose: "**Choose Playground from the list.**" describe: "**Add a name, and close the feature editor**" lines: diff --git a/dist/locales/en.json b/dist/locales/en.json index 4ac4f4252..18a473047 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -314,7 +314,7 @@ "title": "Points", "add": "Points can be used to represent features such as shops, restaurants and monuments. They mark a specific location, and describe what's there. **Click the Point button to add a new point.**", "place": "The point can be placed by clicking on the map. **Place the point on top of the building.**", - "search": "There are many different features that can be represented by points. The point you just added is a Cafe. **Search for 'Cafe' **", + "search": "There are many different features that can be represented by points. The point you just added is a Cafe. **Search for '{name}'**", "choose": "**Choose Cafe from the list.**", "describe": "The point is now marked as a cafe. Using the feature editor, we can add more information about the feature. **Add a name**", "close": "The feature editor can be closed by clicking on the close button. **Close the feature editor**", @@ -328,7 +328,7 @@ "add": "Areas are a more detailed way to represent features. They provide information on the boundaries of the feature. Areas can be used for most feature types points can be used for, and are often preferred. **Click the Area button to add a new area.**", "corner": "Areas are drawn by placing nodes that mark the boundary of the area. **Place the starting node on one of the corners of the playground.**", "place": "Draw the area by placing more nodes. Finish the area by clicking on the starting node. **Draw an area for the playground.**", - "search": "**Search for Playground.**", + "search": "**Search for '{name}'.**", "choose": "**Choose Playground from the list.**", "describe": "**Add a name, and close the feature editor**" }, diff --git a/js/id/ui/intro.js b/js/id/ui/intro.js index 65a100bc8..4044cec78 100644 --- a/js/id/ui/intro.js +++ b/js/id/ui/intro.js @@ -36,9 +36,10 @@ iD.ui.intro = function(context) { var curtain = d3.curtain(); selection.call(curtain); - function reveal(box, textid, duration) { - if (textid) curtain.reveal(box, t(textid), textid.replace(/\./g, '-'), duration); - else curtain.reveal(box, '', '', duration); + function reveal(box, text, options) { + options = options || {}; + if (text) curtain.reveal(box, text, options.tooltipClass, options.duration); + else curtain.reveal(box, '', '', options.duration); } var steps = ['navigation', 'point', 'area', 'line', 'startEditing'].map(function(step, i) { diff --git a/js/id/ui/intro/area.js b/js/id/ui/intro/area.js index 72561a19c..ee05e15f2 100644 --- a/js/id/ui/intro/area.js +++ b/js/id/ui/intro/area.js @@ -12,7 +12,7 @@ iD.ui.intro.area = function(context, reveal) { var playground = [-85.63552, 41.94159], corner = [-85.63565411045074, 41.9417715536927]; context.map().centerZoom(playground, 19); - reveal('button.add-area', 'intro.areas.add'); + reveal('button.add-area', t('intro.areas.add'), {tooltipClass: 'intro-areas-add'}); context.on('enter.intro', addArea); @@ -22,12 +22,12 @@ iD.ui.intro.area = function(context, reveal) { var padding = 120 * Math.pow(2, context.map().zoom() - 19); var pointBox = iD.ui.intro.pad(context.projection(corner), padding); - reveal(pointBox, 'intro.areas.corner'); + reveal(pointBox, t('intro.areas.corner')); context.map().on('move.intro', function() { padding = 120 * Math.pow(2, context.map().zoom() - 19); pointBox = iD.ui.intro.pad(context.projection(corner), padding); - reveal(pointBox, 'intro.areas.corner', 0); + reveal(pointBox, t('intro.areas.corner'), {duration: 0}); }); } @@ -37,12 +37,12 @@ iD.ui.intro.area = function(context, reveal) { var padding = 150 * Math.pow(2, context.map().zoom() - 19); var pointBox = iD.ui.intro.pad(context.projection(playground), padding); - reveal(pointBox, 'intro.areas.place'); + reveal(pointBox, t('intro.areas.place')); context.map().on('move.intro', function() { padding = 150 * Math.pow(2, context.map().zoom() - 19); pointBox = iD.ui.intro.pad(context.projection(playground), padding); - reveal(pointBox, 'intro.areas.place', 0); + reveal(pointBox, t('intro.areas.place'), {duration: 0}); }); } @@ -52,7 +52,7 @@ iD.ui.intro.area = function(context, reveal) { context.on('enter.intro', null); timeout = setTimeout(function() { - reveal('.preset-search-input', 'intro.areas.search'); + reveal('.preset-search-input', t('intro.areas.search', {name: context.presets().item('leisure/playground').name()})); d3.select('.preset-search-input').on('keyup.intro', keySearch); }, 500); } @@ -60,14 +60,14 @@ iD.ui.intro.area = function(context, reveal) { function keySearch() { var first = d3.select('.preset-list-item:first-child'); if (first.classed('preset-leisure-playground')) { - reveal(first.select('.preset-list-button').node(), 'intro.areas.choose'); + reveal(first.select('.preset-list-button').node(), t('intro.areas.choose')); d3.selection.prototype.one.call(context.history(), 'change.intro', selectedPreset); d3.select('.preset-search-input').on('keyup.intro', null); } } function selectedPreset() { - reveal('.pane', 'intro.areas.describe'); + reveal('.pane', t('intro.areas.describe')); context.on('exit.intro', event.done); } }; diff --git a/js/id/ui/intro/line.js b/js/id/ui/intro/line.js index e05f6c241..7f7547d07 100644 --- a/js/id/ui/intro/line.js +++ b/js/id/ui/intro/line.js @@ -23,7 +23,7 @@ iD.ui.intro.line = function(context, reveal) { var intersection = [-85.62974496187628, 41.95742515554585]; context.map().centerZoom(start, 18); - reveal('button.add-line', 'intro.lines.add'); + reveal('button.add-line', t('intro.lines.add'), {tooltipClass: 'intro-areas-add'}); context.on('enter.intro', addLine); @@ -33,12 +33,12 @@ iD.ui.intro.line = function(context, reveal) { var padding = 150 * Math.pow(2, context.map().zoom() - 18); var pointBox = iD.ui.intro.pad(context.projection(start), padding); - reveal(pointBox, 'intro.lines.start'); + reveal(pointBox, t('intro.lines.start')); context.map().on('move.intro', function() { padding = 150 * Math.pow(2, context.map().zoom() - 18); pointBox = iD.ui.intro.pad(context.projection(start), padding); - reveal(pointBox, 'intro.lines.start', 0); + reveal(pointBox, t('intro.lines.start'), {duration: 0}); }); } @@ -49,12 +49,12 @@ iD.ui.intro.line = function(context, reveal) { var padding = 300 * Math.pow(2, context.map().zoom() - 19); var pointBox = iD.ui.intro.pad(context.projection(midpoint), padding); - reveal(pointBox, 'intro.lines.intersect'); + reveal(pointBox, t('intro.lines.intersect')); context.map().on('move.intro', function() { padding = 300 * Math.pow(2, context.map().zoom() - 19); pointBox = iD.ui.intro.pad(context.projection(midpoint), padding); - reveal(pointBox, 'intro.lines.intersect', 0); + reveal(pointBox, t('intro.lines.intersect'), {duration: 0}); }); } @@ -62,7 +62,7 @@ iD.ui.intro.line = function(context, reveal) { function retry(mode) { if (mode.id !== 'select') return; var pointBox = iD.ui.intro.pad(context.projection(intersection), 30); - reveal(pointBox, 'intro.lines.restart'); + reveal(pointBox, t('intro.lines.restart')); timeout(function() { context.replace(iD.actions.DeleteMultiple(mode.selectedIDs())); step.exit(); @@ -79,12 +79,12 @@ iD.ui.intro.line = function(context, reveal) { var padding = 900 * Math.pow(2, context.map().zoom() - 19); var pointBox = iD.ui.intro.pad(context.projection(centroid), padding); - reveal(pointBox, 'intro.lines.finish'); + reveal(pointBox, t('intro.lines.finish')); context.map().on('move.intro', function() { padding = 900 * Math.pow(2, context.map().zoom() - 19); pointBox = iD.ui.intro.pad(context.projection(centroid), padding); - reveal(pointBox, 'intro.lines.finish', 0); + reveal(pointBox, t('intro.lines.finish'), {duration: 0}); }); } } @@ -98,7 +98,7 @@ iD.ui.intro.line = function(context, reveal) { timeout(function() { d3.select('#curtain').style('pointer-events', 'none'); var road = d3.select('.preset-category-road .preset-list-button'); - reveal(road.node(), 'intro.lines.road'); + reveal(road.node(), t('intro.lines.road')); road.one('click.intro', roadCategory); }, 500); } @@ -106,14 +106,14 @@ iD.ui.intro.line = function(context, reveal) { function roadCategory() { timeout(function() { var grid = d3.select('.subgrid'); - reveal(grid.node(), 'intro.lines.residential'); + reveal(grid.node(), t('intro.lines.residential')); grid.selectAll('.preset-highway-residential .preset-list-button') .one('click.intro', roadDetails); }, 200); } function roadDetails() { - reveal('.pane', 'intro.lines.describe'); + reveal('.pane', t('intro.lines.describe')); context.on('exit.intro', event.done); } diff --git a/js/id/ui/intro/navigation.js b/js/id/ui/intro/navigation.js index d84f0e69f..3411b1f59 100644 --- a/js/id/ui/intro/navigation.js +++ b/js/id/ui/intro/navigation.js @@ -32,7 +32,7 @@ iD.ui.intro.navigation = function(context, reveal) { context.map().centerZoom([-85.63591, 41.94285], 19); - reveal(map, 'intro.navigation.drag'); + reveal(map, t('intro.navigation.drag')); context.map().on('move.intro', _.debounce(function() { context.map().on('move.intro', null); @@ -50,11 +50,11 @@ iD.ui.intro.navigation = function(context, reveal) { point = context.projection(hall); } var box = iD.ui.intro.pointBox(point); - reveal(box, 'intro.navigation.select'); + reveal(box, t('intro.navigation.select')); context.map().on('move.intro', function() { var box = iD.ui.intro.pointBox(context.projection(hall)); - reveal(box, 'intro.navigation.select', 0); + reveal(box, t('intro.navigation.select'), {duration: 0}); }); } @@ -63,7 +63,7 @@ iD.ui.intro.navigation = function(context, reveal) { context.on('enter.intro', null); context.map().on('move.intro', null); set(function() { - reveal('.entity-editor-pane', 'intro.navigation.pane'); + reveal('.entity-editor-pane', t('intro.navigation.pane')); context.on('exit.intro', event.done); }, 700); } diff --git a/js/id/ui/intro/point.js b/js/id/ui/intro/point.js index a2c806cab..a2b50ffb7 100644 --- a/js/id/ui/intro/point.js +++ b/js/id/ui/intro/point.js @@ -14,7 +14,7 @@ iD.ui.intro.point = function(context, reveal) { step.enter = function() { context.map().centerZoom([-85.63279, 41.94394], 19); - reveal('button.add-point', 'intro.points.add'); + reveal('button.add-point', t('intro.points.add'), {tooltipClass: 'intro-points-add'}); var corner = [-85.632481,41.944094]; @@ -25,11 +25,11 @@ iD.ui.intro.point = function(context, reveal) { context.on('enter.intro', enterSelect); var pointBox = iD.ui.intro.pad(context.projection(corner), 150); - reveal(pointBox, 'intro.points.place'); + reveal(pointBox, t('intro.points.place')); context.map().on('move.intro', function() { pointBox = iD.ui.intro.pad(context.projection(corner), 150); - reveal(pointBox, 'intro.points.place', 0); + reveal(pointBox, t('intro.points.place'), {duration: 0}); }); } @@ -40,7 +40,7 @@ iD.ui.intro.point = function(context, reveal) { context.on('enter.intro', null); setTimeout(function() { - reveal('.preset-search-input', 'intro.points.search'); + reveal('.preset-search-input', t('intro.points.search', {name: context.presets().item('amenity/cafe').name()})); d3.select('.preset-search-input').on('keyup.intro', keySearch); }, 500); } @@ -48,7 +48,7 @@ iD.ui.intro.point = function(context, reveal) { function keySearch() { var first = d3.select('.preset-list-item:first-child'); if (first.classed('preset-amenity-cafe')) { - reveal(first.select('.preset-list-button').node(), 'intro.points.choose'); + reveal(first.select('.preset-list-button').node(), t('intro.points.choose')); d3.selection.prototype.one.call(context.history(), 'change.intro', selectedPreset); d3.select('.preset-search-input').on('keydown.intro', function() { @@ -61,7 +61,7 @@ iD.ui.intro.point = function(context, reveal) { function selectedPreset() { setTimeout(function() { - reveal('.entity-editor-pane', 'intro.points.describe'); + reveal('.entity-editor-pane', t('intro.points.describe'), {tooltipClass: 'intro-points-describe'}); context.history().on('change.intro', closeEditor); context.on('exit.intro', selectPoint); }, 400); @@ -70,7 +70,7 @@ iD.ui.intro.point = function(context, reveal) { function closeEditor() { d3.select('.preset-search-input').on('keydown.intro', null); context.history().on('change.intro', null); - reveal('.entity-editor-pane', 'intro.points.close'); + reveal('.entity-editor-pane', t('intro.points.close')); } function selectPoint() { @@ -79,11 +79,11 @@ iD.ui.intro.point = function(context, reveal) { context.on('enter.intro', enterReselect); var pointBox = iD.ui.intro.pad(context.projection(corner), 150); - reveal(pointBox, 'intro.points.reselect'); + reveal(pointBox, t('intro.points.reselect')); context.map().on('move.intro', function() { pointBox = iD.ui.intro.pad(context.projection(corner), 150); - reveal(pointBox, 'intro.points.reselect', 0); + reveal(pointBox, t('intro.points.reselect'), {duration: 0}); }); } @@ -93,7 +93,7 @@ iD.ui.intro.point = function(context, reveal) { context.on('enter.intro', null); setTimeout(function() { - reveal('.entity-editor-pane', 'intro.points.fixname'); + reveal('.entity-editor-pane', t('intro.points.fixname')); context.on('exit.intro', deletePoint); }, 500); } @@ -103,11 +103,11 @@ iD.ui.intro.point = function(context, reveal) { context.on('enter.intro', enterDelete); var pointBox = iD.ui.intro.pad(context.projection(corner), 150); - reveal(pointBox, 'intro.points.reselect_delete'); + reveal(pointBox, t('intro.points.reselect_delete')); context.map().on('move.intro', function() { pointBox = iD.ui.intro.pad(context.projection(corner), 150); - reveal(pointBox, 'intro.points.reselect_delete', 0); + reveal(pointBox, t('intro.points.reselect_delete'), {duration: 0}); }); } @@ -122,7 +122,7 @@ iD.ui.intro.point = function(context, reveal) { setTimeout(function() { var node = d3.select('.radial-menu-item-delete').node(); var pointBox = iD.ui.intro.pad(node.getBoundingClientRect(), 50); - reveal(pointBox, 'intro.points.delete'); + reveal(pointBox, t('intro.points.delete')); }, 300); } diff --git a/js/id/ui/intro/start_editing.js b/js/id/ui/intro/start_editing.js index a91a6cd25..ec49b1b16 100644 --- a/js/id/ui/intro/start_editing.js +++ b/js/id/ui/intro/start_editing.js @@ -14,10 +14,10 @@ iD.ui.intro.startEditing = function(context, reveal) { step.enter = function() { - reveal('.map-control.help-control', 'intro.startediting.help'); + reveal('.map-control.help-control', t('intro.startediting.help')); timeout(function() { - reveal('#bar button.save', 'intro.startediting.save'); + reveal('#bar button.save', t('intro.startediting.save')); }, 3500); timeout(function() {