lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I change LOCALEDIR?


From: Werner LEMBERG
Subject: Re: How do I change LOCALEDIR?
Date: Tue, 03 Mar 2020 13:40:20 +0100 (CET)

>> If I understand the code correctly (in file `relocate.cc`), the two
>> calls to `bindtextdomain` happen before relocation files are
>> read.[*] In other words, the `LILYPOND_LOCALEDIR` environment
>> variable is honoured but a corresponding assignment in relocation
>> files are ignored (for the lilypond binary itself – child programs
>> do get the updated environment variable).
>>
>> Maybe this approach should be changed?
> 
> Perhaps!  What is the point of overriding the environment setting
> for LOCALEDIR?  Does LilyPond itself use that setting, or do only
> the child programs use it?

Please try the attached patch.  It now calls `bindtextdomain` a third
time to take care of setting `LILYPOND_LOCALEDIR` in the relocation
files.


    Werner
>From fb1c6fea888450974eafc0b31add9a2d926d0106 Mon Sep 17 00:00:00 2001
From: Werner Lemberg <address@hidden>
Date: Tue, 3 Mar 2020 11:02:02 +0100
Subject: [PATCH] relocate.cc: Try harder to find directory for translations

This commit adds a third call to find translations; we now have the
following search algorithm.

  * Try the `LOCALEDIR` value as found with the `configure` script.
  * Try the `LILYPOND_LOCALEDIR` environment variable.
  * After relocation files are read, try the `LILYPOND_LOCALEDIR` variable
    again.
---
 lily/relocate.cc | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/lily/relocate.cc b/lily/relocate.cc
index 63259e6913..6800c21ba3 100644
--- a/lily/relocate.cc
+++ b/lily/relocate.cc
@@ -211,6 +211,17 @@ setup_paths (char const *argv0_ptr)
   string bindir = File_name (dir_name (argv0_abs)).canonicalized ().to_string 
();
   string prefix = File_name (bindir + "/..").canonicalized ().to_string ();
 
+#if HAVE_GETTEXT
+  // second try to get translations (using the LILYPOND_LOCALEDIR
+  // environment variable)
+  string localedir = set_up_directory ("LILYPOND_LOCALEDIR",
+                                       "localedir",
+                                       LOCALEDIR,
+                                       prefix + "/share/locale");
+  if (is_dir (localedir))
+    bindtextdomain ("lilypond", localedir.c_str ());
+#endif
+
   // set INSTALLER_PREFIX environment variable
   sane_putenv ("INSTALLER_PREFIX", prefix.c_str (), true, true);
 
@@ -223,23 +234,24 @@ setup_paths (char const *argv0_ptr)
                                        PACKAGE_DATADIR "/" TOPLEVEL_VERSION,
                                        prefix + "/share/lilypond/" 
TOPLEVEL_VERSION,
                                        prefix + "/share/lilypond/current");
-  string localedir = set_up_directory ("LILYPOND_LOCALEDIR",
-                                       "localedir",
-                                       LOCALEDIR,
-                                       prefix + "/share/locale");
   string relocdir = set_up_directory ("LILYPOND_RELOCDIR",
                                       "relocdir",
                                       "", // no compile-time default
                                       prefix + "/etc/relocate");
+  if (is_dir (relocdir))
+    read_relocation_dir (relocdir);
 
 #if HAVE_GETTEXT
+  // the relocation files might have changed LILYPOND_LOCALEDIR again,
+  // so we try to get translations a third and final time
+  localedir = set_up_directory ("LILYPOND_LOCALEDIR",
+                                "localedir",
+                                LOCALEDIR,
+                                prefix + "/share/locale");
   if (is_dir (localedir))
     bindtextdomain ("lilypond", localedir.c_str ());
 #endif
 
-  if (is_dir (relocdir))
-    read_relocation_dir (relocdir);
-
   prepend_env_path ("PATH", bindir);
   global_path.append ("");
 
-- 
2.16.4


reply via email to

[Prev in Thread] Current Thread [Next in Thread]