diff --git a/src/ChangeLog b/src/ChangeLog index 45b19300cf..2ee366b24b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,11 @@ 2003-04-25 Lars Gullik Bjønnes + * 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. diff --git a/src/buffer.C b/src/buffer.C index dd70097d42..aa481e4815 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -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() { diff --git a/src/buffer.h b/src/buffer.h index b5de352222..8d562bd281 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -262,6 +262,10 @@ public: /// void changeLanguage(Language const * from, Language const * to); + + /// + void updateDocLang(Language const * nlang); + /// bool isMultiLingual(); diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 58236269dc..38ae48d7d3 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,8 @@ +2003-04-25 Lars Gullik Bjønnes + + * ControlDocument.C (setLanguage): call updateDocLang when not + calling changeLanguage. + 2003-04-10 John Levon * ControlTabular.h: diff --git a/src/frontends/controllers/ControlDocument.C b/src/frontends/controllers/ControlDocument.C index 77dc09462f..18461bf408 100644 --- a/src/frontends/controllers/ControlDocument.C +++ b/src/frontends/controllers/ControlDocument.C @@ -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); + } } diff --git a/src/messages.C b/src/messages.C index 44c029b5d2..466d9e2240 100644 --- a/src/messages.C +++ b/src/messages.C @@ -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: ///