def read_csv(self, filename): file = open(os.path.join(os.path.dirname(__file__), "data", filename), 'r') reader = CSVReader(file, "comma", "utf-8") result = reader.read() file.close() return result
def spreadsheet_import(self, file, lang, dialect, encoding='utf-8'): """Imports translations from a spreadsheet format into the message catalog.""" from Products.NaayaCore.managers.import_export import CSVReader # read translations from spreadsheet file translations = CSVReader(file, dialect, encoding) translations = translations.read()[ 0] #result.read() is ([{id, source, target}], '') # iterate translations for translation in translations: #import only translated messages if translation['target'] != '': self._catalog.edit_message( translation['source'].decode(encoding), lang, translation['target'].decode(encoding))