2003-04-25 Lars Gullik Bjønnes <larsbj@gullik.net>
+ * buffer.C (readFile): set message_ after file is loaded.
+ (makeDocBookFile): remove double return
+ (changeLanguage): reset message_ upon language change.
+ (B_): new func, use this to get translated buffer strings.
+
* main.C: add myself and Jean Marc as authors.
2003-04-24 Lars Gullik Bjønnes <larsbj@gullik.net>
#include "lyxtextclasslist.h"
#include "sgml.h"
#include "paragraph_funcs.h"
+#include "messages.h"
#include "author.h"
#include "frontends/LyXView.h"
bool Buffer::readFile(LyXLex & lex, string const & filename)
{
- return readFile(lex, filename, paragraphs.begin());
+ bool ret = readFile(lex, filename, paragraphs.begin());
+
+ // 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"));
+
+ return ret;
}
// FIXME: all the below Alerts should give the filename..
-bool Buffer::readFile(LyXLex & lex, string const & filename, ParagraphList::iterator pit)
+bool Buffer::readFile(LyXLex & lex, string const & filename,
+ ParagraphList::iterator pit)
{
if (!lex.isOK()) {
Alert::error(_("Document could not be read"),
#endif
Alert::error(_("Could not save document"), text);
return;
- return;
}
niceFile = nice; // this will be used by Insetincludes.
void Buffer::changeLanguage(Language const * from, Language const * to)
{
+ // Take care of l10n/i18n
+ messages_.reset(new Messages(to->code(), "/usr/local/share/locale"));
ParIterator end = par_iterator_end();
for (ParIterator it = par_iterator_begin(); it != end; ++it)
}
+string const Buffer::B_(string const & l10n) const
+{
+ if (messages_.get()) {
+ return messages_->get(l10n);
+ }
+
+ return _(l10n);
+}
+
+
bool Buffer::isClean() const
{
return lyx_clean;
#include "author.h"
#include <boost/shared_ptr.hpp>
+#include <boost/scoped_ptr.hpp>
class BufferView;
class LyXRC;
class Language;
class ParIterator;
class ParConstIterator;
+class Messages;
/** The buffer object.
/// returns the main language for the buffer (document)
Language const * getLanguage() const;
+ /// get l10n translated to the buffers language
+ string const B_(string const & l10n) const;
+
///
int runChktex();
/// return true if the main lyx file does not need saving
of the buffers in the list of users to do a #updateLayoutChoice#.
*/
BufferView * users;
+ ///
+ boost::scoped_ptr<Messages> messages_;
public:
///
class inset_iterator {