]> git.lyx.org Git - features.git/commitdiff
more message work, should now be ready for real integration
authorLars Gullik Bjønnes <larsbj@gullik.org>
Thu, 24 Apr 2003 23:19:41 +0000 (23:19 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Thu, 24 Apr 2003 23:19:41 +0000 (23:19 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6850 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/buffer.C
src/buffer.h

index 1379b7c3c1f2b65b1a0b02dadfd04213b675d3ab..d2ccfe45c545d69980e9781a3c1af9b0f3f27339 100644 (file)
@@ -1,5 +1,10 @@
 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>
index f7b0aae7623405cf549ea55a39b3fe0f09193ad3..dd70097d422a375487c5658b3e4169570c878452 100644 (file)
@@ -36,6 +36,7 @@
 #include "lyxtextclasslist.h"
 #include "sgml.h"
 #include "paragraph_funcs.h"
+#include "messages.h"
 #include "author.h"
 
 #include "frontends/LyXView.h"
@@ -494,12 +495,21 @@ void Buffer::insertStringAsLines(ParagraphList::iterator & par, pos_type & pos,
 
 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"),
@@ -1631,7 +1641,6 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
 #endif
                Alert::error(_("Could not save document"), text);
                return;
-               return;
        }
 
        niceFile = nice; // this will be used by Insetincludes.
@@ -2206,6 +2215,8 @@ void Buffer::redraw()
 
 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)
@@ -2315,6 +2326,16 @@ Language const * Buffer::getLanguage() const
 }
 
 
+string const Buffer::B_(string const & l10n) const
+{
+       if (messages_.get()) {
+               return messages_->get(l10n);
+       }
+       
+       return _(l10n);
+}
+
+
 bool Buffer::isClean() const
 {
        return lyx_clean;
index ea66fe9ca494916b476e6f4ead269f341b9f992d..b5de352222d3a5b8cc2f8fc23201d7c23605e07c 100644 (file)
@@ -25,6 +25,7 @@
 #include "author.h"
 
 #include <boost/shared_ptr.hpp>
+#include <boost/scoped_ptr.hpp>
 
 class BufferView;
 class LyXRC;
@@ -33,6 +34,7 @@ class LaTeXFeatures;
 class Language;
 class ParIterator;
 class ParConstIterator;
+class Messages;
 
 
 /** The buffer object.
@@ -169,6 +171,9 @@ public:
 
        /// 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
@@ -326,6 +331,8 @@ private:
            of the buffers in the list of users to do a #updateLayoutChoice#.
        */
        BufferView * users;
+       ///
+       boost::scoped_ptr<Messages> messages_;
 public:
        ///
        class inset_iterator {