Greenbone Security Assistant
9.0.1
gsad_i18n.c
Go to the documentation of this file.
1
/* Copyright (C) 2015-2018 Greenbone Networks GmbH
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*/
19
25
#define _GNU_SOURCE
26
27
#include "
gsad_i18n.h
"
28
29
#include "
gsad_base.h
"
30
31
#include <assert.h>
32
#include <dirent.h>
33
#include <errno.h>
34
#include <glib.h>
35
#include <libintl.h>
36
#include <libxml/xpath.h>
37
#include <libxml/xpathInternals.h>
38
#include <locale.h>
39
#include <math.h>
40
#include <stdlib.h>
41
#include <string.h>
42
43
#undef G_LOG_DOMAIN
44
47
#define G_LOG_DOMAIN "gsad i18n"
48
61
gchar *
62
accept_language_to_env_fmt
(
const
char
*accept_language)
63
{
64
if
(accept_language == NULL)
65
return
g_strdup (
DEFAULT_GSAD_LANGUAGE
);
66
67
gchar *language;
68
// TODO: Convert to a colon-separated list of codes instead of
69
// just extracting the first one
70
gchar **prefs, *pref;
71
prefs = g_strsplit_set (accept_language,
",;"
, -1);
72
73
pref = prefs[0];
74
if
(pref)
75
{
76
char
*pos;
77
g_strstrip (pref);
78
pos = pref;
79
while
(pos[0] !=
'\0'
)
80
{
81
if
(pos[0] ==
'-'
)
82
pos[0] =
'_'
;
83
pos++;
84
};
85
}
86
language = g_strdup (pref ? pref :
DEFAULT_GSAD_LANGUAGE
);
87
g_strfreev (prefs);
88
89
return
language;
90
}
DEFAULT_GSAD_LANGUAGE
#define DEFAULT_GSAD_LANGUAGE
Default language code, used when Accept-Language header is missing.
Definition:
gsad_i18n.h:33
accept_language_to_env_fmt
gchar * accept_language_to_env_fmt(const char *accept_language)
Convert an Accept-Language string to the LANGUAGE env variable form.
Definition:
gsad_i18n.c:62
gsad_i18n.h
I18n support for Greenbone Security Assistant.
gsad_base.h
Headers/structs used generally in GSA.
src
gsad_i18n.c
Generated on Sat May 23 2020 00:00:00 for Greenbone Security Assistant by
1.8.17