mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-12 16:52:50 +00:00
Change imagery Transifex to YAML, use translated name and description
This commit is contained in:
@@ -15,6 +15,6 @@ source_lang = en
|
||||
type = YAML
|
||||
|
||||
[id-editor.imagery]
|
||||
file_filter = .tx/tmp/imagery/<lang>.json
|
||||
file_filter = .tx/tmp/imagery/<lang>.yaml
|
||||
source_lang = en
|
||||
type = KEYVALUEJSON
|
||||
type = YAML
|
||||
|
||||
4
build.js
4
build.js
@@ -66,8 +66,8 @@ fs.writeFileSync('data/taginfo.json', JSON.stringify(taginfo, null, 4));
|
||||
|
||||
// Push changes from data/core.yaml into en.json
|
||||
var core = YAML.load(fs.readFileSync('data/core.yaml', 'utf8'));
|
||||
var imagery = JSON.parse(fs.readFileSync('./node_modules/editor-layer-index/i18n/en.json', 'utf8'));
|
||||
var en = _.merge(core, { en: { presets: tstrings }}, { en: { imagery: imagery }});
|
||||
var imagery = YAML.load(fs.readFileSync('node_modules/editor-layer-index/i18n/en.yaml', 'utf8'));
|
||||
var en = _.merge(core, { en: { presets: tstrings }}, imagery);
|
||||
fs.writeFileSync('dist/locales/en.json', JSON.stringify(en, null, 4));
|
||||
|
||||
process.exit();
|
||||
|
||||
@@ -26,13 +26,13 @@ var auth = JSON.parse(fs.readFileSync('./transifex.auth', 'utf8'));
|
||||
|
||||
var sourceCore = yaml.load(fs.readFileSync('./data/core.yaml', 'utf8')),
|
||||
sourcePresets = yaml.load(fs.readFileSync('./data/presets.yaml', 'utf8')),
|
||||
sourceImagery = JSON.parse(fs.readFileSync('./node_modules/editor-layer-index/i18n/en.json', 'utf8'));
|
||||
sourceImagery = yaml.load(fs.readFileSync('./node_modules/editor-layer-index/i18n/en.yaml', 'utf8'));
|
||||
|
||||
|
||||
asyncMap(resources, getResource, function(err, locales) {
|
||||
if (err) return console.log(err);
|
||||
|
||||
var locale = _.merge(sourceCore, sourcePresets, { en: { imagery: sourceImagery }}),
|
||||
var locale = _.merge(sourceCore, sourcePresets, sourceImagery),
|
||||
dataLocales = {};
|
||||
|
||||
locales.forEach(function(l) {
|
||||
@@ -83,33 +83,14 @@ function getResource(resource, callback) {
|
||||
function getLanguage(resourceURL) {
|
||||
return function(code, callback) {
|
||||
code = code.replace(/-/g, '_');
|
||||
var isImagery = resourceURL.match(/imagery\/$/);
|
||||
var mode;
|
||||
var url = resourceURL + 'translation/' + code;
|
||||
if (code === 'vi') { url += '?mode=reviewed'; }
|
||||
|
||||
// Transifex treats JSONKEYVALUE a bit differently than YML.
|
||||
// YML = untranslated strings are excluded
|
||||
// JSONKEYVALUE = untranslated strings are replaced by source strings
|
||||
if (code === 'vi') {
|
||||
mode = isImagery ? 'onlyreviewed' : 'reviewed';
|
||||
} else {
|
||||
mode = isImagery ? 'onlytranslated': 'default';
|
||||
}
|
||||
|
||||
var url = resourceURL + 'translation/' + code + '?mode=' + mode;
|
||||
request.get(url, { auth : auth }, function(err, resp, body) {
|
||||
if (err) return callback(err);
|
||||
console.log(resp.statusCode + ': ' + url);
|
||||
|
||||
var content = JSON.parse(body).content;
|
||||
var data;
|
||||
if (isImagery) {
|
||||
// keep only translated (non-empty) values
|
||||
var imagery = _.pickBy(JSON.parse(content), _.identity);
|
||||
data = _.isEmpty(imagery) ? {} : { imagery: imagery };
|
||||
} else {
|
||||
data = yaml.safeLoad(content)[code];
|
||||
}
|
||||
callback(null, data);
|
||||
callback(null, yaml.safeLoad(content)[code]);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
86
dist/locales/en.json
vendored
86
dist/locales/en.json
vendored
@@ -5111,29 +5111,69 @@
|
||||
}
|
||||
},
|
||||
"imagery": {
|
||||
"Bing.name": "Bing aerial imagery",
|
||||
"DigitalGlobe-Premium.attribution.text": "Terms & Feedback",
|
||||
"DigitalGlobe-Premium.name": "DigitalGlobe Premium Imagery",
|
||||
"DigitalGlobe-Standard.attribution.text": "Terms & Feedback",
|
||||
"DigitalGlobe-Standard.name": "DigitalGlobe Standard Imagery",
|
||||
"Mapbox.attribution.text": "Terms & Feedback",
|
||||
"Mapbox.name": "Mapbox Satellite",
|
||||
"New_and_Misaligned_TIGER_Roads-2013.description": "At zoom level 16+, public domain map data from the US Census. At lower zooms, only changes since 2006 minus changes already incorporated into OpenStreetMap",
|
||||
"New_and_Misaligned_TIGER_Roads-2013.name": "New & Misaligned TIGER Roads",
|
||||
"mapbox_locator_overlay.attribution.text": "Terms & Feedback",
|
||||
"mapbox_locator_overlay.description": "Shows major features to help orient you.",
|
||||
"mapbox_locator_overlay.name": "Locator Overlay",
|
||||
"osm-gps.attribution.text": "© OpenStreetMap contributors",
|
||||
"osm-gps.description": "Public GPS traces uploaded to OpenStreetMap.",
|
||||
"osm-gps.name": "OpenStreetMap GPS traces",
|
||||
"osm-mapnik-german_style.attribution.text": "© OpenStreetMap contributors, CC-BY-SA",
|
||||
"osm-mapnik-german_style.name": "OpenStreetMap (German Style)",
|
||||
"stamen-terrain-background.attribution.text": "Map tiles by Stamen Design, under CC BY 3.0",
|
||||
"stamen-terrain-background.name": "Stamen Terrain",
|
||||
"tf-cycle.attribution.text": "Maps © Thunderforest, Data © OpenStreetMap contributors",
|
||||
"tf-cycle.name": "Thunderforest OpenCycleMap",
|
||||
"tf-landscape.attribution.text": "Maps © Thunderforest, Data © OpenStreetMap contributors",
|
||||
"tf-landscape.name": "Thunderforest Landscape"
|
||||
"Bing": {
|
||||
"name": "Bing aerial imagery"
|
||||
},
|
||||
"DigitalGlobe-Premium": {
|
||||
"attribution": {
|
||||
"text": "Terms & Feedback"
|
||||
},
|
||||
"name": "DigitalGlobe Premium Imagery"
|
||||
},
|
||||
"DigitalGlobe-Standard": {
|
||||
"attribution": {
|
||||
"text": "Terms & Feedback"
|
||||
},
|
||||
"name": "DigitalGlobe Standard Imagery"
|
||||
},
|
||||
"Mapbox": {
|
||||
"attribution": {
|
||||
"text": "Terms & Feedback"
|
||||
},
|
||||
"name": "Mapbox Satellite"
|
||||
},
|
||||
"New_and_Misaligned_TIGER_Roads-2013": {
|
||||
"description": "At zoom level 16+, public domain map data from the US Census. At lower zooms, only changes since 2006 minus changes already incorporated into OpenStreetMap",
|
||||
"name": "New & Misaligned TIGER Roads"
|
||||
},
|
||||
"mapbox_locator_overlay": {
|
||||
"attribution": {
|
||||
"text": "Terms & Feedback"
|
||||
},
|
||||
"description": "Shows major features to help orient you.",
|
||||
"name": "Locator Overlay"
|
||||
},
|
||||
"osm-gps": {
|
||||
"attribution": {
|
||||
"text": "© OpenStreetMap contributors"
|
||||
},
|
||||
"description": "Public GPS traces uploaded to OpenStreetMap.",
|
||||
"name": "OpenStreetMap GPS traces"
|
||||
},
|
||||
"osm-mapnik-german_style": {
|
||||
"attribution": {
|
||||
"text": "© OpenStreetMap contributors, CC-BY-SA"
|
||||
},
|
||||
"name": "OpenStreetMap (German Style)"
|
||||
},
|
||||
"stamen-terrain-background": {
|
||||
"attribution": {
|
||||
"text": "Map tiles by Stamen Design, under CC BY 3.0"
|
||||
},
|
||||
"name": "Stamen Terrain"
|
||||
},
|
||||
"tf-cycle": {
|
||||
"attribution": {
|
||||
"text": "Maps © Thunderforest, Data © OpenStreetMap contributors"
|
||||
},
|
||||
"name": "Thunderforest OpenCycleMap"
|
||||
},
|
||||
"tf-landscape": {
|
||||
"attribution": {
|
||||
"text": "Maps © Thunderforest, Data © OpenStreetMap contributors"
|
||||
},
|
||||
"name": "Thunderforest Landscape"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ export function rendererBackgroundSource(data) {
|
||||
var source = _.clone(data),
|
||||
offset = [0, 0],
|
||||
name = source.name,
|
||||
description = source.description,
|
||||
best = !!source.best;
|
||||
|
||||
source.scaleExtent = data.scaleExtent || [0, 20];
|
||||
@@ -30,7 +31,12 @@ export function rendererBackgroundSource(data) {
|
||||
|
||||
|
||||
source.name = function() {
|
||||
return name;
|
||||
return t('imagery.' + source.id + '.name', { default: name });
|
||||
};
|
||||
|
||||
|
||||
source.description = function() {
|
||||
return t('imagery.' + source.id + '.description', { default: description });
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ export function uiBackground(context) {
|
||||
var item = d3.select(this).select('label'),
|
||||
span = item.select('span'),
|
||||
placement = (i < nodes.length / 2) ? 'bottom' : 'top',
|
||||
description = d.description(),
|
||||
isOverflowing = (span.property('clientWidth') !== span.property('scrollWidth'));
|
||||
|
||||
if (d === previous) {
|
||||
@@ -73,10 +74,10 @@ export function uiBackground(context) {
|
||||
return uiTooltipHtml(tip, uiCmd('⌘B'));
|
||||
})
|
||||
);
|
||||
} else if (d.description || isOverflowing) {
|
||||
} else if (description || isOverflowing) {
|
||||
item.call(tooltip()
|
||||
.placement(placement)
|
||||
.title(d.description || d.name())
|
||||
.title(description || d.name())
|
||||
);
|
||||
} else {
|
||||
item.call(tooltip().destroy);
|
||||
|
||||
Reference in New Issue
Block a user