def test_only_selected_languages_are_synced(self): fshelpers.create_structure(self.tempdir, { 'foo/bar/locales/bar.pot': fshelpers.asset('empty.pot'), 'foo/bar/locales/de/LC_MESSAGES/bar.po': pohelpers.makepo({ 'label_login': ('Login', 'de original')}), 'foo/bar/locales/fr/LC_MESSAGES/bar.po': pohelpers.makepo({ 'label_login': ('Login', 'fr original')})}) de_pofile = (self.tempdir, 'foo/bar/locales/de/LC_MESSAGES/bar.po') fr_pofile = (self.tempdir, 'foo/bar/locales/fr/LC_MESSAGES/bar.po') spreadsheet = SpreadSheetMock( {'worksheet': [{'package': u'foo', 'domain': u'bar', 'id': u'label_login', 'default': u'Login', 'translations': {u'de': u'Anmelden', u'fr': u'Connecter'}, }]}) download.download(spreadsheet, self.tempdir, worksheet_name='worksheet', languages=['de']) self.assertEquals({'label_login': '******'}, pohelpers.messages(*de_pofile)) self.assertEquals({'label_login': '******'}, pohelpers.messages(*fr_pofile))
def test_download(self): fshelpers.create_structure(self.tempdir, { 'foo/bar/locales/bar.pot': fshelpers.asset('empty.pot'), 'foo/bar/locales/de/LC_MESSAGES/bar.po': pohelpers.makepo({ 'label_login': ('Login', '')})}) pofile = (self.tempdir, 'foo/bar/locales/de/LC_MESSAGES/bar.po') self.assertEquals({'label_login': ''}, pohelpers.messages(*pofile)) spreadsheet = SpreadSheetMock( {'worksheet': [{'package': u'foo', 'domain': u'bar', 'id': u'label_login', 'default': u'Login', 'translations': {u'de': u'Anmelden'}, }, {'package': u'foo', 'domain': u'bar', 'id': u'this_was_removed', 'default': u'Yay', 'translations': {u'de': u'Yay'}, }]}) download.download(spreadsheet, self.tempdir, worksheet_name='worksheet', languages=['de']) self.assertEquals({'label_login': '******'}, pohelpers.messages(*pofile))
def test_download_does_not_empty_existing_translations(self): fshelpers.create_structure(self.tempdir, { 'foo/bar/locales/bar.pot': fshelpers.asset('empty.pot'), 'foo/bar/locales/de/LC_MESSAGES/bar.po': pohelpers.makepo({ 'label_login': ('Login', 'Anmelden')})}) pofile = (self.tempdir, 'foo/bar/locales/de/LC_MESSAGES/bar.po') spreadsheet = SpreadSheetMock( {'worksheet': [{'package': u'foo', 'domain': u'bar', 'id': u'label_login', 'default': u'Login', 'translations': {u'de': u''}, }]}) download.download(spreadsheet, self.tempdir, worksheet_name='worksheet', languages=['de']) self.assertEquals({'label_login': '******'}, pohelpers.messages(*pofile))