Skip to content

Commit

Permalink
Minor fixups in cz/sk translation (sky-map-team#359)
Browse files Browse the repository at this point in the history
* fixed up few strings (mainly missing 1st capital letter
* made some strings more clear
* fixed one mistranslated string (location auto set)
* upgrade/documentacion/refatcor  of translation  check script (now checks for duplicates)
  • Loading branch information
07pepa authored Sep 23, 2020
1 parent 8e425cc commit ca170d5
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 43 deletions.
2 changes: 1 addition & 1 deletion app/src/main/res/values-cs/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
<item>Standardní</item>
<item>Vysoké</item>
</string-array>
</resources>
</resources>
14 changes: 7 additions & 7 deletions app/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<string name="location_no_auto">Váš telefon nepodporuje automatické určení polohy. Polohu můžete nastavit ručně v nastavení.</string>
<string name="location_offer_to_enable">Automatické určení polohy je deaktivováno. Chce je aktivovat?</string>
<string name="location_offer_to_enable_gps_title">Automatické určení polohy deaktivováno</string>
<string name="location_set_auto">Poloha nastavena od %1$s po %2$s</string>
<string name="location_set_auto">Poloha nastavena pomocí %1$s na %2$s</string>
<string name="location_unable_to_geocode">Nelze najít vaši polohu, možná je síť nedostupná?</string>
<string name="location_not_found_title" translation_description="dialog box title when location not found">Nenalezeno</string>
<string name="location_not_found" translation_description="dialog message when placename not found">Nelze nalézt „%s“</string>
Expand Down Expand Up @@ -378,8 +378,8 @@
<string name="load_kml_file">Načíst</string>
<string name="show_meteors_pref">Meteorické roje</string>
<string name="quadrantids" translation_description="Meteor Shower">Kvadrantidy</string>
<string name="compass_calibration_activity_heading_compass">Kompas -</string>
<string name="diagnostics_activity_magnetic_correction">Mag korekce</string>
<string name="compass_calibration_activity_heading_compass">Kompas</string>
<string name="diagnostics_activity_magnetic_correction">Magnetická korekce</string>
<string name="menu_diagnostics">Diagnostika</string>
<string name="permission_disabled">Povolení odmítnuto</string>
<string name="sensor_absent">Senzor chybí</string>
Expand All @@ -392,7 +392,7 @@
<string name="diagnostics_activity_universal_time">Univerzální čas</string>
<string name="location_rationale_title">Proč potřebujeme vaši lokaci?</string>
<string name="diagnostics_activity_rotation_vector">Rotace</string>
<string name="diagnostics_activity_location_and_time_heading">lokace a čas</string>
<string name="diagnostics_activity_location_and_time_heading">Lokace a čas</string>
<string name="e_lyrae" translation_description="Name of the star ε Lyrae">Epsylon Lyrae</string>
<string name="perseids" translation_description="Meteor Shower">Perseidy</string>
<string name="sensor_accuracy_unreliable">Přesnost: Nespolehlivá</string>
Expand All @@ -411,7 +411,7 @@
Avšak Sky Map lze stále používat v manuálním módu tím že budete mapu posouvat otačet a zoomovat prsty.
</string>
<string name="compass_calibration_activity_do_not_show_this_again">Toto již nezobrazovat</string>
<string name="diagnostics_activity_location">Lokace (lat, long)</string>
<string name="diagnostics_activity_location">Lokace (šíkař, délka)</string>
<string name="diagnostics_activity_sensors_heading">Senzory</string>
<string name="orionids" translation_description="Meteor Shower">Orionidy</string>
<string name="diagnostics_activity_sky_map_version">Verze Sky Map</string>
Expand Down Expand Up @@ -447,7 +447,7 @@
<string name="deltaaquariids" translation_description="Meteor Shower">Jižní Delta Aquaridy</string>
<string name="do_not_show_again">Tuto zprávu již nezobrazovat</string>
<string name="diagnostics_activity_gyroscope">Gyroskop</string>
<string name="diagnostics_activity_network_heading">Síť</string>
<string name="diagnostics_activity_network_heading">Sítě</string>
<string name="diagnostics_activity_local_datetime">Místní čas</string>
<string name="rotate_horizon_preference_summary">Otočit horizont o 90 stupňů (pro zařízení s vynuceným zobrazení na šírku, např. chytré brýle)</string>
<string name="sensor_reverse_preference_title">Obrátit magnetické pole v ose Z</string>
Expand All @@ -456,7 +456,7 @@
<string name="wifi">" (wifi)"</string>
<string name="sensor_accuracy_low">Přesnost: Nízká</string>
<string name="diagnostics_activity_gps">GPS</string>
<string name="diagnostics_activity_pointing_ra_dec">ukazující snapshot</string>
<string name="diagnostics_activity_pointing_ra_dec">Ukazující/ilustrační snapshot</string>
<string name="connected">Připojeno</string>
<string name="sensor_accuracy_unknown">Přesnost: Neznámá</string>
</resources>
14 changes: 7 additions & 7 deletions app/src/main/res/values-sk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<string name="location_no_auto">Váš telefon nepodporuje automatické určení polohy. Polohu můžete nastavit ručně v nastavení.</string>
<string name="location_offer_to_enable">Automatické určení polohy je deaktivováno. Chce je aktivovat?</string>
<string name="location_offer_to_enable_gps_title">Automatické určení polohy deaktivováno</string>
<string name="location_set_auto">Poloha nastavena od %1$s po %2$s</string>
<string name="location_set_auto">Poloha nastavena pomocí %1$s na %2$s</string>
<string name="location_unable_to_geocode">Nelze najít vaši polohu, možná je síť nedostupná?</string>
<string name="location_not_found_title" translation_description="dialog box title when location not found">Nenalezeno</string>
<string name="location_not_found" translation_description="dialog message when placename not found">Nelze nalézt „%s“</string>
Expand Down Expand Up @@ -378,8 +378,8 @@
<string name="load_kml_file">Načíst</string>
<string name="show_meteors_pref">Meteorické roje</string>
<string name="quadrantids" translation_description="Meteor Shower">Kvadrantidy</string>
<string name="compass_calibration_activity_heading_compass">Kompas -</string>
<string name="diagnostics_activity_magnetic_correction">Mag korekce</string>
<string name="compass_calibration_activity_heading_compass">Kompas</string>
<string name="diagnostics_activity_magnetic_correction">Magnetická korekce</string>
<string name="menu_diagnostics">Diagnostika</string>
<string name="permission_disabled">Povolení odmítnuto</string>
<string name="sensor_absent">Senzor chybí</string>
Expand All @@ -392,7 +392,7 @@
<string name="diagnostics_activity_universal_time">Univerzální čas</string>
<string name="location_rationale_title">Proč potřebujeme vaši lokaci?</string>
<string name="diagnostics_activity_rotation_vector">Rotace</string>
<string name="diagnostics_activity_location_and_time_heading">lokace a čas</string>
<string name="diagnostics_activity_location_and_time_heading">Lokace a čas</string>
<string name="e_lyrae" translation_description="Name of the star ε Lyrae">Epsylon Lyrae</string>
<string name="perseids" translation_description="Meteor Shower">Perseidy</string>
<string name="sensor_accuracy_unreliable">Přesnost: Nespolehlivá</string>
Expand All @@ -411,7 +411,7 @@
Avšak Sky Map lze stále používat v manuálním módu tím že budete mapu posouvat otačet a zoomovat prsty.
</string>
<string name="compass_calibration_activity_do_not_show_this_again">Toto již nezobrazovat</string>
<string name="diagnostics_activity_location">Lokace (lat, long)</string>
<string name="diagnostics_activity_location">Lokace (šíkař, délka)</string>
<string name="diagnostics_activity_sensors_heading">Senzory</string>
<string name="orionids" translation_description="Meteor Shower">Orionidy</string>
<string name="diagnostics_activity_sky_map_version">Verze Sky Map</string>
Expand Down Expand Up @@ -447,7 +447,7 @@
<string name="deltaaquariids" translation_description="Meteor Shower">Jižní Delta Aquaridy</string>
<string name="do_not_show_again">Tuto zprávu již nezobrazovat</string>
<string name="diagnostics_activity_gyroscope">Gyroskop</string>
<string name="diagnostics_activity_network_heading">Síť</string>
<string name="diagnostics_activity_network_heading">Sítě</string>
<string name="diagnostics_activity_local_datetime">Místní čas</string>
<string name="rotate_horizon_preference_summary">Otočit horizont o 90 stupňů (pro zařízení s vynuceným zobrazení na šírku, např. chytré brýle)</string>
<string name="sensor_reverse_preference_title">Obrátit magnetické pole v ose Z</string>
Expand All @@ -456,7 +456,7 @@
<string name="wifi">" (wifi)"</string>
<string name="sensor_accuracy_low">Přesnost: Nízká</string>
<string name="diagnostics_activity_gps">GPS</string>
<string name="diagnostics_activity_pointing_ra_dec">ukazující snapshot</string>
<string name="diagnostics_activity_pointing_ra_dec">Ukazující/ilustrační snapshot</string>
<string name="connected">Připojeno</string>
<string name="sensor_accuracy_unknown">Přesnost: Neznámá</string>
</resources>
77 changes: 49 additions & 28 deletions tools/translateCheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,75 @@
from bs4 import BeautifulSoup # pip install beautifulsoup4 lxml
from pathlib import Path

enca="utf-8"
enca="utf-8" #used encoding

#get root of project
resfolder=Path(__file__).absolute().parent.parent.joinpath("app/src/main/res")

#get folder with reference string
referencefolder= resfolder.joinpath("values")

#get language
lang = input("write two letter iso code of your country like fr: ")



ender = input("write two letter iso code of your country like fr: ")

toTranslateFolder= resfolder.joinpath(f"values-{ender}")
#target folder to translate
toTranslateFolder= resfolder.joinpath(f"values-{lang}")

if not toTranslateFolder.is_dir():
print(f"your folder is not folder or does not exist {toTranslateFolder}")
exit(0)


def diffmaker(endpath):
def checker(file):
"""
prints
* diff between reference and target translation
* duplicates in target translation
"""
print("=======================================================")
toCompare = toTranslateFolder.joinpath(endpath)
reference = referencefolder.joinpath(endpath)
toCompare = toTranslateFolder.joinpath(file)
reference = referencefolder.joinpath(file)
if not toCompare.is_file():
print(f"translation for {endpath} dont exists, coppy it from {reference}")
print(f"translation for {file} dont exists, coppy it from {reference}")
return

toCompare = BeautifulSoup(toCompare.open(encoding=enca), "xml")
reference = BeautifulSoup(reference.open(encoding=enca), "xml")

def fetchAllNames(src):
outSet = set()
for string in src.find_all("string"):
outSet.add(string["name"])
return outSet
# returns iterator
return map(lambda string: string["name"], src.find_all("string"))

toCompare = fetchAllNames(toCompare)
missing = set()


for one in fetchAllNames(reference):
toCompare = list(fetchAllNames(toCompare))
errBuffer = ""
#diff pringing
for one in set(fetchAllNames(reference)):
if one not in toCompare:
missing.add(str(reference.find("string",attrs={"name":one})))
errBuffer += str(reference.find("string",attrs={"name":one}))+"\n"

if(len(missing)>0):
print(f"missing from {endpath} (contains oreginal strings)\n------------------------------------------------------\n"+"\n".join(missing))


diffmaker("strings.xml")

diffmaker("celestial_objects.xml")

if errBuffer!="":
errBuffer= f"missing from {file} (contains oreginal strings)\n------------------------------------------------------\n{errBuffer}"

#duplication detection
seen = set()
dupes = {}
for x in toCompare:
if x not in seen:
seen.add(x)
elif x in dupes:
dupes[x]+=1
else:
dupes[x]=2

if(len(dupes)>0):
errBuffer+= f"\n\nfound duplicates in {file} \n\n"
for key,value in dupes.items():
errBuffer+= f"<string name=\"{key}\"> is present {value} times \n"

if(errBuffer!=""):
print(errBuffer)
else:
print(f"no fixes needed in {file}")

checker("strings.xml")
checker("celestial_objects.xml")

0 comments on commit ca170d5

Please sign in to comment.