2002-09-05 14:10:50 +00:00
|
|
|
/**
|
2002-04-29 15:56:36 +00:00
|
|
|
* \file frnt_lang.C
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-04-29 15:56:36 +00:00
|
|
|
*
|
2002-10-21 17:38:09 +00:00
|
|
|
* \author Angus Leeming
|
2002-09-05 14:10:50 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-04-29 15:56:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "frnt_lang.h"
|
|
|
|
#include "gettext.h"
|
|
|
|
#include "language.h"
|
|
|
|
|
2003-09-05 22:17:02 +00:00
|
|
|
#include <algorithm>
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
|
|
|
using std::string;
|
2002-04-29 15:56:36 +00:00
|
|
|
using std::vector;
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2002-04-30 15:07:03 +00:00
|
|
|
namespace {
|
|
|
|
|
2005-01-19 15:03:31 +00:00
|
|
|
class Sorter
|
2004-05-19 15:11:37 +00:00
|
|
|
: public std::binary_function<LanguagePair,
|
|
|
|
LanguagePair, bool>
|
2004-01-31 15:30:24 +00:00
|
|
|
{
|
2005-01-19 15:03:31 +00:00
|
|
|
public:
|
2004-05-19 15:11:37 +00:00
|
|
|
bool operator()(LanguagePair const & lhs,
|
|
|
|
LanguagePair const & rhs) const {
|
2002-10-21 17:38:09 +00:00
|
|
|
return lhs.first < rhs.first;
|
|
|
|
}
|
2002-04-30 15:07:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace anon
|
|
|
|
|
2002-04-29 15:56:36 +00:00
|
|
|
|
2002-04-30 15:07:03 +00:00
|
|
|
vector<LanguagePair> const getLanguageData(bool character_dlg)
|
2002-04-29 15:56:36 +00:00
|
|
|
{
|
2002-04-30 15:07:03 +00:00
|
|
|
vector<LanguagePair>::size_type const size = character_dlg ?
|
|
|
|
languages.size() + 2 : languages.size();
|
2002-04-29 15:56:36 +00:00
|
|
|
|
2002-04-30 15:07:03 +00:00
|
|
|
vector<LanguagePair> langs(size);
|
2002-04-29 15:56:36 +00:00
|
|
|
|
2002-04-30 15:07:03 +00:00
|
|
|
if (character_dlg) {
|
2002-10-21 17:38:09 +00:00
|
|
|
langs[0].first = _("No change");
|
|
|
|
langs[0].second = "ignore";
|
|
|
|
langs[1].first = _("Reset");
|
|
|
|
langs[1].second = "reset";
|
2002-04-30 15:07:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
vector<string>::size_type i = character_dlg ? 2 : 0;
|
2002-04-29 15:56:36 +00:00
|
|
|
for (Languages::const_iterator cit = languages.begin();
|
|
|
|
cit != languages.end(); ++cit) {
|
2002-04-30 15:07:03 +00:00
|
|
|
langs[i].first = _(cit->second.display());
|
2002-04-29 15:56:36 +00:00
|
|
|
langs[i].second = cit->second.lang();
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
2002-05-01 14:43:38 +00:00
|
|
|
// Don't sort "ignore" and "reset"
|
|
|
|
vector<LanguagePair>::iterator begin = character_dlg ?
|
|
|
|
langs.begin() + 2 : langs.begin();
|
|
|
|
|
|
|
|
std::sort(begin, langs.end(), Sorter());
|
2002-04-30 15:07:03 +00:00
|
|
|
|
2002-04-29 15:56:36 +00:00
|
|
|
return langs;
|
|
|
|
}
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|