Lolly 1.4.28
Loading...
Searching...
No Matches
Macros | Functions
locale.cpp File Reference
#include "locale.hpp"
#include <langinfo.h>
#include <locale>
#include "analyze.hpp"
#include "sys_utils.hpp"
Include dependency graph for locale.cpp:

Go to the source code of this file.

Macros

#define outline   Core_outline
 
#define extend   Core_extends
 

Functions

string locale_to_language (string s)
 
string language_to_locale (string s)
 
string language_to_local_ISO_charset (string s)
 
string get_locale_language ()
 
string get_locale_charset ()
 

Macro Definition Documentation

◆ outline

#define outline   Core_outline

Definition at line 29 of file locale.cpp.

◆ extend

#define extend   Core_extends

Definition at line 30 of file locale.cpp.

Function Documentation

◆ locale_to_language()

string locale_to_language ( string s)

Definition at line 155 of file locale.cpp.

155 {
156 if (N (s) > 5) s= s (0, 5);
157 if (s == "en_GB") return "british";
158 if (s == "zh_TW") return "taiwanese";
159 if (N (s) > 2) s= s (0, 2);
160 if (s == "bg") return "bulgarian";
161 if (s == "zh") return "chinese";
162 if (s == "hr") return "croatian";
163 if (s == "cs") return "czech";
164 if (s == "da") return "danish";
165 if (s == "nl") return "dutch";
166 if (s == "en") return "english";
167 if (s == "eo") return "esperanto";
168 if (s == "fi") return "finnish";
169 if (s == "fr") return "french";
170 if (s == "de") return "german";
171 if (s == "gr") return "greek";
172 if (s == "hu") return "hungarian";
173 if (s == "it") return "italian";
174 if (s == "ja") return "japanese";
175 if (s == "ko") return "korean";
176 if (s == "pl") return "polish";
177 if (s == "pt") return "portuguese";
178 if (s == "ro") return "romanian";
179 if (s == "ru") return "russian";
180 if (s == "sk") return "slovak";
181 if (s == "sl") return "slovene";
182 if (s == "es") return "spanish";
183 if (s == "sv") return "swedish";
184 if (s == "uk") return "ukrainian";
185 return "english";
186}
int N(array< T > a)
Get the length of the array.
Definition array.hpp:170

◆ language_to_locale()

string language_to_locale ( string s)

Definition at line 189 of file locale.cpp.

189 {
190 if (s == "american") return "en_US";
191 if (s == "british") return "en_GB";
192 if (s == "bulgarian") return "bg_BG";
193 if (s == "chinese") return "zh_CN";
194 if (s == "croatian") return "hr_HR";
195 if (s == "czech") return "cs_CZ";
196 if (s == "danish") return "da_DK";
197 if (s == "dutch") return "nl_NL";
198 if (s == "english") return "en_US";
199 if (s == "esperanto") return "eo_EO";
200 if (s == "finnish") return "fi_FI";
201 if (s == "french") return "fr_FR";
202 if (s == "german") return "de_DE";
203 if (s == "greek") return "gr_GR";
204 if (s == "hungarian") return "hu_HU";
205 if (s == "italian") return "it_IT";
206 if (s == "japanese") return "ja_JP";
207 if (s == "korean") return "ko_KR";
208 if (s == "polish") return "pl_PL";
209 if (s == "portuguese") return "pt_PT";
210 if (s == "romanian") return "ro_RO";
211 if (s == "russian") return "ru_RU";
212 if (s == "slovak") return "sk_SK";
213 if (s == "slovene") return "sl_SI";
214 if (s == "spanish") return "es_ES";
215 if (s == "swedish") return "sv_SV";
216 if (s == "taiwanese") return "zh_TW";
217 if (s == "ukrainian") return "uk_UA";
218 return "en_US";
219}

◆ language_to_local_ISO_charset()

string language_to_local_ISO_charset ( string s)

Definition at line 222 of file locale.cpp.

222 {
223 if (s == "bulgarian") return "ISO-8859-5";
224 if (s == "chinese") return "";
225 if (s == "croatian") return "ISO-8859-2";
226 if (s == "czech") return "ISO-8859-2";
227 if (s == "greek") return "ISO-8859-7";
228 if (s == "hungarian") return "ISO-8859-2";
229 if (s == "japanese") return "";
230 if (s == "korean") return "";
231 if (s == "polish") return "ISO-8859-2";
232 if (s == "romanian") return "ISO-8859-2";
233 if (s == "russian") return "ISO-8859-5";
234 if (s == "slovak") return "ISO-8859-2";
235 if (s == "slovene") return "ISO-8859-2";
236 if (s == "taiwanese") return "";
237 if (s == "ukrainian") return "ISO-8859-5";
238 return "ISO-8859-1";
239}

◆ get_locale_language()

string get_locale_language ( )

Definition at line 242 of file locale.cpp.

242 {
243#if defined(OS_MINGW) || defined(OS_WIN)
245#endif
246
247#ifdef OS_MACOS
249#endif
250
251#ifdef OS_WASM
252 return "english";
253#endif
254
255#ifdef OS_LINUX
256 string env_lan= get_env ("LC_ALL");
257 if (env_lan != "") return locale_to_language (env_lan);
258 env_lan= get_env ("LC_MESSAGES");
259 if (env_lan != "") return locale_to_language (env_lan);
260 env_lan= get_env ("LANG");
261 if (env_lan != "") return locale_to_language (env_lan);
262 env_lan= get_env ("GDM_LANG");
263 if (env_lan != "") return locale_to_language (env_lan);
264#endif
265 return "english";
266}
The list class represents a linked list.
Definition list.hpp:48
string locale_to_language(string s)
Definition locale.cpp:155
string get_env(string var)
Definition sys_utils.cpp:25

◆ get_locale_charset()

string get_locale_charset ( )

Definition at line 269 of file locale.cpp.

269 {
270 return "UTF-8";
271}