Skip to content

Instantly share code, notes, and snippets.

@ImreSamu
Created September 21, 2018 03:15
Show Gist options
  • Save ImreSamu/eec097b3b2afaee8f878a1d8753ba812 to your computer and use it in GitHub Desktop.
Save ImreSamu/eec097b3b2afaee8f878a1d8753ba812 to your computer and use it in GitHub Desktop.
check_idpresets.sh [ 2018.Sep.21]
#!/bin/bash
# name: check_idpresets.sh [ 2018.Sep.21]
# check iD Editor Translations
# --- Determine Duplicate Elements,
# --- Export presets to CSV
#
# License: same as iD Editor / available under the WTFPL : http://sam.zoy.org/wtfpl/
# Created by ImreSamu for helping hungarian translations
#
# requirements :
# - jq ( http://stedolan.github.io/jq/ )
# - json2csv ( https://github.com/zemirco/json2csv )
#
# example call - first parameter is the language code
# ./check_idpresets.sh hu
# ./check_idpresets.sh de
# ./check_idpresets.sh en
# ./check_idpresets.sh es
# ./check_idpresets.sh it
#
# check valid language code here: https://github.com/openstreetmap/iD/tree/master/dist/locales
#
set -e
xaafill=$(printf "%0.s-" {1..80})
echo "Check OpenStreetMap iD Editor Translations"
if [ "$1" = "" ]
then
echo "Usage: $0 <language code>"
echo "check valid language code here: https://github.com/openstreetmap/iD/tree/master/dist/locales "
echo "- example2: hu.json -> $0 hu"
echo "- example3: de.json -> $0 de"
echo " "
echo "Output files "
echo " - <language code>_presets.csv : all presets converted to csv ( separator = ; )"
echo " - <language code>_dups.csv : translations duplicates"
exit
fi
echo "Language code :" $1
# download
wget -O id.json https://raw.githubusercontent.com/openstreetmap/iD/master/dist/locales/$1.json
# convert to csv
cat id.json | \
jq ".$1.presets.presets|to_entries|[.[]|{key:.key,name:.value.name,terms:.value.terms}]" | \
json2csv -f name,key,terms -d ";" | \
sort > $1_presets.csv
# detecting duplicate translations
cat id.json | \
jq ".$1.presets.presets|to_entries|[.[]|{key:.key,name:.value.name,terms:.value.terms}]" | \
json2csv -f name,key,terms -d ";" | \
sort | \
sed "s/;/$xaafill;/g" | \
uniq -D -w80 | \
sed "s/$xaafill;/;/g" \
> $1_dups.csv
echo " --- Duplicates -----"
cat $1_dups.csv
echo "Created 2 files "
echo "--> $1_presets.csv : all presets converted to csv ( separator = ; )"
echo "--> $1_dups.csv : translations duplicates"
echo " "
We can make this file beautiful and searchable if this error is corrected: Any value after quoted field isn't allowed in line 1.
"Accessible aux services d'urgences";"emergency/destination";null
"Accessible aux services d'urgences";"emergency/yes";null
"Arrêt de bus";"highway/bus_stop";null
"Arrêt de bus";"public_transport/linear_platform_bus";null
"Arrêt de bus";"public_transport/platform_bus";null
"Artisanat";"craft";"Artisanat"
"Artisanat";"craft/handicraft";"Artisan"
"Bunker";"building/bunker";null
"Bunker";"golf/bunker";"Bunker"
"Bunker";"landuse/military/bunker";"Bunker, Casemate"
"Bureau d'état-civil";"amenity/register_office";null
"Bureau d'état-civil";"office/government/register_office";"Registre d'état civil"
"Caméra de surveillance";"man_made/surveillance_camera";"Caméra,Vidéosurveillance,Vidéoprotection"
"Caméra de surveillance";"man_made/surveillance";"caméra, vidéo"
"Casse automobile";"amenity/scrapyard";null
"Casse automobile";"landuse/industrial/scrap_yard";"Casse automobile, Cimetière de voitures, Ferrailles."
"Distributeur de journaux";"amenity/vending_machine/newspapers";"distributeur de journaux, distributeur à journaux, distributeur automatique de journaux, machine à journaux, vente automatique de journaux, vente de journaux, vente journaux, journaux, journal, machine journaux, vending machine newspapers, newspapers, magazines, journaux"
"Distributeur de journaux";"amenity/vending_machine/news_papers";null
"Entrée/Sortie";"building/entrance";null
"Entrée/Sortie";"entrance";"Entrée/Sortie,Évacuation,Porte d'entrée"
"Gare de remontée mécanique";"aerialway/station";null
"Gare de remontée mécanique";"public_transport/station_aerialway";null
"Gare ferroviaire (arrêt à la demande)";"public_transport/station_train_halt";null
"Gare ferroviaire (arrêt à la demande)";"railway/halt";null
"Gare ferroviaire";"building/train_station";null
"Gare ferroviaire";"public_transport/station_train";null
"Gare ferroviaire";"railway/station";null
"Gare routière";"amenity/bus_station";null
"Gare routière";"public_transport/station_bus";null
"Maison de repos";"amenity/nursing_home";null
"Maison de repos";"amenity/social_facility/nursing_home";"Maison de repis, Maison de convalescence, Maison de retraite médicalisée"
"Notaire";"office/lawyer/notary";null
"Notaire";"office/notary";"Notaire"
"Obstacle d'eau";"golf/water_hazard_area";"zone d'eau"
"Obstacle d'eau";"golf/water_hazard_line";"ligne d'eau"
"Obstacle d'eau latéral";"golf/lateral_water_hazard_area";"zone d'eau latéral"
"Obstacle d'eau latéral";"golf/lateral_water_hazard_line";"ligne d'eau latéral"
"Opticien";"craft/optician";null
"Opticien";"shop/optician";"Opticien,Marchand de lunettes"
"Passage piéton";"footway/crossing";"Traversée de rue,Passage clouté"
"Passage piéton";"highway/crossing";"Passage piéton"
"Passage piéton surélevé";"footway/crossing-raised";"Passage piéton, piéton, passage clouté, croisée de rues"
"Passage piéton surélevé";"footway/crosswalk-raised";"Zébra, passage piéton, passage cloûté"
"Passage piéton surélevé";"highway/crossing-raised";"Passage piéton"
"Passage piéton surélevé";"highway/crosswalk-raised";"Passage piéton"
"Passage piéton (zebra)";"footway/crosswalk";"Passage piéton, Zébra, Passage zébré"
"Passage piéton (zebra)";"highway/crosswalk";"Passage piéton, Zébra, Passage zébré"
"Piscine";"amenity/swimming_pool";null
"Piscine";"leisure/swimming_pool";"Piscine"
"Prêteur sur gages";"shop/money_lender";"Prêteur sur gages"
"Prêteur sur gages";"shop/pawnbroker";"Mont-de-piété, Crédit municipal"
"Quai de gare ferroviaire";"public_transport/linear_platform_train";null
"Quai de gare ferroviaire";"public_transport/platform_train";null
"Quai de gare ferroviaire";"railway/platform";null
"Quai de transport en commun";"public_transport/linear_platform";null
"Quai de transport en commun";"public_transport/platform";null
"Quai pour ferry";"public_transport/linear_platform_ferry";null
"Quai pour ferry";"public_transport/platform_ferry";null
"Quai pour remontée mécanique";"public_transport/linear_platform_aerialway";null
"Quai pour remontée mécanique";"public_transport/platform_aerialway";null
"Quai pour tramway";"public_transport/linear_platform_tram";null
"Quai pour tramway";"public_transport/platform_tram";null
"Quai pour trolleys";"public_transport/linear_platform_trolleybus";null
"Quai pour trolleys";"public_transport/platform_trolleybus";null
"Serrurier";"craft/locksmith";null
"Serrurier";"shop/locksmith";"Serrurier"
"Station de métro léger";"public_transport/linear_platform_light_rail";null
"Station de métro léger";"public_transport/platform_light_rail";null
"Station de métro";"public_transport/linear_platform_subway";null
"Station de métro";"public_transport/platform_subway";null
"Station de métro";"public_transport/station_subway";null
"Station de monorail";"public_transport/linear_platform_monorail";null
"Station de monorail";"public_transport/platform_monorail";null
"Station de monorail";"public_transport/station_monorail";null
"Station de tramway";"public_transport/station_light_rail";null
"Station de tramway";"public_transport/station_tram";null
"Terminal ferry";"amenity/ferry_terminal";null
"Terminal ferry";"public_transport/station_ferry";null
"Terre-plein";"embankment";"Digue,Surélévation"
"Terre-plein";"man_made/embankment";null
"Voie navigable";"type/waterway";"Canal, rivière, cours d'eau"
"Voie navigable";"waterway";null
"Zone agricole";"landuse/farmland";"Terre agricole : cultures et élevage"
"Zone agricole";"landuse/farm";null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment