1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2014-2016 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU Lesser General Public License Version 2.1
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <config.h>
#include <asb-plugin.h>
const gchar *
asb_plugin_get_name (void)
{
return "gettext";
}
void
asb_plugin_add_globs (AsbPlugin *plugin, GPtrArray *globs)
{
asb_plugin_add_glob (globs, "/usr/share/locale/*/LC_MESSAGES/*.mo");
asb_plugin_add_glob (globs, "/usr/share/*/translations/*.qm");
asb_plugin_add_glob (globs, "/usr/lib64/*/locales/*.pak");
asb_plugin_add_glob (globs, "/usr/lib64/*/langpacks/*.xpi");
}
gboolean
asb_plugin_process_app (AsbPlugin *plugin,
AsbPackage *pkg,
AsbApp *app,
const gchar *tmpdir,
GError **error)
{
g_autofree gchar *prefix = NULL;
GPtrArray *translations;
/* skip for addons */
if (as_app_get_kind (AS_APP (app)) == AS_APP_KIND_ADDON)
return TRUE;
if (as_app_get_kind (AS_APP (app)) == AS_APP_KIND_GENERIC)
return TRUE;
/* auto-add this */
translations = as_app_get_translations (AS_APP (app));
if (translations->len == 0) {
g_autoptr(AsTranslation) translation = as_translation_new ();
as_translation_set_id (translation, asb_package_get_name (pkg));
as_app_add_translation (AS_APP (app), translation);
}
/* search for .mo files in the prefix */
prefix = g_build_filename (tmpdir, "usr", NULL);
return as_app_builder_search_translations (AS_APP (app), prefix, 25,
AS_APP_BUILDER_FLAG_USE_FALLBACKS,
NULL, error);
}
|