summaryrefslogtreecommitdiff
path: root/libappstream-builder
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2016-01-26 15:56:45 +0000
committerRichard Hughes <richard@hughsie.com>2016-01-26 15:56:55 +0000
commite740ab00457cd7bbbf5a940d79a356ed0b918d1b (patch)
tree5ae1e2abd3bfd8001038bda62b873b2aa853a681 /libappstream-builder
parent50d31f68ffe161195f6aff606f824bdca7805ea9 (diff)
downloadappstream-glib-e740ab00457cd7bbbf5a940d79a356ed0b918d1b.tar.gz
Support the QT translation system
Fixes: https://github.com/hughsie/appdata-tools/issues/26
Diffstat (limited to 'libappstream-builder')
-rw-r--r--libappstream-builder/plugins/asb-plugin-gettext.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/libappstream-builder/plugins/asb-plugin-gettext.c b/libappstream-builder/plugins/asb-plugin-gettext.c
index 1f4d4a7..bb035bc 100644
--- a/libappstream-builder/plugins/asb-plugin-gettext.c
+++ b/libappstream-builder/plugins/asb-plugin-gettext.c
@@ -39,6 +39,7 @@ 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");
}
/**
@@ -51,20 +52,20 @@ asb_plugin_process_app (AsbPlugin *plugin,
const gchar *tmpdir,
GError **error)
{
- g_autofree gchar *root = NULL;
- g_auto(GStrv) intl_domains = NULL;
+ g_autofree gchar *prefix = NULL;
+ GPtrArray *translations;
- /* search for .mo files in the prefix */
- root = g_build_filename (tmpdir, "/usr/share/locale", NULL);
- if (!g_file_test (root, G_FILE_TEST_EXISTS))
- 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);
+ }
- /* generate */
- intl_domains = g_strsplit (asb_package_get_name (pkg), ",", -1);
- return as_app_gettext_search_path (AS_APP (app),
- root,
- intl_domains,
- 25,
- NULL,
- error);
+ /* 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);
}