69 w.write(POT_file) |
69 w.write(POT_file) |
70 |
70 |
71 def GetPoFiles(dirpath): |
71 def GetPoFiles(dirpath): |
72 po_files = [fname for fname in os.listdir(dirpath) if fname.endswith(".po")] |
72 po_files = [fname for fname in os.listdir(dirpath) if fname.endswith(".po")] |
73 po_files.sort() |
73 po_files.sort() |
74 return po_files |
74 return [(po_fname[:-3],os.path.join(dirpath, po_fname)) for po_fname in po_files] |
75 |
75 |
76 def ReadTranslations(dirpath): |
76 def ReadTranslations(dirpath): |
77 """ Read all PO files from a directory and return a list of (langcode, translation_dict) tuples """ |
77 """ Read all PO files from a directory and return a list of (langcode, translation_dict) tuples """ |
78 |
78 |
79 po_files = GetPoFiles(dirpath) |
|
80 |
|
81 translations = [] |
79 translations = [] |
82 for po_fname in po_files: |
80 for translation_name, po_path in GetPoFiles(dirpath): |
83 r = POReader() |
81 r = POReader() |
84 with open(os.path.join(dirpath, po_fname), 'r') as PO_file: |
82 with open(po_path, 'r') as PO_file: |
85 r.read(PO_file) |
83 r.read(PO_file) |
86 translations.append((po_fname[:-3], r.get_messages())) |
84 translations.append((translation_name, r.get_messages())) |
87 return translations |
85 return translations |
88 |
86 |
89 def MatchTranslations(translations, messages, errcallback): |
87 def MatchTranslations(translations, messages, errcallback): |
90 """ |
88 """ |
91 Matches translations against original message catalog, |
89 Matches translations against original message catalog, |