From e740ab00457cd7bbbf5a940d79a356ed0b918d1b Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Tue, 26 Jan 2016 15:56:45 +0000 Subject: Support the QT translation system Fixes: https://github.com/hughsie/appdata-tools/issues/26 --- libappstream-builder/plugins/asb-plugin-gettext.c | 29 ++++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'libappstream-builder') 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); } -- cgit v1.2.1