]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/frnt_lang.C
some support for pch
[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 lyx {
26 namespace frontend {
27
28 namespace {
29
30 struct Sorter
31         : public std::binary_function<LanguagePair,
32                                       LanguagePair, bool>
33 {
34         bool operator()(LanguagePair const & lhs,
35                         LanguagePair const & rhs) const {
36                 return lhs.first < rhs.first;
37         }
38 };
39
40 } // namespace anon
41
42
43 vector<LanguagePair> const getLanguageData(bool character_dlg)
44 {
45         vector<LanguagePair>::size_type const size = character_dlg ?
46                 languages.size() + 2 : languages.size();
47
48         vector<LanguagePair> langs(size);
49
50         if (character_dlg) {
51                 langs[0].first = _("No change");
52                 langs[0].second = "ignore";
53                 langs[1].first = _("Reset");
54                 langs[1].second = "reset";
55         }
56
57         vector<string>::size_type i = character_dlg ? 2 : 0;
58         for (Languages::const_iterator cit = languages.begin();
59              cit != languages.end(); ++cit) {
60                 langs[i].first  = _(cit->second.display());
61                 langs[i].second = cit->second.lang();
62                 ++i;
63         }
64
65         // Don't sort "ignore" and "reset"
66         vector<LanguagePair>::iterator begin = character_dlg ?
67                 langs.begin() + 2 : langs.begin();
68
69         std::sort(begin, langs.end(), Sorter());
70
71         return langs;
72 }
73
74 } // namespace frontend
75 } // namespace lyx