mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
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.
This commit is contained in:
parent
a3c864102a
commit
149b574b07
@ -90,11 +90,13 @@ Run ./pocheck.pl -h to see all possible switches.
|
|||||||
|
|
||||||
6) HOW CAN I TEST MY TRANSLATION?
|
6) HOW CAN I TEST MY TRANSLATION?
|
||||||
|
|
||||||
In order to test your translation you need to obtain the LyX sources (from the
|
In order to test your translation you need to obtain the LyX sources
|
||||||
SVN repository) and replace the existing .po with yours. Afterwards, you should
|
(from the git repository) and replace the existing .po with yours.
|
||||||
compile and install LyX (check the INSTALL file for your OS). If you don't
|
Afterwards, you should compile and optionally install LyX (check the
|
||||||
install LyX it won't work. In order to run LyX with your translation, use the
|
INSTALL file for your OS). Note that, as of LyX 2.1, it is not
|
||||||
appropriate LANG variable:
|
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 Linux: LANG=xx_CC lyx
|
||||||
On Windows, you need to change the lyx.bat file and write: set LANG=xx_CC
|
On Windows, you need to change the lyx.bat file and write: set LANG=xx_CC
|
||||||
@ -102,11 +104,9 @@ appropriate LANG variable:
|
|||||||
xx stands for your language code. CC stands for your country code. So to get,
|
xx stands for your language code. CC stands for your country code. So to get,
|
||||||
e.g., Czech, the code is "cs_CZ".
|
e.g., Czech, the code is "cs_CZ".
|
||||||
|
|
||||||
The most comfortable way to see your updated translation while editing, is
|
The most comfortable way to see your updated translation while
|
||||||
running (in linux):
|
editing, is running (in linux) "make xx.gmo" in the po directory to
|
||||||
1. "make xx.gmo" in the po directory to compile updated xx.po translation
|
compile updated xx.po translation and then run LyX.
|
||||||
2. "make install" in root lyx tree to copy xx.gmo to the appropriate location
|
|
||||||
(or do it by hand...)
|
|
||||||
|
|
||||||
For advanced users - if you want to remerge your files against current source
|
For advanced users - if you want to remerge your files against current source
|
||||||
files run make update-po.
|
files run make update-po.
|
||||||
|
@ -155,15 +155,6 @@ Messages::Messages(string const & l)
|
|||||||
|
|
||||||
namespace {
|
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.
|
// Find the code we have for a given language code. Return empty if not found.
|
||||||
string realCode(string const & c)
|
string realCode(string const & c)
|
||||||
{
|
{
|
||||||
@ -171,7 +162,7 @@ string realCode(string const & c)
|
|||||||
string code = (c == "C") ? "en" : c;
|
string code = (c == "C") ? "en" : c;
|
||||||
// this loops at most twice
|
// this loops at most twice
|
||||||
while (true) {
|
while (true) {
|
||||||
if (FileName(moFile(code)).isReadableFile())
|
if (package().messages_file(code).isReadableFile())
|
||||||
return code;
|
return code;
|
||||||
if (contains(code, '_'))
|
if (contains(code, '_'))
|
||||||
code = token(code, '_', 0);
|
code = token(code, '_', 0);
|
||||||
@ -234,7 +225,7 @@ bool Messages::readMoFile()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
string const filen = moFile(code);
|
string const filen = package().messages_file(code).toSafeFilesystemEncoding();
|
||||||
|
|
||||||
// get file size
|
// get file size
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
|
@ -119,9 +119,9 @@ Package::Package(string const & command_line_arg0,
|
|||||||
lyx_dir_ = FileName(lyx_dir_.realPath());
|
lyx_dir_ = FileName(lyx_dir_.realPath());
|
||||||
|
|
||||||
// Is LyX being run in-place from the build tree?
|
// 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_ =
|
system_support_dir_ =
|
||||||
get_system_support_dir(abs_binary,
|
get_system_support_dir(abs_binary,
|
||||||
command_line_system_support_dir);
|
command_line_system_support_dir);
|
||||||
@ -164,6 +164,18 @@ void Package::set_temp_dir(FileName const & temp_dir) const
|
|||||||
temp_dir_ = temp_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.
|
// The specification of home_dir_ is fixed for a given OS.
|
||||||
// A typical example on Windows: "C:/Documents and Settings/USERNAME"
|
// A typical example on Windows: "C:/Documents and Settings/USERNAME"
|
||||||
// and on a Posix-like machine: "/home/USERNAME".
|
// and on a Posix-like machine: "/home/USERNAME".
|
||||||
|
@ -101,6 +101,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
FileName const & locale_dir() const { return locale_dir_; }
|
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.
|
/** The default document directory.
|
||||||
* Can be reset by LyXRC.
|
* Can be reset by LyXRC.
|
||||||
*/
|
*/
|
||||||
@ -147,6 +153,7 @@ private:
|
|||||||
FileName system_temp_dir_;
|
FileName system_temp_dir_;
|
||||||
std::string configure_command_;
|
std::string configure_command_;
|
||||||
bool explicit_user_support_dir_;
|
bool explicit_user_support_dir_;
|
||||||
|
bool in_build_dir_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace support
|
} // namespace support
|
||||||
|
Loading…
Reference in New Issue
Block a user