mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
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.
This commit is contained in:
parent
684f230d66
commit
63dac87a40
2 changed files with 13 additions and 6 deletions
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue