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.
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 git 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
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.
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)
{
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);
return false;
}
- string const filen = moFile(code);
+ string const filen = package().messages_file(code).toSafeFilesystemEncoding();
// get file size
struct stat buf;
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);
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".
*/
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.
*/
FileName system_temp_dir_;
std::string configure_command_;
bool explicit_user_support_dir_;
+ bool in_build_dir_;
};
} // namespace support