The branch, kill-gettext, has been updated.

- Log -----------------------------------------------------------------

commit 2190a13497e4b0963fd1d08c57ffe7c22275fe78
Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date:   Tue May 14 16:35:34 2013 +0200

    Read the right .gmo files when running in place
    
    With gettext, we have been forced to install .mo files at the right place 
in order to read them. Now that we have our code, the situation changes.
    
    * Add new method Package::messages_file(code), when returns the right path, 
depending on whether we are running in place.
    * In Messages class use that intead of the existing one.

diff --git a/README.localization b/README.localization
index 52280f9..016e95a 100644
--- a/README.localization
+++ b/README.localization
@@ -89,11 +89,13 @@ Run ./pocheck.pl -h to see all possible switches.
 
 6) HOW CAN I TEST MY TRANSLATION?
 
-In order to test your translation you need to obtain the LyX sources (from the 
-SVN repository) and replace the existing .po with yours. Afterwards, you 
should 
-compile and install LyX (check the INSTALL file for your OS). If you don't 
-install LyX it won't work. In order to run LyX with your translation, use the 
-appropriate LANG variable:
+In order to test your translation you need to obtain the LyX sources
+(from the SVN repository) and replace the existing .po with yours.
+Afterwards, you should compile and optionally install LyX (check the
+INSTALL file for your OS). Note that, as of LyX 2.1, it is not
+necessary anymore to install anything. In order to run LyX with your
+translation, change the current language in Preferences dialog or use
+the appropriate LANG variable:
 
   On Linux: LANG=xx_CC lyx
   On Windows, you need to change the lyx.bat file and write: set LANG=xx_CC
@@ -101,11 +103,9 @@ appropriate LANG variable:
 xx stands for your language code. CC stands for your country code. So to get, 
 e.g., Czech, the code is "cs_CZ".
 
-The most comfortable way to see your updated translation while editing, is
-running (in linux):
-1. "make xx.gmo" in the po directory to compile updated xx.po translation
-2. "make install" in root lyx tree to copy xx.gmo to the appropriate location
-   (or do it by hand...)
+The most comfortable way to see your updated translation while
+editing, is running (in linux) "make xx.gmo" in the po directory to
+compile updated xx.po translation and then run LyX.
 
 For advanced users - if you want to remerge your files against current source
 files run make update-po. 
diff --git a/src/support/Messages.cpp b/src/support/Messages.cpp
index d2907ac..33e5262 100644
--- a/src/support/Messages.cpp
+++ b/src/support/Messages.cpp
@@ -153,15 +153,6 @@ Messages::Messages(string const & l)
 
 namespace {
 
-string moFile(string const & c)
-{
-       static string const locale_dir
-               = package().locale_dir().toFilesystemEncoding();
-       return locale_dir + "/" + c
-               + "/LC_MESSAGES/" PACKAGE ".mo";
-}
-
-
 // Find the code we have for a given language code. Return empty if not found.
 string realCode(string const & c)
 {
@@ -169,7 +160,7 @@ string realCode(string const & c)
        string code = (c == "C") ? "en" : c;
        // this loops at most twice
        while (true) {
-               if (FileName(moFile(code)).isReadableFile())
+               if (package().messages_file(code).isReadableFile())
                        return code;
                if (contains(code, '_'))
                        code = token(code, '_', 0);
@@ -232,7 +223,7 @@ bool Messages::readMoFile()
                return false;
        }
 
-       string const filen = moFile(code);
+       string const filen = 
package().messages_file(code).toSafeFilesystemEncoding();
 
        // get file size
        struct stat buf;
diff --git a/src/support/Package.cpp b/src/support/Package.cpp
index 845553f..24cf8ca 100644
--- a/src/support/Package.cpp
+++ b/src/support/Package.cpp
@@ -119,9 +119,9 @@ Package::Package(string const & command_line_arg0,
        lyx_dir_ = FileName(lyx_dir_.realPath());
 
        // Is LyX being run in-place from the build tree?
-       bool in_build_dir = inBuildDir(abs_binary, build_support_dir_, 
system_support_dir_);
+       in_build_dir_ = inBuildDir(abs_binary, build_support_dir_, 
system_support_dir_);
 
-       if (!in_build_dir) {
+       if (!in_build_dir_) {
                system_support_dir_ =
                        get_system_support_dir(abs_binary,
                                               command_line_system_support_dir);
@@ -164,6 +164,18 @@ void Package::set_temp_dir(FileName const & temp_dir) const
                temp_dir_ = temp_dir;
 }
 
+
+FileName Package::messages_file(string const & c) const
+{
+       if (in_build_dir_)
+               return FileName(top_srcdir().absFileName() + "/po/"
+                               + c + ".gmo");
+       else
+               return FileName(locale_dir_.absFileName() + "/" + c
+                       + "/LC_MESSAGES/" PACKAGE ".mo");
+}
+
+
 // The specification of home_dir_ is fixed for a given OS.
 // A typical example on Windows: "C:/Documents and Settings/USERNAME"
 // and on a Posix-like machine: "/home/USERNAME".
diff --git a/src/support/Package.h b/src/support/Package.h
index d6e76fb..064f662 100644
--- a/src/support/Package.h
+++ b/src/support/Package.h
@@ -101,6 +101,12 @@ public:
         */
        FileName const & locale_dir() const { return locale_dir_; }
 
+       /** The file name that should contain the message file (.mo)
+        *  for language code \param c. Does not check whether the
+        *  file exists. Handles running in place.
+        */
+       FileName messages_file(std::string const & c) const;
+
        /** The default document directory.
         *  Can be reset by LyXRC.
         */
@@ -147,6 +153,7 @@ private:
        FileName system_temp_dir_;
        std::string configure_command_;
        bool explicit_user_support_dir_;
+       bool in_build_dir_;
 };
 
 } // namespace support

-----------------------------------------------------------------------

Summary of changes:
 README.localization      |   20 ++++++++++----------
 src/support/Messages.cpp |   13 ++-----------
 src/support/Package.cpp  |   16 ++++++++++++++--
 src/support/Package.h    |    7 +++++++
 4 files changed, 33 insertions(+), 23 deletions(-)


hooks/post-receive
-- 
Repository for new features

Reply via email to