Re: [PATCH] Fix #3332 (plaintext output)

2007-05-01 Thread Abdelrazak Younes

Georg Baum wrote:

Am Montag, 30. April 2007 23:52 schrieb Abdelrazak Younes:

Michael Gerz wrote:

Georg, all,

as an attempt to please you and to fix bug #3332, I produced the 
attached patch :-)


The bad news: The translations to the buffer language do not work on my 
machine (Win XP) - all translations are made to the menu language, 
instead :-(
I think you need to use the paragraph language instead; look at 
Paragraph::translateIfPossible().


Using the paragraph language would indeed be more correct, but AFAIK this 
would require to change the signature of the plaintext() methods. Also 
Paragraph::translateIfPossible would not be needed in this case (the 
string to be translated does not come from the user).


OK, thanks.

Abdel.



Re: [PATCH] Fix #3332 (plaintext output)

2007-05-01 Thread Michael Gerz

Abdelrazak Younes schrieb:

Michael Gerz wrote:

Georg, all,

as an attempt to please you and to fix bug #3332, I produced the 
attached patch :-)


The bad news: The translations to the buffer language do not work on 
my machine (Win XP) - all translations are made to the menu language, 
instead :-(


I think you need to use the paragraph language instead; look at 
Paragraph::translateIfPossible().
See Georg's comment. IMHO, using the buffer language rather than the 
paragraph language is more than good enough for plain text output. Using 
the paragraph language would require code changes that are (IMHO again) 
not worth the effort.


Michael



Re: [PATCH] Fix #3332 (plaintext output)

2007-05-01 Thread Georg Baum
Am Montag, 30. April 2007 23:52 schrieb Abdelrazak Younes:
> Michael Gerz wrote:
> > Georg, all,
> > 
> > as an attempt to please you and to fix bug #3332, I produced the 
> > attached patch :-)
> > 
> > The bad news: The translations to the buffer language do not work on my 
> > machine (Win XP) - all translations are made to the menu language, 
> > instead :-(
> 
> I think you need to use the paragraph language instead; look at 
> Paragraph::translateIfPossible().

Using the paragraph language would indeed be more correct, but AFAIK this 
would require to change the signature of the plaintext() methods. Also 
Paragraph::translateIfPossible would not be needed in this case (the 
string to be translated does not come from the user).

My main concern was that the exported document should not depend on the 
environment, and this is fixed by the patch, so it is fine with me.

I also think that translation of the on screen labels to the buffer 
language makes sense. This fits to the translation of layout strings 
(which is even more fine grained at paragraph level).

The fact that the patch does not work needs of course further 
investigation, but from looking at the code I don't see anything wrong. I 
rather believe that translation to the buffer language is broken in 
general for Michael.


Georg



Re: [PATCH] Fix #3332 (plaintext output)

2007-04-30 Thread Abdelrazak Younes

Michael Gerz wrote:

Georg, all,

as an attempt to please you and to fix bug #3332, I produced the 
attached patch :-)


The bad news: The translations to the buffer language do not work on my 
machine (Win XP) - all translations are made to the menu language, 
instead :-(


I think you need to use the paragraph language instead; look at 
Paragraph::translateIfPossible().


Abdel.



[PATCH] Fix #3332 (plaintext output)

2007-04-30 Thread Michael Gerz

Georg, all,

as an attempt to please you and to fix bug #3332, I produced the 
attached patch :-)


The bad news: The translations to the buffer language do not work on my 
machine (Win XP) - all translations are made to the menu language, 
instead :-(


Could someone please check whether the patch works on Linux at least? 
E.g., if you open a Spanish doc in a German environment and export the 
doc as plain text, you shouldn't see any German inset labels.


Georg, is this what you had in mind? Any comments on the code itself?

Regards, Michael

PS: Since plaintext output partly depends on screen labels, some screen 
labels are also printed in the buffer's language now. Whether this is 
preferable, is a matter of taste, of course. From a logical point of 
view, it may make sense.
Index: src/insets/InsetCaption.cpp
===
--- src/insets/InsetCaption.cpp	(Revision 18124)
+++ src/insets/InsetCaption.cpp	(Arbeitskopie)
@@ -134,7 +134,7 @@
 	int const width_offset = TEXT_TO_INSET_OFFSET / 2;
 	mi.base.textwidth -= width_offset;
 
-	computeFullLabel();
+	computeFullLabel(*mi.base.bv->buffer());
 
 	labelwidth_ = theFontMetrics(mi.base.font).width(full_label_);
 	// add some space to separate the label from the inset text
@@ -257,7 +257,7 @@
 int InsetCaption::plaintext(Buffer const & buf, odocstream & os,
 OutputParams const & runparams) const
 {
-	computeFullLabel();
+	computeFullLabel(buf);
 
 	os << '[' << full_label_ << "\n";
 	InsetText::plaintext(buf, os, runparams);
@@ -278,13 +278,13 @@
 }
 
 
-void InsetCaption::computeFullLabel() const
+void InsetCaption::computeFullLabel(Buffer const & buf) const
 {
 	if (type_.empty())
-		full_label_ = _("Senseless!!! ");
+		full_label_ = buf.B_("Senseless!!! ");
 	else {
 		docstring const number = convert(counter_);
-		docstring label = custom_label_.empty()? _(type_): custom_label_;
+		docstring label = custom_label_.empty()? buf.B_(type_): custom_label_;
 		full_label_ = bformat(from_ascii("%1$s %2$s:"), label, number);
 	}
 }
Index: src/insets/InsetFoot.cpp
===
--- src/insets/InsetFoot.cpp	(Revision 18124)
+++ src/insets/InsetFoot.cpp	(Arbeitskopie)
@@ -13,6 +13,7 @@
 
 #include "InsetFoot.h"
 
+#include "Buffer.h"
 #include "gettext.h"
 // the following are needed just to get the layout of the enclosing
 // paragraph. This seems a bit too much to me (JMarc)
@@ -82,7 +83,7 @@
 int InsetFoot::plaintext(Buffer const & buf, odocstream & os,
  OutputParams const & runparams) const
 {
-	os << '[' << _("footnote") << ":\n";
+	os << '[' << buf.B_("footnote") << ":\n";
 	InsetText::plaintext(buf, os, runparams);
 	os << "\n]";
 
Index: src/insets/InsetMarginal.cpp
===
--- src/insets/InsetMarginal.cpp	(Revision 18124)
+++ src/insets/InsetMarginal.cpp	(Arbeitskopie)
@@ -13,6 +13,7 @@
 
 #include "InsetMarginal.h"
 
+#include "Buffer.h"
 #include "gettext.h"
 #include "Paragraph.h"
 #include "OutputParams.h"
@@ -66,7 +67,7 @@
 int InsetMarginal::plaintext(Buffer const & buf, odocstream & os,
  OutputParams const & runparams) const
 {
-	os << '[' << _("margin") << ":\n";
+	os << '[' << buf.B_("margin") << ":\n";
 	InsetText::plaintext(buf, os, runparams);
 	os << "\n]";
 
Index: src/insets/InsetBranch.cpp
===
--- src/insets/InsetBranch.cpp	(Revision 18124)
+++ src/insets/InsetBranch.cpp	(Arbeitskopie)
@@ -235,7 +235,7 @@
 	if (!isBranchSelected(buf))
 		return 0;
 
-	os << '[' << _("branch") << ' ' << params_.branch << ":\n";
+	os << '[' << buf.B_("branch") << ' ' << params_.branch << ":\n";
 	InsetText::plaintext(buf, os, runparams);
 	os << "\n]";
 
Index: src/insets/InsetGraphics.cpp
===
--- src/insets/InsetGraphics.cpp	(Revision 18124)
+++ src/insets/InsetGraphics.cpp	(Arbeitskopie)
@@ -807,7 +807,7 @@
 }
 
 
-int InsetGraphics::plaintext(Buffer const &, odocstream & os,
+int InsetGraphics::plaintext(Buffer const & buf, odocstream & os,
  OutputParams const &) const
 {
 	// No graphics in ascii output. Possible to use gifscii to convert
@@ -818,7 +818,7 @@
 	// FIXME UNICODE
 	// FIXME: We have no idea what the encoding of the filename is
 
-	docstring const str = bformat(_("Graphics file: %1$s"),
+	docstring const str = bformat(buf.B_("Graphics file: %1$s"),
 	  from_utf8(params().filename.absFilename()));
 	os << '<' << str << '>';
 
Index: src/insets/InsetCaption.h
===
--- src/insets/InsetCaption.h	(Revision 18124)
+++ src/insets/InsetCaption.h	(Arbeitskopie)
@@ -84,7 +84,7 @@
 
 private:
 	///
-	void computeFullLabel() const;
+	void computeFullLabel(Buffer co