From 63dac87a40e288d2905027519a895d2cab4012c8 Mon Sep 17 00:00:00 2001 From: "Lynn \"Zhorken\" Vaughan" Date: Sun, 1 Jun 2014 11:40:54 -0400 Subject: [PATCH] Dump translations for official languages by default. I don't really like this but ehhhhhhh, the system for prose translations seems to be to keep them in csv/translations/, and I can't figure out how you're supposed to DO that, plus judging by the age of the single file that's in there, that seems to be where translations go to die. --- pokedex/db/load.py | 12 ++++++++---- pokedex/main.py | 7 +++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/pokedex/db/load.py b/pokedex/db/load.py index 01859a2..d968fdb 100644 --- a/pokedex/db/load.py +++ b/pokedex/db/load.py @@ -347,7 +347,7 @@ def load(session, tables=[], directory=None, drop_tables=False, verbose=False, s -def dump(session, tables=[], directory=None, verbose=False, langs=['en']): +def dump(session, tables=[], directory=None, verbose=False, langs=None): """Dumps the contents of a database to a set of CSV files. Probably not useful to anyone besides a developer. @@ -398,12 +398,16 @@ def dump(session, tables=[], directory=None, verbose=False, langs=['en']): columns = [col.name for col in table.columns] - # For name tables, dump rows for official languages, as well as - # for those in `langs`. + # For name tables, always dump rows for official languages, as well as + # for those in `langs` if specified. # For other translation tables, only dump rows for languages in `langs` + # if specified, or for official languages by default. # For non-translation tables, dump all rows. if 'local_language_id' in columns: - if any(col.info.get('official') for col in table.columns): + if langs is None: + def include_row(row): + return languages[row.local_language_id].official + elif any(col.info.get('official') for col in table.columns): def include_row(row): return (languages[row.local_language_id].official or languages[row.local_language_id].identifier in langs) diff --git a/pokedex/main.py b/pokedex/main.py index d10f75e..fd29593 100644 --- a/pokedex/main.py +++ b/pokedex/main.py @@ -111,7 +111,7 @@ def get_csv_directory(options): def command_dump(*args): parser = get_parser(verbose=True) parser.add_option('-d', '--directory', dest='directory', default=None) - parser.add_option('-l', '--langs', dest='langs', default='en', + parser.add_option('-l', '--langs', dest='langs', default=None, help="Comma-separated list of languages to dump all strings for. " "Default is English ('en')") options, tables = parser.parse_args(list(args)) @@ -119,7 +119,10 @@ def command_dump(*args): session = get_session(options) get_csv_directory(options) - langs = [l.strip() for l in options.langs.split(',')] + if options.langs is not None: + langs = [l.strip() for l in options.langs.split(',')] + else: + langs = None pokedex.db.load.dump(session, directory=options.directory, tables=tables,