1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[loc] add a rufus.loc validation script and fix multiple issues

This commit is contained in:
Piotr Halama 2018-04-23 15:57:50 +01:00 committed by Pete Batard
parent 0eb41e4efb
commit 0ae39f2ba3
3 changed files with 205 additions and 30 deletions

View file

@ -125,6 +125,7 @@ t IDC_START "Start"
g IDD_ABOUTBOX
t IDD_ABOUTBOX "About Rufus"
t IDC_ABOUT_LICENSE "License"
t IDOK "OK"
# About -> License dialog
g IDD_LICENSE
@ -2382,7 +2383,6 @@ t IDS_FORMAT_OPTIONS_TXT "選項"
t IDC_BAD_BLOCKS "檢查損毀磁區,測試次數"
t IDC_QUICK_FORMAT "快速格式化"
t IDC_EXTENDED_LABEL "建立延伸標籤及圖示"
t IDC_LOG "記錄檔"
t IDS_STATUS_TXT "狀態"
t IDCANCEL "離開"
t IDC_START "執行"
@ -2774,11 +2774,11 @@ t MSG_298 "你選擇的 ISO 映像檔不符合它所宣告的大小: 缺少 %s !
t MSG_299 "時間戳記驗證錯誤"
t MSG_300 "Rufus 不能驗證下載的更新其時間戳記比現有的執行檔還新。\n\n"
"為避免可能的資安攻擊,更新流程已停止且下載的更新檔將會刪除。更多詳情請參見記錄檔。"
MSG_301 "顯示應用程式設定"
MSG_302 "顯示此應用程式資訊"
MSG_303 "顯示記錄檔"
MSG_304 "建立選擇的裝置的磁碟映像"
MSG_305 "是否要使用此裝置來安裝 Windows 在另一個磁碟上,"
t MSG_301 "顯示應用程式設定"
t MSG_302 "顯示此應用程式資訊"
t MSG_303 "顯示記錄檔"
t MSG_304 "建立選擇的裝置的磁碟映像"
t MSG_305 "是否要使用此裝置來安裝 Windows 在另一個磁碟上,"
"或是要直接在此磁碟上執行 Windows (Windows To Go)。"
################################################################################
@ -3739,7 +3739,6 @@ t IDNO "Nej"
# Log dialog
g IDD_LOG
t IDD_LOG "Log"
t IDC_LOG_CLEAR "Slet"
t IDC_LOG_SAVE "Gem"
t IDCANCEL "Luk"
@ -4023,7 +4022,7 @@ t MSG_202 "Scanner image..."
t MSG_203 "Fejl opstod ved scanning af image"
t MSG_204 "Forældet %s fundet"
t MSG_205 "ISO-image: %s"
t MSG_206 "Manglende %s fil
t MSG_206 "Manglende %s fil"
t MSG_207 "Ny disk"
t MSG_208 "%d enhed fundet"
t MSG_209 "%d enheder fundet"
@ -5465,7 +5464,6 @@ t IDYES "Ja"
t IDNO "Nein"
g IDD_LOG
t IDD_LOG "Log"
t IDC_LOG_SAVE "Speichern"
t IDC_LOG_CLEAR "Löschen"
t IDCANCEL "Schließen"
@ -6071,7 +6069,7 @@ t MSG_109 "0x%02X (Δίσκος %d)"
t MSG_110 "Το MS-DOS δεν μπορεί να κάνει εκκίνηση από ένα δίσκο χρησιμοποιώντας μέγεθος συμπλέγματος 64 kilobyte.\n"
"Παρακαλώ αλλάξτε το μέγεθος συμπλέγματος ή χρησιμοποιήστε το FreeDOS."
t MSG_111 "Μη συμβατό μέγεθος συμπλέγματος"
t MSG_112 "Η διαμόρφωση μεγάλων τόμων UDF ίσως διαρκέσει αρκετά." Ο χρόνος διαμόρφωσης, στις ταχύτητες του USB 2.0 "
t MSG_112 "Η διαμόρφωση μεγάλων τόμων UDF ίσως διαρκέσει αρκετά. Ο χρόνος διαμόρφωσης, στις ταχύτητες του USB 2.0 "
"είναι %d:%02d. Κατά την διάρκεια της διαμόρφωσης η μπάρα προόδου θα είναι στατική. Παρακαλώ περιμένετε!"
t MSG_113 "Mεγάλος τόμος UDF"
t MSG_114 "Αυτό το είδωλο χρησιμοποιεί το Syslinux %s%s παρόλα αυτά η εφαρμογή(Rufus) εμπεριέχει μόνο τα αρχεία εγκατάστασης του "
@ -6261,7 +6259,7 @@ t MSG_281 "(Παρακαλώ επιλέξτε κάποιο είδωλο)"
t MSG_282 "Κλείδωμα μονάδας USB"
t MSG_283 "Μη έγκυρη ψηφιακή υπογραφή"
t MSG_284 "Το εκτελέσιμο αρχείο που κατεβάσατε δεν περιλαμβάνει ψηφιακή υπογραφή."
τ MSG_285 "Το εκτελέσιμο αρχείο που κατεβάσατε έχει υπογραφτεί από τον/την '%s'.\nΑύτη η υπογραφή δεν "
t MSG_285 "Το εκτελέσιμο αρχείο που κατεβάσατε έχει υπογραφτεί από τον/την '%s'.\nΑύτη η υπογραφή δεν "
"αναγνωρίζεται από το Rufus. Ενδεχομένως να υπάρχει συσχέτιση με κάποια κακόβουλη προσπάθεια...\n"
"Είστε σίγουροι ότι θέλετε να εκτελέσετε αυτό το αρχείο?"
t MSG_286 "Άδειασμα δίσκου: %0.1f%% ολοκληρώθηκε"
@ -6721,9 +6719,9 @@ t MSG_290 "מצב מיון קבצים באינדקס"
t MSG_291 "בחר/י/י גרסה"
t MSG_292 "נא לבחור גרסת windows להתקנה:"
t MSG_293 "גירסת Windows לא נתמכת"
t MSG_294 "גרסת ה windows הזו לא נתמכת יותר ע"י רופוס."
t MSG_294 "גרסת ה windows הזו לא נתמכת יותר ע י רופוס."
t MSG_295 "אזהרה: גרסה לא רשמית"
t MSG_296 "גרסה זו של רופוס לא נוצרה ע"י מפתחה הרשמי. \n\nהאם את/ה בטוח/ה שברצונך להריץ אותה?"
t MSG_296 "גרסה זו של רופוס לא נוצרה ע י מפתחה הרשמי. \n\nהאם את/ה בטוח/ה שברצונך להריץ אותה?"
t MSG_297 "קובץ ISO קטוע זוהה"
t MSG_298 "קובץ ה ISO שבחרת לא מתאים לגודלו המוצהר: מידע בגודל של כ %s חסר!\n\nאםהורדת "
"את הקובץ הזה מהאינטרנט, את/ה צריכ/ה להוריד אותו שוב ולוודא שה checksum שלו ולוודאשביקורת ה MD5 או SHA מתאימים "
@ -7200,7 +7198,6 @@ t IDNO "Tidak"
# Log dialog
g IDD_LOG
t IDD_LOG "Log"
t IDC_LOG_CLEAR "Bersihkan"
t IDC_LOG_SAVE "Simpan"
t IDCANCEL "Tutup"
@ -9881,7 +9878,6 @@ t IDNO "Tidak"
# Log dialog
g IDD_LOG
t IDD_LOG "Log"
t IDC_LOG_CLEAR "Bersihkan"
t IDC_LOG_SAVE "Simpan"
t IDCANCEL "Tutup"
@ -10531,7 +10527,7 @@ t MSG_121 "Vis %s"
t MSG_122 "Skjul %s"
# Tooltips
# Partition Scheme and Target Type
t MSG_150 ""Datamaskin typen du planlegger å bruke denne oppstartbare stasjonen med. Det er ditt ansvar å avgjøre om"
t MSG_150 "Datamaskin typen du planlegger å bruke denne oppstartbare stasjonen med. Det er ditt ansvar å avgjøre om "
"målet ditt er av BIOS eller UEFI-typen før du begynner å lage stasjonen, da det kan mislykkes å starte opp ellers."
t MSG_151 "'UEFI-CSM' betyr at enheten bare starter opp i BIOS-emuleringsmodus (også kjent som 'Legacy Mode') under UEFI, og ikke i innebygde UEFI-modus."
t MSG_152 "'ikke-CSM' betyr at enheten bare starter opp i innebygde UEFI-modus, og ikke i BIOS-emuleringsmodus (også kjent som 'Legacy Mode')."
@ -11296,7 +11292,6 @@ t IDNO "Nie"
# Log dialog
g IDD_LOG
t IDD_LOG "Log"
t IDC_LOG_CLEAR "Wyczyść"
t IDC_LOG_SAVE "Zapisz"
t IDCANCEL "Zamknij"
@ -12513,7 +12508,7 @@ t MSG_189 "Esta imagem ISO não é compatível com o sistema de ficheiros seleci
t MSG_190 "Detetada unidade incompatível"
# See MSG_235 for where the 2 messages below are being used:
t MSG_191 "Escrita"
t MSG_192 "Leitura""
t MSG_192 "Leitura"
t MSG_193 "Transferido %s"
t MSG_194 "Não é possível transferir %s"
# eg. "Using embedded version of Grub2 file(s)"
@ -12624,7 +12619,7 @@ t MSG_275 "A imagem selecionada é uma imagem 'ISOHybrid'. Isto significa que po
"No entanto, se existirem erros durante o arranque, pode tentar escrever no modo %s.\n\n"
"Selecione o modo que realmente pretende para escrever esta imagem:"
t MSG_276 "Escrever no modo %s (Recomendado)"
t MSG_277 "Escrever no modo %s
t MSG_277 "Escrever no modo %s"
t MSG_279 "Não inicializável"
t MSG_280 "Disco ou imagem ISO"
t MSG_281 "%s (Por favor, selecione)"
@ -14386,8 +14381,8 @@ t MSG_277 "Zápis v režime %s"
t MSG_279 "Nie je možné bootovať"
t MSG_280 "Výber obrazu"
t MSG_281 "(Vyberte obraz)"
t MSG_282 "Uzamknutie USB zariadenia
t MSG_283 "Neplatný podpis
t MSG_282 "Uzamknutie USB zariadenia"
t MSG_283 "Neplatný podpis"
t MSG_284 "Stiahnutému inštalátoru chýba digitálny podpis."
t MSG_285 "Stiahnutý inštalátor podpísal '%s'.\nTento podpis nebol rozoznaný a môže znamenať "
"nejakú formu škodlivej aktivity...\nSte si istý, že chcete spustiť tento súbor?"
@ -15719,7 +15714,7 @@ t MSG_297 "Ej komplett ISO-fil"
t MSG_298 "ISO-filen du har valt matchar inte den angivna storleken: %s av data saknas!\n\nOm du har hämtat den här filen från internet, "
"prova då med att ladda ner filen igen och verifiera att checksumman MD5 eller SHA stämmer överens med den officiella filen.\n\n"
"Tips: Du kan beräkna MD5 eller SHA i Rufus genom att klicka på knappen '#'."
t MSG_299 "Valideringfel av tidsstämpeln
t MSG_299 "Valideringfel av tidsstämpeln"
t MSG_300 "Rufus kunde inte validera att tidsstämpeln på den nerladdade uppdateringen är nyare än den gamla.\n\n"
"För att förhindra potentiella angreppsscenarier, har uppdateringsprocessen avslutats och "
"den nerladdade filen har tagits bort. Kontrollera loggen för mer information."
@ -15783,7 +15778,6 @@ t IDNO "ไม่ใช่"
# Log dialog
g IDD_LOG
t IDD_LOG "Log"
t IDC_LOG_CLEAR "ล้าง"
t IDC_LOG_SAVE "บันทึก"
t IDCANCEL "ปิด"
@ -16194,7 +16188,7 @@ t MSG_298 "อิมเมจ ISO ที่คุณเลือกมีคุ
"อินเทอร์เน็ต กรุณาดาวน์โหลดไฟล์อีกครั้ง และตรวจสอบว่าไฟล์นั้นมี MD5 หรือ SHA checksums ตรงกับไฟล์จากผู้ผลิต\n\nโปรดจำไว้ว่า"
"คุณสามารถตรวจสอบ checksum ของไฟล์ดังกล่าวได้จากโปรแกรม Rufus โดยกดปุ่ม '#'"
t MSG_299 "การตรวจสอบ Timestamp ผิดพลาด"
t MSG 300 "Rufus ไม่สามารถยืนยันความถูกต้องของ Timestamp ของโปรแกรมปรับรุ่นที่เพิ่งดาวน์โหลดมาว่าใหม่กว่า"
t MSG_300 "Rufus ไม่สามารถยืนยันความถูกต้องของ Timestamp ของโปรแกรมปรับรุ่นที่เพิ่งดาวน์โหลดมาว่าใหม่กว่า"
"รุ่นที่กำลังใช้อยู่ในปัจจุบัน.\n\nเพื่อป้องกันความเป็นไปได้ที่จะถูกโจมตี การปรับรุ่นได้ถูกยกเลิกและลบทิ้งไป"
"กรุณาดู Log เพื่ออ่านรายละเอียดเพิ่มเติม"
t MSG_301 "แสดงการตั้งค่าของโปรแกรม"

View file

@ -0,0 +1,181 @@
#! /usr/bin/env python3
# -*- coding=utf-8 -*-
# LIMITATIONS
# this script was written as fast as possbile so it is broken/minimalistic:
# it assumes the first language in rufus.loc in English
# written for 1.0.23, things may have changes since then
# horrible code below
# in multiline messages checks only first one if is the same as in English (should be enough for now)
import sys
# regex
import re
# splitting by "quotes"
import shlex
# pretty print for debug
import pprint
# global variables, I'm no python expert so I'll just dump everything here
languages = []
unavailable = []
untranslated = []
version = "0.0.0"
ignored_messages = ['IDOK', 'MSG_020', 'MSG_021', 'MSG_022', 'MSG_023', 'MSG_024', 'MSG_025', 'MSG_026', 'MSG_027', 'MSG_028', 'MSG_118']
class Language:
code = "xx-XX"
name = "None"
version = "0.0.0"
base = "en-US"
groups = {}
#{ "group" => { "MNEMONIC => "transl" }, group2 = (...) }
def __init__(self):
self.groups = {}
def get_current_group(self):
if len(self.groups) > 0:
return list(self.groups.keys())[len(self.groups)-1]
else:
return "none"
def get_current_message(self):
current_group = self.get_current_group()
if len(self.groups[current_group]) > 0:
return list(self.groups[current_group].keys())[len(self.groups[current_group])-1]
else:
return "none"
def print_no_new(data):
print(data, end="")
def load_languages():
print_no_new("loading rufus.loc file...\t")
sys.stdout.flush()
#load file
lines = [line.strip() for line in open("rufus.loc", "r", encoding="utf8")]
# remove comments
#TODO properly remove comments, now it'll break messages with "#" in them, I just assumes there aren't any
#lines = [re.sub(re.compile("#(.*)?" ) ,"" ,line) for line in lines]
# remove empty lines
#lines = filter(None, lines)
i = -1
exceptions = []
for index, line in enumerate(lines):
try:
if line != "" and line[0] != "#":
if line[0] == "l":
#this is language declaration
i += 1
temp_language = Language()
temp_language.name = shlex.split(line)[2]
temp_language.code = shlex.split(line)[1]
languages.append(temp_language)
# print("current language: "+languages[i].name)
elif line[0] == "v":
#this is language declaration
version = line.split(" ")[1]
languages[i].version = line.split(" ")[1]
elif line[0] == "b":
languages[i].base = shlex.split(line)[1]
if line != "b \"en-US\"":
print(languages[i].name + " is based on another translation: " + languages[i].base)
elif line[0] == "g":
languages[i].groups[shlex.split(line)[1]] = {}
# print("current group: "+languages[i].get_current_group())
elif line[0] == "t":
pass
try:
temp_translation = shlex.split(line) #errors
except ValueError as err:
exceptions.append(str(err)+" in line "+ str(index+1)+": "+line)
languages[i].groups[languages[i].get_current_group()][temp_translation[1]] = temp_translation[2]
#print("cur transl: "+languages[i].get_current_message())
elif line[0] == "\"":
pass
elif line[0] == "a":
pass #only RTL indication as for now
else:
raise Exception("unknown line "+str(index+1)+ ": "+line)
except Exception as error:
exceptions.append("Error: "+ repr(error))
if len(exceptions) > 0:
print("[WARNING]")
print("\n".join(exceptions))
else:
print("[OK]")
print()
print ("Found " + str(len(languages)) + " languages")
version = languages[0].version
print("Assuming " + version + " is the latest version. Only languages with this version will be checked...")
#comment if you want to check every single language, not only newest versions
languages[:] = [language for language in languages if language.version==version]
print (str(len(languages)) + " languages in " + languages[0].version + " version:")
print ("\n".join(language.name for language in languages))
print()
def check_unavailable():
print_no_new("Checking for possible missing messages...\t")
sys.stdout.flush()
#for groups in english
#every lang
#does group exist
#for strings in groups
#does it exist
for group in languages[0].groups:
for language in languages[1::]:
if group not in language.groups:
unavailable.append("Language " + language.name + " is missing group '" + group + "'")
else:
for string in languages[0].groups[group]:
if string not in language.groups[group] and string not in ignored_messages:
unavailable.append("Language " + language.name + " is missing message '" + string + "'")
# print output
if len(unavailable) > 0:
print("[WARNING]")
print("Possible missing messages:")
print("\n".join(unavailable))
else:
print("[OK]")
print()
def check_untranslated():
print_no_new("Checking for possible untranslated messages...\t")
sys.stdout.flush()
#evyerything but english
#for group
#for string
#transl==english?
for language in languages[1::]:
for group in language.groups:
for string in language.groups[group]:
try:
if language.groups[group][string] == languages[0].groups[group][string] and string not in ignored_messages:
untranslated.append("Language " + language.name + ": message '" + string + "' has the same translation as English")
except KeyError as error:
untranslated.append("Language " + language.name + ": message '" + string + "' doesn't exist in English")
# print output
if len(untranslated) > 0:
print("[WARNING]")
print("Possible untranslated messages:")
print("\n".join(untranslated))
else:
print("[OK]")
print()
def main():
print("Rufus translation helper tool, proof of concept/MVP")
load_languages()
#pp = pprint.PrettyPrinter(indent=4)
#pp.pprint(languages[2].groups)
check_unavailable()
check_untranslated()
#load main only in ran as stand-alone script
if __name__ == "__main__":
main()

View file

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 232, 326
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 3.0.1257"
CAPTION "Rufus 3.0.1258"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@ -371,8 +371,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,0,1257,0
PRODUCTVERSION 3,0,1257,0
FILEVERSION 3,0,1258,0
PRODUCTVERSION 3,0,1258,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -389,13 +389,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "3.0.1257"
VALUE "FileVersion", "3.0.1258"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2018 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.0.1257"
VALUE "ProductVersion", "3.0.1258"
END
END
BLOCK "VarFileInfo"