kaputtnik has proposed merging lp:~widelands-dev/widelands/bug-1807701_translate_update_authors into lp:widelands.
Commit message: Add an extra key to get a translatable author-value. Explicit close opened files. Requested reviews: Widelands Developers (widelands-dev) Related bugs: Bug #1807701 in widelands: "Extraneous TRANSLATORS comment" https://bugs.launchpad.net/widelands/+bug/1807701 For more details, see: https://code.launchpad.net/~widelands-dev/widelands/bug-1807701_translate_update_authors/+merge/361401 The main change: Add an optional key 'translate' to data/txts/developers.json and add the translation function (_) to the value(s). Added two new functions for adding a lua key to a table and apply values as a lua array automatically if given. The new functions are only used for the developers, not the translators. Feel free to use them also for the translators. -- Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1807701_translate_update_authors into lp:widelands.
=== modified file 'data/txts/developers.json' --- data/txts/developers.json 2018-10-12 17:15:47 +0000 +++ data/txts/developers.json 2019-01-06 09:43:32 +0000 @@ -18,8 +18,8 @@ "entries":[ { "subheading": "Graphics", - "members":[ - "Chuck Wilder (chuckw)" + "translate":[ + "vacant" ] }, { @@ -392,7 +392,9 @@ "members":[ "Matt Howe (mdhowe)", "Samuel Tilly (eldamar)", - "WorldSavior", + "WorldSavior" + ], + "translate":[ "and many, many more (thank you for everything you've done)" ] } === modified file 'data/txts/developers.lua' --- data/txts/developers.lua 2018-10-26 05:29:19 +0000 +++ data/txts/developers.lua 2019-01-06 09:43:32 +0000 @@ -1,3 +1,3 @@ -- Do not edit this file - it is automatically generated -- by utils/update_authors.py from developers.json. -function developers() return {{heading = _"Chieftains",image = "images/players/genstats_player.png",entries = {{members = {"GunChleoc (Since 2016)","Holger Rapp (SirVer) (2001 – 2016)",},},},},{heading = _"Elders",image = "images/players/genstats_player.png",entries = {{subheading = _"Graphics",members = {"Chuck Wilder (chuckw)",},},{subheading = _"Homepage",members = {"Markus Pfitzner (janus)",},},{subheading = _"Sound",members = {"Jan Bruns (solatis)",},},{subheading = _"Tongues",members = {"GunChleoc",},},},},{heading = _"Coders",image = "images/wui/stats/genstats_nrwares.png",entries = {{members = {"Holger Rapp (SirVer)","Nicolai Hähnle (ixprefect)","Florian Bluemel","Florian Falkner (foldrian)","Florian Weber (Bedouin)","Philipp Engelhard","Stefan Boettner","Tron","Martin Quinson","Raul Ferriz","Willem Jan Palenstijn","Josef Spillner","Christof Petig","Erik Sigra (sigra)","Nanne Wams","Surgery","Andrius R. (knutux)","Jari Hautio (jarih)","Peter Schwanemann (Nasenbaer)","Victor Pelt (Dwarik)","Axel Gehlert (dunkelbrauer)","András Eisenberger (Kiscsirke)","Andi","Timo","Hannes","TimoW","Jens Beyer (Qcumber-some)","Andreas Breitschopp (ab-tools)","Joachim Breitner (nomeata)","Nizamov Shawkat","Carl-Philip Hänsch (carli)","Martin Prussak (martin)","David Allwicher (aber)","Nathan Peters (nathanpeters)","Leif Sandstede (lcsand)","Matthias Horne (shevonar)","Borim (borim)","Angelo Locritani (alocritani)","Gabriel Margiani (gamag)","Anthony J. Bentley (anthonyjbentley)","Peter Waller (iri)","Johannes Ebke (sirius-in4matiker)","Andreas Eriksson","Mark Scott","Teppo Mäenpää","Steven De Herdt (stdh)","Charly Ghislain (cghislai)","Tino Miegel (TinoM)","Tibor Bamhor (tiborb95)","GunChleoc","Ferdinand Thiessen (f-thiessen)","Willy Scheibel (willyscheibel)","Martin Schmidt (mars)","Simon Eilting","Alexander Kartzow (daAlx1)","Łukasz Majcher","Paul Mehrer (meitis)","Miroslav Remák (MiroslavR)","Janosch Peters","Klaus Halfmann (Hasi50)","Philipp Klaus Krause (PkK)","Notabilis","Jukka Pakarinen","Evgeny Kapun","ypopezios","Toni Förster (stonerl)","Arty","Benedikt Straub (Nordfriese)",},},},},{heading = _"Graphicians",image = "images/wui/stats/genstats_nrbuildings.png",entries = {{members = {"Albert Jasiowka","Holger Rapp (SirVer)","Marz","Philipp Engelhard","Yannick Warnier","Delia","Florian Neuerburg","Jerome Rosinski","Mats Olsson","Odin Omdal","Wolfgang Weidner","Andreas Baier","Juri Chomé","Toralf Bethke (bithunter32)","Peter Schwanemann (Nasenbaer)","Alexia Death","Repsa Jih","Geoffroy Schmitlin (Trimard)","Benedikt Freisen (Objpaswriter)","Stefano Guidoni (Ilguido)","Samith Sandanayake (samithdisal)","Chuck Wilder (chuckw)","Astuur","Gerrit Familiegrosskopf (kingcreole)","Florian Angermeier (fraang)","DragonAtma","Benedikt Straub (Nordfriese)",},},},},{heading = _"Musicians",image = "images/wui/overlays/workarea123.png",entries = {{members = {"Kristian","MiddleFinger","Valerio Orlandini (Symbiosis)","Barry van Oudtshoorn (barryvan)","Jan Bruns (Solatis)","Nikola Whallon (Saturn)","Joshua O'Leary (Joshun)","Klaus Halfmann (Hasi50)","Stuart Marshall",},},},},{heading = _"Sound Effects",image = "images/wui/overlays/workarea123.png",entries = {{members = {"Stefan de Konik","Peter Schwanemann (Nasenbaer)","Stephan","Adam Piggott (_aD)","Stanisław Gackowski (Soeb)","Tada",},},},},{heading = _"Maps and Missions",image = "images/wui/stats/genstats_landsize.png",entries = {{members = {"Michal Szopa (Winterwind)","Jan-Henrik Kluth (Isch)","Peter Schwanemann (Nasenbaer)","Sven (deviant)","Tuxlands","Kamil Wilczek (Another Barbarian)","Tarvo Reim (Tarrei)","Manuel Holzmeier (Quappo)","ivh","Hanna Podewski (kristin)","Teppo Mäenpää","fk","Einstein13","Jenia","Robnick","wl-zocker","king of nowhere","kaputtnik","Stephan Lutz (hessenfarmer)","Benedikt Straub (Nordfriese)",},},},},{heading = _"Campaign Story",image = "images/ui_basic/ls_wlmap.png",entries = {{subheading = _"Barbarians",members = {"Bastian Rapp","Alexander Kahl (wolfpac)","Peter Schwanemann (Nasenbaer)",},},{subheading = _"Empire",members = {"Peter Schwanemann (Nasenbaer)","Stephan Lutz (hessenfarmer)",},},{subheading = _"Atlanteans",members = {"Holger Rapp (SirVer)","Peter Schwanemann (Nasenbaer)",},},{subheading = _"Frisians",members = {"Benedikt Straub (Nordfriese)",},},},},{heading = _"Packagers",image = "images/wui/stats/genstats_productivity.png",entries = {{subheading = _"Debian Linux",members = {"Martin Quinson",},},{subheading = _"Fedora Linux",members = {"Karol Trzcionka","Jochen Wiedmann",},},{subheading = _"Mandriva Linux",members = {"Emmanuel Andry (eandry)",},},{subheading = _"FreeBSD",members = {"Bartosz Fabianowski",},},{subheading = _"Mac OS X",members = {"Holger Rapp (SirVer)","Philipp Engelhard","Pierre Salagnac (Tarou)","Wolf St. Kappesser","David Allwicher (aber)","Toni Förster (stonerl)",},},{subheading = _"Windows",members = {"Tino Miegel (TinoM)","Alexander Kahl (Wolfpac)","Geodomus","Jari Hautio",},},{subheading = _"ZetaOS",members = {"BeSman",},},},},{heading = _"Homepage",image = "images/logos/WL-Editor-16.png",entries = {{subheading = _"Homepage Coders",members = {"Holger Rapp (SirVer)","Stanislaw Gackowski (Soeb)","Markus Pfitzner (janus)","Tobi","kaputtnik",},},{subheading = _"Documentation, Help and Wiki",members = {"Erik Sigra (sigra)","Florian Falkner (foldrian)","Florian Weber (bedouin)","Nicolai Haehnle","Holger Rapp (SirVer)","Johannes (nuefke)","Alexander Kahl (wolfpac)","Stanislaw Gackowski (Soeb)","Hanna Podewski (kristin)","king of nowhere","GunChleoc",},},},},{heading = _"Former Elders",image = "images/players/genstats_player.png",entries = {{subheading = _"Graphics",members = {"Salamander","Alexia Death (death)",},},{subheading = _"Homepage",members = {"holymoly","Stuart Eglington (DaaL1973)","Jon Harris (jonsjava)",},},{subheading = _"Sound",members = {"Yannick Warnier",},},{subheading = _"Translation",members = {"Peter Schwanemann (Nasenbaer)","Philipp Niemann (Azagtoth)",},},},},{heading = _"Other",image = "images/wui/stats/genstats_landsize.png",entries = {{members = {"Matt Howe (mdhowe)","Samuel Tilly (eldamar)","WorldSavior","and many, many more (thank you for everything you've done)",},},},},} end +function developers() return {{heading = _"Chieftains",image = "images/players/genstats_player.png",entries = {{members = {"GunChleoc (Since 2016)","Holger Rapp (SirVer) (2001 – 2016)",},},},},{heading = _"Elders",image = "images/players/genstats_player.png",entries = {{subheading = _"Graphics",members = {_"vacant",},},{subheading = _"Homepage",members = {"Markus Pfitzner (janus)",},},{subheading = _"Sound",members = {"Jan Bruns (solatis)",},},{subheading = _"Tongues",members = {"GunChleoc",},},},},{heading = _"Coders",image = "images/wui/stats/genstats_nrwares.png",entries = {{members = {"Holger Rapp (SirVer)","Nicolai Hähnle (ixprefect)","Florian Bluemel","Florian Falkner (foldrian)","Florian Weber (Bedouin)","Philipp Engelhard","Stefan Boettner","Tron","Martin Quinson","Raul Ferriz","Willem Jan Palenstijn","Josef Spillner","Christof Petig","Erik Sigra (sigra)","Nanne Wams","Surgery","Andrius R. (knutux)","Jari Hautio (jarih)","Peter Schwanemann (Nasenbaer)","Victor Pelt (Dwarik)","Axel Gehlert (dunkelbrauer)","András Eisenberger (Kiscsirke)","Andi","Timo","Hannes","TimoW","Jens Beyer (Qcumber-some)","Andreas Breitschopp (ab-tools)","Joachim Breitner (nomeata)","Nizamov Shawkat","Carl-Philip Hänsch (carli)","Martin Prussak (martin)","David Allwicher (aber)","Nathan Peters (nathanpeters)","Leif Sandstede (lcsand)","Matthias Horne (shevonar)","Borim (borim)","Angelo Locritani (alocritani)","Gabriel Margiani (gamag)","Anthony J. Bentley (anthonyjbentley)","Peter Waller (iri)","Johannes Ebke (sirius-in4matiker)","Andreas Eriksson","Mark Scott","Teppo Mäenpää","Steven De Herdt (stdh)","Charly Ghislain (cghislai)","Tino Miegel (TinoM)","Tibor Bamhor (tiborb95)","GunChleoc","Ferdinand Thiessen (f-thiessen)","Willy Scheibel (willyscheibel)","Martin Schmidt (mars)","Simon Eilting","Alexander Kartzow (daAlx1)","Łukasz Majcher","Paul Mehrer (meitis)","Miroslav Remák (MiroslavR)","Janosch Peters","Klaus Halfmann (Hasi50)","Philipp Klaus Krause (PkK)","Notabilis","Jukka Pakarinen","Evgeny Kapun","ypopezios","Toni Förster (stonerl)","Arty","Benedikt Straub (Nordfriese)",},},},},{heading = _"Graphicians",image = "images/wui/stats/genstats_nrbuildings.png",entries = {{members = {"Albert Jasiowka","Holger Rapp (SirVer)","Marz","Philipp Engelhard","Yannick Warnier","Delia","Florian Neuerburg","Jerome Rosinski","Mats Olsson","Odin Omdal","Wolfgang Weidner","Andreas Baier","Juri Chomé","Toralf Bethke (bithunter32)","Peter Schwanemann (Nasenbaer)","Alexia Death","Repsa Jih","Geoffroy Schmitlin (Trimard)","Benedikt Freisen (Objpaswriter)","Stefano Guidoni (Ilguido)","Samith Sandanayake (samithdisal)","Chuck Wilder (chuckw)","Astuur","Gerrit Familiegrosskopf (kingcreole)","Florian Angermeier (fraang)","DragonAtma","Benedikt Straub (Nordfriese)",},},},},{heading = _"Musicians",image = "images/wui/overlays/workarea123.png",entries = {{members = {"Kristian","MiddleFinger","Valerio Orlandini (Symbiosis)","Barry van Oudtshoorn (barryvan)","Jan Bruns (Solatis)","Nikola Whallon (Saturn)","Joshua O'Leary (Joshun)","Klaus Halfmann (Hasi50)","Stuart Marshall",},},},},{heading = _"Sound Effects",image = "images/wui/overlays/workarea123.png",entries = {{members = {"Stefan de Konik","Peter Schwanemann (Nasenbaer)","Stephan","Adam Piggott (_aD)","Stanisław Gackowski (Soeb)","Tada",},},},},{heading = _"Maps and Missions",image = "images/wui/stats/genstats_landsize.png",entries = {{members = {"Michal Szopa (Winterwind)","Jan-Henrik Kluth (Isch)","Peter Schwanemann (Nasenbaer)","Sven (deviant)","Tuxlands","Kamil Wilczek (Another Barbarian)","Tarvo Reim (Tarrei)","Manuel Holzmeier (Quappo)","ivh","Hanna Podewski (kristin)","Teppo Mäenpää","fk","Einstein13","Jenia","Robnick","wl-zocker","king of nowhere","kaputtnik","Stephan Lutz (hessenfarmer)","Benedikt Straub (Nordfriese)",},},},},{heading = _"Campaign Story",image = "images/ui_basic/ls_wlmap.png",entries = {{subheading = _"Barbarians",members = {"Bastian Rapp","Alexander Kahl (wolfpac)","Peter Schwanemann (Nasenbaer)",},},{subheading = _"Empire",members = {"Peter Schwanemann (Nasenbaer)","Stephan Lutz (hessenfarmer)",},},{subheading = _"Atlanteans",members = {"Holger Rapp (SirVer)","Peter Schwanemann (Nasenbaer)",},},{subheading = _"Frisians",members = {"Benedikt Straub (Nordfriese)",},},},},{heading = _"Packagers",image = "images/wui/stats/genstats_productivity.png",entries = {{subheading = _"Debian Linux",members = {"Martin Quinson",},},{subheading = _"Fedora Linux",members = {"Karol Trzcionka","Jochen Wiedmann",},},{subheading = _"Mandriva Linux",members = {"Emmanuel Andry (eandry)",},},{subheading = _"FreeBSD",members = {"Bartosz Fabianowski",},},{subheading = _"Mac OS X",members = {"Holger Rapp (SirVer)","Philipp Engelhard","Pierre Salagnac (Tarou)","Wolf St. Kappesser","David Allwicher (aber)","Toni Förster (stonerl)",},},{subheading = _"Windows",members = {"Tino Miegel (TinoM)","Alexander Kahl (Wolfpac)","Geodomus","Jari Hautio",},},{subheading = _"ZetaOS",members = {"BeSman",},},},},{heading = _"Homepage",image = "images/logos/WL-Editor-16.png",entries = {{subheading = _"Homepage Coders",members = {"Holger Rapp (SirVer)","Stanislaw Gackowski (Soeb)","Markus Pfitzner (janus)","Tobi","kaputtnik",},},{subheading = _"Documentation, Help and Wiki",members = {"Erik Sigra (sigra)","Florian Falkner (foldrian)","Florian Weber (bedouin)","Nicolai Haehnle","Holger Rapp (SirVer)","Johannes (nuefke)","Alexander Kahl (wolfpac)","Stanislaw Gackowski (Soeb)","Hanna Podewski (kristin)","king of nowhere","GunChleoc",},},},},{heading = _"Former Elders",image = "images/players/genstats_player.png",entries = {{subheading = _"Graphics",members = {"Salamander","Alexia Death (death)",},},{subheading = _"Homepage",members = {"holymoly","Stuart Eglington (DaaL1973)","Jon Harris (jonsjava)",},},{subheading = _"Sound",members = {"Yannick Warnier",},},{subheading = _"Translation",members = {"Peter Schwanemann (Nasenbaer)","Philipp Niemann (Azagtoth)",},},},},{heading = _"Other",image = "images/wui/stats/genstats_landsize.png",entries = {{members = {"Matt Howe (mdhowe)","Samuel Tilly (eldamar)","WorldSavior",_"and many, many more (thank you for everything you've done)",},},},},} end === modified file 'utils/update_authors.py' --- utils/update_authors.py 2016-12-03 16:08:18 +0000 +++ utils/update_authors.py 2019-01-06 09:43:32 +0000 @@ -13,6 +13,53 @@ # and writes the translator and developer credits to ./txts/developers.lua # The locale information is written to ../data/i18n/locales.lua. + +def add_lua_array(values): + """Creates an array.""" + + text = '{' + for value in values: + if value.startswith('_"'): + # a translation marker has already been added + text += value + else: + text += '"' + value + '",' + text += '},' + return text + + +def add_lua_table_key(key, value=None, **kwrds): + """Adds a key to a table. + + Surrounding brackets of the table have to be applied manually. + If given, the value(s) is/are applied also to the key. + + Known kwrds: 'transl', if true a translation marker is added + """ + + transl = kwrds.get('transl', False) + if key == '': + print("At least a key must be given!") + sys.exit(1) + + if value == None: + # We have only a key, which in general shouldn't be translated + return key + ' = ' + + else: + # A value is present + if transl: + return key + ' = _"' + value + '",' + + if isinstance(value, list): + # To get translations, apply '_"foo"' manually to the list + return key + ' = ' + add_lua_array(value) + else: + return key + ' = "' + value + '",' + + return '' + + base_path = os.path.abspath(os.path.join( os.path.dirname(__file__), os.path.pardir)) @@ -103,6 +150,7 @@ base_path + '/data/i18n') + '/' + dest_filename dest_file = codecs.open(dest_filepath, encoding='utf-8', mode='w') dest_file.write(lua_locales) +dest_file.close() print('Writing translators\n') dest_filename = 'translators_data.lua' @@ -110,6 +158,7 @@ base_path + '/data/txts') + '/' + dest_filename dest_file = codecs.open(dest_filepath, encoding='utf-8', mode='w') dest_file.write(lua_translators) +dest_file.close() print('Reading developers from JSON') source_path = os.path.normpath(base_path + '/data/txts') @@ -120,6 +169,7 @@ source_file = open(source_path + '/developers.json', 'r') developers = json.load(source_file)['developers'] +source_file.close() lua_string = """-- Do not edit this file - it is automatically generated -- by utils/update_authors.py from developers.json. @@ -127,30 +177,31 @@ lua_string += 'function developers() return {' # developers for category in developers: - print('- Adding ' + category['heading']) - if category['heading'] != 'Translators': # Unused hook for adding translators + if 'heading' in category and category['heading'] != 'Translators': # Unused hook for adding translators + print('- Adding ' + category['heading']) lua_string += '{' # category - lua_string += 'heading = _"' + \ - category['heading'] + '",' # This will be localized - lua_string += 'image = "' + category['image'] + '",' - - lua_string += 'entries = {' # entries - + lua_string += add_lua_table_key('heading', category['heading'], transl=True) + lua_string += add_lua_table_key('image', category['image']) + + lua_string += add_lua_table_key('entries') + lua_string += '{' # entries for subcategory in category['entries']: lua_string += '{' # entry if 'subheading' in subcategory: - lua_string += 'subheading = _"' + \ - subcategory['subheading'] + '",' # This will be localized - - lua_string += 'members = {' # members - for member in subcategory['members']: - lua_string += '"' + member + '",' - lua_string += '},' # members - + lua_string += add_lua_table_key('subheading', subcategory['subheading'], transl=True) + members = [] + if 'members' in subcategory: + for m in subcategory['members']: + members.append(m) + if 'translate' in subcategory: + for m in subcategory['translate']: + members.append('_"' + m + '",') + lua_string += add_lua_table_key('members', members) + lua_string += '},' # entry lua_string += '},' # entries - lua_string += '},' # category + lua_string += '} end\n' # developers print('Writing developers') @@ -158,4 +209,5 @@ dest_filepath = source_path + '/' + dest_filename dest_file = codecs.open(dest_filepath, encoding='utf-8', mode='w') dest_file.write(lua_string) +dest_file.close() print('Done.')
_______________________________________________ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp