Clean-up yesterday's code-splurge and sort the translated language names.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4095 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2002-04-30 15:07:03 +00:00
parent 2c35ae62a6
commit ac926e5f0a
7 changed files with 59 additions and 20 deletions

View File

@ -1,3 +1,12 @@
2002-04-30 Angus Leeming <a.leeming@ic.ac.uk>
* frnt_lang.[Ch] (getLanguageData): passed a bool character_dlg.
If the the caller is the character dialog, add "No change" and "Reset"
to the vector, else don't.
Internationalise the GUI strings here rather than in the different
calling dialogs.
Sort the translated strings, albeit simply.
2002-04-29 Angus Leeming <a.leeming@ic.ac.uk>
* character.[Ch]: rename namespace character as namespace frnt.

View File

@ -15,26 +15,46 @@
#include "frnt_lang.h"
#include "gettext.h"
#include "language.h"
#include <iostream>
using std::vector;
namespace {
struct Sorter {
bool operator()(frnt::LanguagePair const & lhs,
frnt::LanguagePair const & rhs) const
{
return lhs.first < rhs.first;
}
};
} // namespace anon
namespace frnt {
vector<LanguagePair> const getLanguageData()
vector<LanguagePair> const getLanguageData(bool character_dlg)
{
vector<LanguagePair> langs(languages.size() + 2);
vector<LanguagePair>::size_type const size = character_dlg ?
languages.size() + 2 : languages.size();
vector<LanguagePair> langs(size);
if (character_dlg) {
langs[0].first = N_("No change"); langs[0].second = "No change";
langs[1].first = N_("Reset"); langs[1].second = "Reset";
}
vector<string>::size_type i = 2;
vector<string>::size_type i = character_dlg ? 2 : 0;
for (Languages::const_iterator cit = languages.begin();
cit != languages.end(); ++cit) {
langs[i].first = cit->second.display();
langs[i].first = _(cit->second.display());
langs[i].second = cit->second.lang();
++i;
}
std::sort(langs.begin(), langs.end(), Sorter());
return langs;
}

View File

@ -23,8 +23,10 @@
namespace frnt {
///
typedef std::pair<string, string> LanguagePair;
///
std::vector<LanguagePair> const getLanguageData();
/** If the caller is the character dialog, add "No change" and "Reset"
* to the vector.
*/
std::vector<LanguagePair> const getLanguageData(bool character_dlg);
} // namespace frnt

View File

@ -1,3 +1,11 @@
2002-04-30 Angus Leeming <a.leeming@ic.ac.uk>
* FormCharacter.C:
* FormDocument.C:
* FormPreferences.C: use the bool flag to getLanguageData as
appropriate. No longer translate the strings as this is done in
getLanguageData.
2002-04-29 Angus Leeming <a.leeming@ic.ac.uk>
* FormCharacter.h:

View File

@ -54,7 +54,7 @@ void FormCharacter::build()
vector<SizePair> const size = getSizeData();
vector<BarPair> const bar = getBarData();
vector<ColorPair> const color = getColorData();
vector<LanguagePair> const langs = getLanguageData();
vector<LanguagePair> const langs = getLanguageData(true);
// Store the identifiers for later
family_ = getSecond(family);
@ -103,7 +103,7 @@ void FormCharacter::build()
vector<LanguagePair>::const_iterator it = langs.begin();
vector<LanguagePair>::const_iterator end = langs.end();
for (; it != end; ++it) {
combo_language2_->addto(_(it->first));
combo_language2_->addto(it->first);
}
combo_language2_->select(1);

View File

@ -242,7 +242,7 @@ void FormDocument::build()
"default|auto|latin1|latin2|latin3|latin4|latin5|latin9"
"|koi8-r|koi8-u|cp866|cp1251|iso88595");
vector<frnt::LanguagePair> const langs = frnt::getLanguageData();
vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
// Store the identifiers for later
lang_ = getSecond(langs);
@ -260,7 +260,7 @@ void FormDocument::build()
vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
vector<frnt::LanguagePair>::const_iterator lend = langs.end();
for (; lit != lend; ++lit) {
combo_language->addto(_(lit->first));
combo_language->addto(lit->first);
}
combo_language->select(1);

View File

@ -1633,7 +1633,7 @@ void FormPreferences::Language::build()
fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
// Store the lang identifiers for later
vector<frnt::LanguagePair> const langs = frnt::getLanguageData();
vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
lang_ = getSecond(langs);
// The default_language is a combo-box and has to be inserted manually
@ -1652,7 +1652,7 @@ void FormPreferences::Language::build()
vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
vector<frnt::LanguagePair>::const_iterator lend = langs.end();
for (; lit != lend; ++lit) {
combo_default_lang->addto(_(lit->first));
combo_default_lang->addto(lit->first);
}
combo_default_lang->select(1);