diff --git a/patacrep/content/song.py b/patacrep/content/song.py index b44fc7f1..e4aec3ad 100755 --- a/patacrep/content/song.py +++ b/patacrep/content/song.py @@ -92,7 +92,7 @@ def parse(keyword, argument, contentlist, config): config, )) songlist.append(renderer) - config["_languages"].update(renderer.song.languages) + config["_languages"].update(renderer.song.language) if len(songlist) > before: break if len(songlist) == before: diff --git a/patacrep/latex/ast.py b/patacrep/latex/ast.py index c4763ddf..ecfa1a4b 100644 --- a/patacrep/latex/ast.py +++ b/patacrep/latex/ast.py @@ -2,6 +2,8 @@ # pylint: disable=too-few-public-methods +DEFAULT_LANGUAGE = "english" + class AST: """Base class for the tree.""" # pylint: disable=no-init @@ -16,7 +18,7 @@ class AST: parsing. """ cls.metadata = { - '@languages': set(), + '@language': DEFAULT_LANGUAGE, } class Expression(AST): @@ -44,7 +46,7 @@ class Command(AST): self.optional = optional if name == r'\selectlanguage': - self.metadata['@languages'] |= set(self.mandatory) + self.metadata['@language'] = self.mandatory def __str__(self): if self.name in [r'\emph']: diff --git a/patacrep/songs/__init__.py b/patacrep/songs/__init__.py index 297a993e..08205aaa 100644 --- a/patacrep/songs/__init__.py +++ b/patacrep/songs/__init__.py @@ -89,7 +89,7 @@ class Song: "cached", "data", "subpath", - "languages", + "language", "authors", "_filehash", "_version", @@ -184,8 +184,8 @@ class Song: - titles: the list of (raw) titles. This list will be processed to remove prefixes. - - languages: the list of languages used in the song, as languages - recognized by the LaTeX babel package. + - language: the main language of the song, as language recognized by + the LaTeX babel package. - authors: the list of (raw) authors. This list will be processed to 'clean' it (see function :func:`patacrep.authors.processauthors`). - data: song metadata. Used (among others) to sort the songs. diff --git a/patacrep/songs/chordpro/__init__.py b/patacrep/songs/chordpro/__init__.py index 5df4a7b9..591a7354 100644 --- a/patacrep/songs/chordpro/__init__.py +++ b/patacrep/songs/chordpro/__init__.py @@ -38,7 +38,7 @@ class ChordproSong(Song): song = parse_song(song.read(), self.fullpath) self.authors = song.authors self.titles = song.titles - self.languages = song.get_data_argument('language', [self.config['lang']]) + self.language = song.get_data_argument('language', self.config['lang']) self.data = song.meta self.cached = { 'song': song, @@ -49,7 +49,7 @@ class ChordproSong(Song): templatedirs = [] context = { - 'language': self.languages[0], + 'language': self.language, "titles": self.titles, "authors": self.authors, "metadata": self.data, diff --git a/patacrep/songs/chordpro/ast.py b/patacrep/songs/chordpro/ast.py index 18805e9b..526f7d93 100644 --- a/patacrep/songs/chordpro/ast.py +++ b/patacrep/songs/chordpro/ast.py @@ -193,7 +193,6 @@ class Song(AST): "artist": "add_author", "key": "add_key", "define": "add_cumulative", - "language": "add_cumulative", } def __init__(self, filename): diff --git a/patacrep/songs/latex/__init__.py b/patacrep/songs/latex/__init__.py index 6ac54c81..2371c7d9 100644 --- a/patacrep/songs/latex/__init__.py +++ b/patacrep/songs/latex/__init__.py @@ -20,8 +20,8 @@ class LatexSong(Song): self.data = parse_song(song.read(), self.fullpath) self.titles = self.data['@titles'] del self.data['@titles'] - self.languages = self.data['@languages'] - del self.data['@languages'] + self.language = self.data['@language'] + del self.data['@language'] if "by" in self.data: self.authors = [self.data['by']] del self.data['by'] diff --git a/test/test_chordpro/metadata.source b/test/test_chordpro/metadata.source index 65a2359a..514ac2c0 100644 --- a/test/test_chordpro/metadata.source +++ b/test/test_chordpro/metadata.source @@ -4,8 +4,8 @@ {subtitle: Subtitle4} {t: Subtitle2} {st: Subtitle5} -{language: french} {language: english} +{language: french} {by: Author1} {artist: Author2} {album: Album}