diff --git a/patacrep/songs/chordpro/__init__.py b/patacrep/songs/chordpro/__init__.py index 4b95b7b0..e0a4be2e 100644 --- a/patacrep/songs/chordpro/__init__.py +++ b/patacrep/songs/chordpro/__init__.py @@ -35,9 +35,18 @@ class ChordproSong(Song): song = parse_song(song.read(), self.fullpath) self.authors = song.authors self.titles = song.titles - #language and lang are synomyms in the directives - language = song.get_data_argument('language', self.config['lang']) - self.lang = song.get_data_argument('lang', language) + + # Lang inverted priority (last one is preferred): + # config['lang'] + # song.language + # song.lang + self.lang = self.config['lang'] + language = song.get_data_argument('language') + if language: + # self.lang is automatically updated + self.language = language + self.lang = song.get_data_argument('lang', self.lang) + self.data = song.meta self.cached = { 'song': song, diff --git a/patacrep/songs/chordpro/ast.py b/patacrep/songs/chordpro/ast.py index 09a3b226..c0497c48 100644 --- a/patacrep/songs/chordpro/ast.py +++ b/patacrep/songs/chordpro/ast.py @@ -245,7 +245,7 @@ class Song(AST): self.meta[data.keyword] = [] self.meta[data.keyword].append(data) - def get_data_argument(self, keyword, default): + def get_data_argument(self, keyword, default=None): """Return `self.meta[keyword].argument`. Return `default` if `self.meta[keyword]` does not exist. diff --git a/test/test_chordpro/lang.sgc b/test/test_chordpro/lang.sgc new file mode 100644 index 00000000..be2eff89 --- /dev/null +++ b/test/test_chordpro/lang.sgc @@ -0,0 +1 @@ +{lang: fr} \ No newline at end of file diff --git a/test/test_chordpro/lang.source b/test/test_chordpro/lang.source new file mode 100644 index 00000000..ac284b64 --- /dev/null +++ b/test/test_chordpro/lang.source @@ -0,0 +1 @@ +{language: french}