diff --git a/dist/clementine.desktop b/dist/clementine.desktop index 6498de8fc..3b70bfb0f 100755 --- a/dist/clementine.desktop +++ b/dist/clementine.desktop @@ -19,23 +19,234 @@ X-Ayatana-Desktop-Shortcuts=Play;Pause;Stop;Previous;Next; Name=Play Exec=clementine --play TargetEnvironment=Unity +Name[af]=Speel +Name[be]=Прайграць +Name[bg]=Възпроизвеждане +Name[br]=Lenn +Name[ca]=Reprodueix +Name[cs]=Přehrát +Name[da]=Afspil +Name[de]=Wiedergabe +Name[el]=Αναπαραγωγή +Name[es]=Reproducir +Name[es_AR]=Reproducir +Name[et]=Mängi +Name[eu]=Erreproduzitu +Name[fa]=پخش +Name[fi]=Toista +Name[fr]=Lecture +Name[ga]=Seinn +Name[gl]=Reproducir +Name[he]=נגינה +Name[hr]=Pokreni reprodukciju +Name[hu]=Lejátszás +Name[it]=Riproduci +Name[ja]=再生 +Name[kk]=Ойнату +Name[lt]=Groti +Name[lv]=Atskaņot +Name[ms]=Mainkan +Name[nb]=Spill +Name[nl]=Afspelen +Name[oc]=Lectura +Name[pl]=Odtwarzaj +Name[pt]=Reproduzir +Name[pt_BR]=Reproduzir +Name[ro]=Redă +Name[ru]=Воспроизвести +Name[sk]=Hrať +Name[sl]=Predvajaj +Name[sr]=Пусти +Name[sv]=Spela upp +Name[tr]=Çal +Name[uk]=Відтворити +Name[vi]=Phát +Name[zh_CN]=播放 +Name[zh_TW]=播放 [Pause Shortcut Group] Name=Pause Exec=clementine --pause TargetEnvironment=Unity +Name[be]=Прыпыніць +Name[bg]=Пауза +Name[br]=Ehan +Name[ca]=Pausa +Name[cs]=Pozastavit +Name[el]=Παύση +Name[es]=Pausar +Name[es_AR]=Pausar +Name[et]=Paus +Name[eu]=Pausarazi +Name[fa]=ایست +Name[fi]=Keskeytä +Name[ga]=Cuir ar sos +Name[gl]=Pausa +Name[he]=השהייה +Name[hr]=Pauza +Name[hu]=Szünet +Name[it]=Pausa +Name[ja]=一時停止 +Name[kk]=Аялдату +Name[ko]=일시중지 +Name[lt]=Pristabdyti +Name[lv]=Pauze +Name[nl]=Pauze +Name[oc]=Pausa +Name[pl]=Pauza +Name[pt]=Pausa +Name[pt_BR]=Pausar +Name[ro]=Pauză +Name[ru]=Приостановить +Name[sk]=Pozastaviť +Name[sl]=Začasno ustavi +Name[sr]=Паузирај +Name[sv]=Gör paus +Name[tr]=Duraklat +Name[uk]=Призупинити +Name[vi]=Tạm dừng +Name[zh_CN]=暂停 +Name[zh_TW]=暫停 [Stop Shortcut Group] Name=Stop Exec=clementine --stop TargetEnvironment=Unity +Name[be]=Спыніць +Name[bg]=Спиране +Name[br]=Paouez +Name[ca]=Atura +Name[cs]=Zastavit +Name[de]=Anhalten +Name[el]=Σταμάτημα +Name[es]=Detener +Name[es_AR]=Detener +Name[et]=Peata +Name[eu]=Gelditu +Name[fa]=ایست +Name[fi]=Pysäytä +Name[ga]=Stad +Name[gl]=Deter +Name[he]=הפסקה +Name[hr]=Zaustavi reprodukciju +Name[hu]=Leállít +Name[it]=Ferma +Name[ja]=停止 +Name[kk]=Тоқтату +Name[ko]=중지 +Name[lt]=Stabdyti +Name[lv]=Apturēt +Name[ms]=Henti +Name[nb]=Stopp +Name[nl]=Stoppen +Name[oc]=Arrestar +Name[pl]=Zatrzymaj +Name[pt]=Parar +Name[pt_BR]=Parar +Name[ro]=Oprește +Name[ru]=Остановить +Name[sk]=Zastaviť +Name[sl]=Zaustavi +Name[sr]=Заустави +Name[sv]=Stoppa +Name[tr]=Durdur +Name[uk]=Зупинити +Name[vi]=Dừng +Name[zh_CN]=停止 +Name[zh_TW]=停止 [Previous Shortcut Group] Name=Previous Exec=clementine --previous TargetEnvironment=Unity +Name[af]=Vorige +Name[be]=Папярэдні +Name[bg]=Предишна +Name[br]=A-raok +Name[ca]=Anterior +Name[cs]=Předchozí +Name[da]=Forrige +Name[de]=Vorheriger +Name[el]=Προηγούμενο +Name[es]=Anterior +Name[es_AR]=Anterior +Name[eu]=Aurrekoa +Name[fa]=پیشین +Name[fi]=Edellinen +Name[fr]=Précédent +Name[ga]=Roimhe +Name[gl]=Anterior +Name[he]=הקודם +Name[hr]=Prijašnje +Name[hu]=Előző +Name[it]=Precedente +Name[ja]=前へ +Name[lt]=Atgal +Name[lv]=Iepriekšējais +Name[nb]=Forrige +Name[nl]=Vorige +Name[pl]=Wstecz +Name[pt]=Anterior +Name[pt_BR]=Anterior +Name[ro]=Precedenta +Name[ru]=Предыдущий +Name[sk]=Predchádzajúca +Name[sl]=Predhodni +Name[sr]=Prethodno +Name[sv]=Föregående +Name[tr]=Önceki +Name[uk]=Попередня +Name[uz]=Oldingi +Name[vi]=Trước +Name[zh_CN]=上一首 +Name[zh_TW]=往前 [Next Shortcut Group] Name=Next Exec=clementine --next TargetEnvironment=Unity +Name[af]=Volgende +Name[be]=Далей +Name[bg]=Следваща +Name[br]=Da-heul +Name[ca]=Següent +Name[cs]=Další +Name[da]=Næste +Name[de]=Weiter +Name[el]=Επόμενο +Name[es]=Siguiente +Name[es_AR]=Siguiente +Name[eu]=Hurrengoa +Name[fa]=پسین +Name[fi]=Seuraava +Name[fr]=Suivant +Name[ga]=Ar aghaidh +Name[gl]=Próximo +Name[he]=הבא +Name[hr]=Sljedeće +Name[hu]=Következő +Name[id]=Berikut +Name[it]=Successivo +Name[ja]=次へ +Name[ko]=다음 +Name[lt]=Toliau +Name[lv]=Uz priekšu +Name[ms]=Seterusnya +Name[nb]=Neste +Name[nl]=Volgende +Name[pl]=Dalej +Name[pt]=Seguinte +Name[pt_BR]=Próximo +Name[ro]=Următoarea +Name[ru]=Дальше +Name[sk]=Ďalšia +Name[sl]=Naslednji +Name[sr]=Sledeće +Name[sv]=Nästa +Name[tr]=İleri +Name[uk]=Наступна +Name[uz]=Keyingi +Name[vi]=Tiếp theo +Name[zh_CN]=下一首 +Name[zh_TW]=下一個 + diff --git a/dist/update_desktop_languages.py b/dist/update_desktop_languages.py new file mode 100644 index 000000000..55c555b26 --- /dev/null +++ b/dist/update_desktop_languages.py @@ -0,0 +1,128 @@ +import codecs +import glob +import logging +import os +import polib +import re + +PO_GLOB = 'src/translations/*.po' +DESKTOP_PATH = 'dist/clementine.desktop' + +class ConfigParser(object): + """ + Better version of the ConfigParser from the stdlib that handles unicode. + """ + + SECTION_RE = re.compile('^\[(.*)\]\s*$') + VALUE_RE = re.compile('^([^\s=]+)\s*=\s*(.*)') + + def __init__(self, encoding='utf-8'): + self._sections = [] + self.encoding = encoding + + def read(self, filename): + with codecs.open(filename, 'r', self.encoding) as handle: + current_section = None + + for line in handle: + match = self.SECTION_RE.match(line) + if match: + current_section = self._add_section(match.group(1)) + continue + + match = self.VALUE_RE.match(line) + if match: + current_section['items'].append( + (match.group(1), match.group(2).strip())) + continue + + def _add_section(self, section_name): + section = { + 'name': section_name, + 'items': [], + } + self._sections.append(section) + return section + + def _find_section(self, section_name): + return [ + section + for section in self._sections + if section['name'] == section_name + ][0] + + def _find_item_value(self, section, key): + return [ + item[1] + for item in section['items'] + if item[0] == key + ][0] + + def sections(self): + return [x['name'] for x in self._sections] + + def get(self, section_name, key): + try: + return self._find_item_value(self._find_section(section_name), key) + except IndexError: + return None + + def set(self, section_name, key, value): + try: + section = self._find_section(section_name) + except IndexError: + section = self._add_section(section_name) + + for index, (existing_key, _existing_value) in enumerate(section['items']): + if existing_key == key: + section['items'][index] = (key, value) + return + + section['items'].append((key, value)) + + def write(self, filename): + with codecs.open(filename, 'w', self.encoding) as handle: + for section in self._sections: + handle.write('[%s]\n' % section['name']) + for key, value in section['items']: + handle.write('%s=%s\n' % (key, value)) + + handle.write('\n') + + +def main(): + logging.basicConfig(level=logging.DEBUG, + format="%(asctime)s %(levelname)-7s %(message)s") + + config_parser = ConfigParser() + config_parser.read(DESKTOP_PATH) + + shortcuts = [ + { + 'section_name': section_name, + 'original': config_parser.get(section_name, 'Name'), + } + for section_name in config_parser.sections() + if section_name.endswith('Shortcut Group') + ] + + for po_filename in glob.glob(PO_GLOB): + language = os.path.splitext(os.path.basename(po_filename))[0] + config_key = 'Name[%s]' % language + po_file = polib.pofile(po_filename) + + logging.info('Reading language %s', po_filename) + + for shortcut in shortcuts: + original = shortcut['original'] + entry = po_file.find(original) + if entry is not None and entry.msgstr and entry.msgstr != original: + logging.info('Setting %s for %s to %s', + config_key, shortcut['section_name'], entry.msgstr) + config_parser.set(shortcut['section_name'], config_key, entry.msgstr) + + config_parser.write(DESKTOP_PATH) + + +if __name__ == '__main__': + main()