]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/frnt_lang.C
Overhaul the branches code.
[lyx.git] / src / frontends / controllers / frnt_lang.C
1 /**
2  * \file frnt_lang.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Angus Leeming
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13
14 #include "frnt_lang.h"
15 #include "gettext.h"
16 #include "language.h"
17
18 #include <algorithm>
19
20
21 using std::string;
22 using std::vector;
23
24
25 namespace {
26
27 struct Sorter {
28         bool operator()(frnt::LanguagePair const & lhs,
29                         frnt::LanguagePair const & rhs) const {
30                 return lhs.first < rhs.first;
31         }
32 };
33
34 } // namespace anon
35
36 namespace frnt {
37
38 vector<LanguagePair> const getLanguageData(bool character_dlg)
39 {
40         vector<LanguagePair>::size_type const size = character_dlg ?
41                 languages.size() + 2 : languages.size();
42
43         vector<LanguagePair> langs(size);
44
45         if (character_dlg) {
46                 langs[0].first = _("No change");
47                 langs[0].second = "ignore";
48                 langs[1].first = _("Reset");
49                 langs[1].second = "reset";
50         }
51
52         vector<string>::size_type i = character_dlg ? 2 : 0;
53         for (Languages::const_iterator cit = languages.begin();
54              cit != languages.end(); ++cit) {
55                 langs[i].first  = _(cit->second.display());
56                 langs[i].second = cit->second.lang();
57                 ++i;
58         }
59
60         // Don't sort "ignore" and "reset"
61         vector<LanguagePair>::iterator begin = character_dlg ?
62                 langs.begin() + 2 : langs.begin();
63
64         std::sort(begin, langs.end(), Sorter());
65
66         return langs;
67 }
68
69 } // namespace frnt