From 5517667b6d08af9d8f9817b4a5cf6c306ea8d169 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Wed, 10 Feb 2016 15:24:23 +0100 Subject: [PATCH] Add songbook_model locale (description and default) --- patacrep/data/templates/songbook_model.yml | 133 +++++++++++++++------ patacrep/songbook/__main__.py | 11 +- test/test_content/test_content.py | 2 +- test/test_song/test_parser.py | 2 +- test/test_songbook/french.tex.control | 131 ++++++++++++++++++++ test/test_songbook/french.yaml | 5 + 6 files changed, 243 insertions(+), 41 deletions(-) create mode 100644 test/test_songbook/french.tex.control create mode 100644 test/test_songbook/french.yaml diff --git a/patacrep/data/templates/songbook_model.yml b/patacrep/data/templates/songbook_model.yml index fb8722bb..922cbe0f 100644 --- a/patacrep/data/templates/songbook_model.yml +++ b/patacrep/data/templates/songbook_model.yml @@ -79,44 +79,101 @@ schema: contents: //str - type: //nil default: - book: - lang: en - encoding: utf-8 - pictures: yes - template: patacrep.tex - onesongperpage: no + en: + book: + lang: en + encoding: utf-8 + pictures: yes + template: patacrep.tex + onesongperpage: no + + chords: + show: yes + diagramreminder: important + diagrampage: yes + repeatchords: yes + lilypond: no + tablatures: no + instrument: guitar + notation: alphascale - chords: # Options relatives aux accords - show: yes - diagramreminder: important - diagrampage: yes - repeatchords: yes - lilypond: no - tablatures: no - instrument: guitar - notation: alphascale + authors: + separators: + - and + ignore: + - unknown + after: + - by - authors: # Comment sont analysés les auteurs - separators: - - and - ignore: - - unknown - after: - - by + titles: + prefix: + - The + - Le + - La + - "L'" + - A + - Au + - Ces + - De + - Des + - El + - Les + - Ma + - Mon + - Un - titles: # Comment sont analysés les titres - prefix: - - The - - Le - - La - - "L'" - - A - - Au - - Ces - - De - - Des - - El - - Les - - Ma - - Mon - - Un + fr: + chords: + notation: solfedge +description: + en: + book: + lang: "Main language of the songbook" + encoding: "Encoding of the files" + pictures: "Display the album pictures" + template: "Main template to use" + onesongperpage: "Start every song on a new page" + + chords: + show: "Display chords" + diagramreminder: "Display some diagram reminders before the songs" + diagrampage: "Add a diagram page" + repeatchords: "Repeat the chords inside the songs" + lilypond: "Display lilypond scores" + tablatures: "Display tablatures" + instrument: "Instrument for the diagrams" + notation: "Chord notation" + + authors: + separators: "Separator words between artists" + ignore: "Artist names to ignore" + after: "Word preceding artist names" + + titles: + prefix: "Words to ignore at the beginning of song titles for the index" + + en: + book: + lang: "Langue principale" + encoding: "Encodage des fichiers" + pictures: "Afficher les illustrations d'albums" + template: "Template de base" + onesongperpage: "Commencer chaque chant sur une nouvelle page" + + chords: + show: "Afficher les accords" + diagramreminder: "Afficher quelques diagrammes d'accords au début des chants" + diagrampage: "Inclure une page de rappel des accords" + repeatchords: "Répéter l'affichage des accords au sein des chants" + lilypond: "Inclure les partitions lilypond" + tablatures: "Inclure les tablatures" + instrument: "Instrument pour les diagrammes d'accords" + notation: "Notation des accords" + + authors: + separators: "Mots de séparation entre les artistes" + ignore: "Noms d'artistes à ignorer" + after: "Mots précédents les noms d'artistes" + + titles: + prefix: "Préfixes de chants à ignorer dans le classement" diff --git a/patacrep/songbook/__main__.py b/patacrep/songbook/__main__.py index 5ab2c929..d3048d48 100644 --- a/patacrep/songbook/__main__.py +++ b/patacrep/songbook/__main__.py @@ -149,7 +149,16 @@ def main(): sys.exit(1) # Merge the default and user configs - default_songbook = DictOfDict(config_model('default')) + locale_default = config_model('default') + # Initialize with default in english + default_songbook = locale_default.get('en', {}) + default_songbook = DictOfDict(default_songbook) + + if 'lang' in user_songbook.get('book', []): + # Update default with current lang + lang = user_songbook['book']['lang'] + default_songbook.update(locale_default.get(lang, {})) + # Update default with user_songbook default_songbook.update(user_songbook) songbook = dict(default_songbook) diff --git a/test/test_content/test_content.py b/test/test_content/test_content.py index 1bbec7af..d4fae378 100644 --- a/test/test_content/test_content.py +++ b/test/test_content/test_content.py @@ -101,7 +101,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): """Generate the config to process the content""" # Load the default songbook config - config = config_model('default') + config = config_model('default')['en'] datadirpaths = [os.path.join(os.path.dirname(__file__), 'datadir')] diff --git a/test/test_song/test_parser.py b/test/test_song/test_parser.py index 5dacf81d..bef2e83b 100644 --- a/test/test_song/test_parser.py +++ b/test/test_song/test_parser.py @@ -76,7 +76,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): """Iterate over song files to test.""" # Setting datadir # Load the default songbook config - cls.config = config_model('default') + cls.config = config_model('default')['en'] if '_datadir' not in cls.config: cls.config['_datadir'] = [] diff --git a/test/test_songbook/french.tex.control b/test/test_songbook/french.tex.control new file mode 100644 index 00000000..0eeac9aa --- /dev/null +++ b/test/test_songbook/french.tex.control @@ -0,0 +1,131 @@ + + + + + + +%% Automatically generated document. +%% You may edit this file but all changes will be overwritten. +%% If you want to change this document, have a look at +%% the templating system. +%% +%% Generated using Songbook + +\makeatletter +\def\input@path{ % + {@TEST_FOLDER@/latex/} % + {@DATA_FOLDER@/latex/} % +} +\makeatother + +\documentclass[ + ]{article} + +\usepackage[ +chorded, +pictures, +repeatchords, +importantdiagramonly, +guitar, + ]{crepbook} + +\usepackage[ + a4paper % paper size + ,includeheadfoot % include header and footer into text size + ,hmarginratio=1:1 % ratio between inner and outer margin (default) + ,outer=1.8cm % outer margin (right) + ,vmarginratio=1:1 % ratio between top and bottom margin + ,bmargin=1.3cm % bottom margin + ]{geometry} + +\usepackage{lmodern} + + +\usepackage[french]{babel} +\lang{french} + +\usepackage{graphicx} +\graphicspath{ % + {@TEST_FOLDER@/} % + {@DATA_FOLDER@/} % +} + + +\makeatletter +\@ifpackageloaded{hyperref}{}{ + \usepackage{url} + \newcommand{\phantomsection}{} + \newcommand{\hyperlink}[2]{#2} + \newcommand{\href}[2]{\expandafter\url\expandafter{#1}} +} +\makeatother + + +\usepackage{chords} + +\title{Recueil de chansons pour guitare} +\author{L'équipe Patacrep} + +\newindex{titleidx}{french_title} +\newauthorindex{authidx}{french_auth} + +\authignoreword{unknown} +\authbyword{by} +\authsepword{and} + +\notenamesout{La}{Si}{Do}{R\'e}{Mi}{Fa}{Sol} + + +\pagestyle{empty}\definecolor{SongNumberBgColor}{HTML}{D1E4AE} +\definecolor{NoteBgColor}{HTML}{D1E4AE} +\definecolor{IndexBgColor}{HTML}{D1E4AE} + +\renewcommand{\snumbgcolor}{SongNumberBgColor} +\renewcommand{\notebgcolor}{NoteBgColor} +\renewcommand{\idxbgcolor}{IndexBgColor} + +\definecolor{tango-green-3}{HTML}{4e9a06} +\definecolor{tango-blue-3}{HTML}{204a87} +\usepackage[ + bookmarks, + bookmarksopen, + hyperfigures=true, + colorlinks=true, + linkcolor=tango-green-3, + urlcolor=tango-blue-3 + ]{hyperref} + + +\subtitle{} +\mail{crep@team-on-fire.com} +\web{http://www.patacrep.com} +\picture{img/treble_a} +\picturecopyright{Dbolton \url{http://commons.wikimedia.org/wiki/User:Dbolton}} +\footer{Créé avec le programme Songbook (\url{http://www.patacrep.com})} + + +\begin{document} + +\maketitle + + +\showindex{\songindexname}{titleidx} +\showindex{\authorindexname}{authidx} + +% list of chords +\ifchorded + \ifdiagram + \phantomsection + \addcontentsline{toc}{section}{\chordlistname} + \chords + \fi +\fi + +\phantomsection +\addcontentsline{toc}{section}{\songlistname} + + + + + +\end{document} \ No newline at end of file diff --git a/test/test_songbook/french.yaml b/test/test_songbook/french.yaml new file mode 100644 index 00000000..6a15c2bb --- /dev/null +++ b/test/test_songbook/french.yaml @@ -0,0 +1,5 @@ +book: + lang: fr + +content: + - sort: \ No newline at end of file