From e7519bce75896142cf3899564ef6b1b777be6869 Mon Sep 17 00:00:00 2001 From: Louis Date: Sat, 14 Jun 2014 15:35:37 +0200 Subject: [PATCH] [WIP] Song languages work --- songbook_core/content/song.py | 6 +++++- songbook_core/data/templates/songs.tex | 7 +++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/songbook_core/content/song.py b/songbook_core/content/song.py index fc371eaf..b2548933 100644 --- a/songbook_core/content/song.py +++ b/songbook_core/content/song.py @@ -34,6 +34,8 @@ class SongRenderer(Content, Song): return r'\input{{{}}}'.format(path) def parse(keyword, config, *arguments): + if 'languages' not in config: + config['languages'] = set() songlist = [] if not arguments: arguments = [ @@ -52,7 +54,9 @@ def parse(keyword, config, *arguments): for songdir in [os.path.join(d, 'songs') for d in config['datadir']]: for filename in glob.iglob(os.path.join(songdir, elem)): LOGGER.debug('Parsing file "{}"…'.format(filename)) - songlist.append(SongRenderer(filename)) + song = SongRenderer(filename) + songlist.append(song) + config["languages"].update(song.languages) if len(songlist) > before: break if len(songlist) == before: diff --git a/songbook_core/data/templates/songs.tex b/songbook_core/data/templates/songs.tex index 8c9b8066..f81db077 100644 --- a/songbook_core/data/templates/songs.tex +++ b/songbook_core/data/templates/songs.tex @@ -70,10 +70,9 @@ (* block songbookpreambule *) (( super() )) - %!TODO - %!(* for lang in content.languages() *) - %!\PassOptionsToPackage{((lang))}{babel} - %!(* endfor *) + (* for lang in languages *) + \PassOptionsToPackage{((lang))}{babel} + (* endfor *) \usepackage[((lang))]{babel} \lang{((lang))}