1 ;------------------------------------------------------------------;
2 ; opus_libre -- 30-readlang.scm ;
4 ; (c) 2008-2011 Valentin Villenave <valentin@villenave.net> ;
6 ; opus_libre is a free framework for GNU LilyPond: you may ;
7 ; redistribute it and/or modify it under the terms of the GNU ;
8 ; General Public License as published by the Free Software ;
9 ; Foundation, either version 3 of the License, or (at your option) ;
10 ; any later version. ;
11 ; This program is distributed WITHOUT ANY WARRANTY; without ;
12 ; even the implied warranty of MERCHANTABILITY or FITNESS FOR A ;
13 ; PARTICULAR PURPOSE. You should have received a copy of the GNU ;
14 ; General Public License along with this program (typically in the ;
15 ; share/doc/ directory). If not, see http://www.gnu.org/licenses/ ;
17 ;------------------------------------------------------------------;
23 ;; "Look for a user-specified language, and load
24 ;; language files accordingly, first globally, then
25 ;; locally. Note that the default language file,
26 ;; typically in etc/ly.conf.d/lang.conf, is always
27 ;; loaded (which allows for lighter language files
28 ;; that only define what needs to be overriden)."
30 (let* ((port (open-input-pipe "locale | grep --color=never LANG"))
31 (result (read-line port))
32 (str (if (string? result)
33 (car (reverse (string-split result #\=)))
37 (if (>= (string-length str) 2)
43 (if (defined-string? 'input)
44 (ly:parser-lookup 'input)
46 (ly:debug-message "Input language not defined.")
49 (ly:debug-message "Using system's default: ~a"
53 (ly:debug-message "Using default language: ~a"
54 conf:default-language)
55 conf:default-language)))))
57 (string-append conf:locale-dir "/" input-lang ".conf"))
59 (string-append conf:local-conf-dir "/" input-lang ".conf"))
64 (ly:debug-message "Loading language file ~a..." f)
65 (parse-def-file f conf:lang-prefix))
66 (ly:debug-message "Language file not found: ~a."
68 (load-lang-file input-lang-file)
69 (load-lang-file local-lang-file)))