make the message stuff work better

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6853 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2003-04-25 01:54:04 +00:00
parent febdea3f88
commit 7eec4960de
6 changed files with 37 additions and 9 deletions

View File

@ -1,5 +1,11 @@
2003-04-25 Lars Gullik Bjønnes <larsbj@gullik.net>
* messages.C: make case where setlocale cannot comply work better.
* buffer.C (updateDocLang): new function
(changeLanguage): use it
(readFile): use it
* text2.C (setCounter): use B_ a bit.
* lyxlayout.C (Read): be sure to trim the label strings.

View File

@ -500,8 +500,7 @@ bool Buffer::readFile(LyXLex & lex, string const & filename)
// After we have read a file, we must ensure that the buffer
// language is set and used in the gui.
// If you know of a better place to put this, please tell me. (Lgb)
messages_.reset(new Messages(params.language->code(),
"/usr/local/share/locale"));
updateDocLang(params.language);
return ret;
}
@ -2215,14 +2214,22 @@ void Buffer::redraw()
void Buffer::changeLanguage(Language const * from, Language const * to)
{
lyxerr << "Changing Language!" << endl;
// Take care of l10n/i18n
messages_.reset(new Messages(to->code(), "/usr/local/share/locale"));
updateDocLang(to);
ParIterator end = par_iterator_end();
for (ParIterator it = par_iterator_begin(); it != end; ++it)
(*it)->changeLanguage(params, from, to);
}
void Buffer::updateDocLang(Language const * nlang)
{
messages_.reset(new Messages(nlang->code(), "/usr/local/share/locale"));
}
bool Buffer::isMultiLingual()
{

View File

@ -262,6 +262,10 @@ public:
///
void changeLanguage(Language const * from, Language const * to);
///
void updateDocLang(Language const * nlang);
///
bool isMultiLingual();

View File

@ -1,3 +1,8 @@
2003-04-25 Lars Gullik Bjønnes <larsbj@gullik.net>
* ControlDocument.C (setLanguage): call updateDocLang when not
calling changeLanguage.
2003-04-10 John Levon <levon@movementarian.org>
* ControlTabular.h:

View File

@ -95,10 +95,14 @@ void ControlDocument::setLanguage()
Language const * oldL = buffer()->params.language;
Language const * newL = bp_->language;
if (oldL != newL
&& oldL->RightToLeft() == newL->RightToLeft()
&& !lv_.buffer()->isMultiLingual())
lv_.buffer()->changeLanguage(oldL, newL);
if (oldL != newL) {
if (oldL->RightToLeft() == newL->RightToLeft()
&& !lv_.buffer()->isMultiLingual())
lv_.buffer()->changeLanguage(oldL, newL);
else
lv_.buffer()->updateDocLang(newL);
}
}

View File

@ -88,11 +88,13 @@ public:
string const get(string const & m) const
{
char * old = strdup(setlocale(LC_ALL, 0));
setlocale(LC_ALL, lang_.c_str());
char * n = setlocale(LC_ALL, lang_.c_str());
const char* msg = gettext(m.c_str());
setlocale(LC_ALL, old);
free(old);
return string(msg);
// If we are unable to honour the request we just
// return what we got in.
return (!n ? m : string(msg));
}
private:
///