}
-docstring const Buffer::translateLabel(docstring const & label) const
-{
- if (support::isAscii(label))
- // Probably standard layout, try to translate
- return B_(to_ascii(label));
- else
- // This must be a user defined layout. We cannot translate
- // this, since gettext accepts only ascii keys.
- return label;
-}
-
-
bool Buffer::isClean() const
{
return pimpl_->lyx_clean;
Language const * getLanguage() const;
/// get l10n translated to the buffers language
docstring const B_(std::string const & l10n) const;
- /// translate \p label to the buffer language if possible
- docstring const translateLabel(docstring const & label) const;
///
int runChktex();
if (layout->margintype == MARGIN_MANUAL) {
if (par.params().labelWidthString().empty())
- par.setLabelWidthString(buf.translateLabel(layout->labelstring()));
+ par.params().labelWidthString(par.translateIfPossible(layout->labelstring(), buf.params()));
} else {
- par.setLabelWidthString(docstring());
+ par.params().labelWidthString(docstring());
}
// Optimisation: setLabel() can be called for each for each
&& (layout->latextype != LATEX_ENVIRONMENT
|| isFirstInSequence(it.pit(), it.plist()))) {
counters.step(layout->counter);
- itemlabel = expandLabel(buf, layout,
- par.params().appendix());
+ par.params().labelString(
+ par.expandLabel(layout, buf.params()));
} else
- itemlabel.clear();
+ par.params().labelString(docstring());
} else if (layout->labeltype == LABEL_ITEMIZE) {
// At some point of time we should do something more
itemlabel = char_type(0x2219); // or 0x00b7
break;
}
+ par.params().labelString(itemlabel);
} else if (layout->labeltype == LABEL_ENUMERATE) {
// FIXME
break;
}
- itemlabel = counters.counterLabel(buf.B_(format));
+ par.params().labelString(counters.counterLabel(
+ par.translateIfPossible(from_ascii(format), buf.params())));
} else if (layout->labeltype == LABEL_BIBLIO) {// ale970302
counters.step(from_ascii("bibitem"));
if (par.bibitem())
par.bibitem()->setCounter(number);
- itemlabel = buf.translateLabel(layout->labelstring());
- // In biblio should't be following counters but...
+ par.params().labelString(
+ par.translateIfPossible(layout->labelstring(), buf.params()));
+ // In biblio shouldn't be following counters but...
} else if (layout->labeltype == LABEL_SENSITIVE) {
// Search for the first float or wrap inset in the iterator
size_t i = it.depth();
counters.step(from_ascii(fl.type()));
// Doesn't work... yet.
- itemlabel = bformat(_("%1$s #:"), buf.B_(fl.name()));
+ par.params().labelString(par.translateIfPossible(
+ bformat(from_ascii("%1$s #:"), from_utf8(fl.name())),
+ buf.params()));
} else {
// par->SetLayout(0);
- itemlabel = buf.translateLabel(layout->labelstring());
+ par.params().labelString(par.translateIfPossible(
+ layout->labelstring(), buf.params()));
}
} else if (layout->labeltype == LABEL_NO_LABEL)
- itemlabel.clear();
+ par.params().labelString(docstring());
else
- itemlabel = buf.translateLabel(layout->labelstring());
-
- par.params().labelString(itemlabel);
+ par.params().labelString(
+ par.translateIfPossible(layout->labelstring(), buf.params()));
}
} // anon namespace
}
-docstring expandLabel(Buffer const & buf,
- LyXLayout_ptr const & layout, bool appendix)
-{
- LyXTextClass const & tclass = buf.params().getLyXTextClass();
-
- docstring fmt = buf.translateLabel(appendix ?
- layout->labelstring_appendix() :
- layout->labelstring());
-
- // handle 'inherited level parts' in 'fmt',
- // i.e. the stuff between '@' in '@Section@.\arabic{subsection}'
- size_t const i = fmt.find('@', 0);
- if (i != docstring::npos) {
- size_t const j = fmt.find('@', i + 1);
- if (j != docstring::npos) {
- docstring parent(fmt, i + 1, j - i - 1);
- // FIXME UNICODE
- docstring label = expandLabel(buf, tclass[to_utf8(parent)], appendix);
- fmt = docstring(fmt, 0, i) + label + docstring(fmt, j + 1, docstring::npos);
- }
- }
-
- return tclass.counters().counterLabel(fmt);
-}
-
-
} // namespace lyx
/// Count the number of words in the text between these two iterators
int countWords(DocIterator const & from, DocIterator const & to);
-/// Expand the counters for the labelstring of \c layout
-lyx::docstring expandLabel(Buffer const & buf,
- LyXLayout_ptr const & layout,
- bool appendix);
-
-
/// update labels at "iter".
/**
A full updateLabels(Buffer const &) will be called if not possible.
// Label around sectioning number:
if (!bstyle->labeltag().empty()) {
sgml::openTag(os, bstyle->labeltag());
- os << expandLabel(buf, bstyle, false);
+ // We don't care about appendix in DOCBOOK.
+ os << par->expandLabel(bstyle, buf.params(), false);
sgml::closeTag(os, bstyle->labeltag());
}
#include "lyxfont.h"
#include "lyxrc.h"
#include "lyxrow.h"
+#include "messages.h"
#include "outputparams.h"
#include "paragraph_funcs.h"
#include "ParagraphList_fwd.h"
}
+docstring const Paragraph::translateIfPossible(docstring const & s,
+ BufferParams const & bparams) const
+{
+ if (!support::isAscii(s) || s.empty()) {
+ // This must be a user defined layout. We cannot translate
+ // this, since gettext accepts only ascii keys.
+ return s;
+ }
+ // Probably standard layout, try to translate
+ Messages & m = getMessages(getParLanguage(bparams)->code());
+ return m.get(to_ascii(s));
+}
+
+
+docstring Paragraph::expandLabel(LyXLayout_ptr const & layout,
+ BufferParams const & bparams, bool process_appendix) const
+{
+ LyXTextClass const & tclass = bparams.getLyXTextClass();
+
+ docstring fmt;
+ if (process_appendix && params().appendix())
+ fmt = translateIfPossible(layout->labelstring_appendix(),
+ bparams);
+ else
+ fmt = translateIfPossible(layout->labelstring(), bparams);
+
+ // handle 'inherited level parts' in 'fmt',
+ // i.e. the stuff between '@' in '@Section@.\arabic{subsection}'
+ size_t const i = fmt.find('@', 0);
+ if (i != docstring::npos) {
+ size_t const j = fmt.find('@', i + 1);
+ if (j != docstring::npos) {
+ docstring parent(fmt, i + 1, j - i - 1);
+ // FIXME UNICODE
+ docstring label = expandLabel(tclass[to_utf8(parent)], bparams);
+ fmt = docstring(fmt, 0, i) + label + docstring(fmt, j + 1, docstring::npos);
+ }
+ }
+
+ return tclass.counters().counterLabel(fmt);
+}
+
+
void Paragraph::applyLayout(LyXLayout_ptr const & new_layout)
{
layout(new_layout);
/// the next two functions are for the manual labels
docstring const getLabelWidthString() const;
- ///
+ /// Set label width string.
void setLabelWidthString(docstring const & s);
+ /// translate \p label to the paragraph language if possible.
+ docstring const translateIfPossible(docstring const & label,
+ BufferParams const & bparams) const;
+ /// Expand the counters for the labelstring of \c layout
+ docstring expandLabel(LyXLayout_ptr const &, BufferParams const &,
+ bool process_appendix = true) const;
/// Actual paragraph alignment used
char getAlign() const;
/// The nesting depth of a paragraph
LyXLayout_ptr const & lyxlayout = bufparams.getLyXTextClass()[layout];
for (pit_type pit = start; pit != end; ++pit) {
- pars_[pit].applyLayout(lyxlayout);
+ Paragraph & par = pars_[pit];
+ par.applyLayout(lyxlayout);
if (lyxlayout->margintype == MARGIN_MANUAL)
- pars_[pit].setLabelWidthString(buffer.translateLabel(lyxlayout->labelstring()));
+ par.setLabelWidthString(par.translateIfPossible(
+ lyxlayout->labelstring(), buffer.params()));
}
}