Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow loading all translations of name, description #247

Closed
adriaandegroot opened this issue Aug 19, 2019 · 1 comment
Closed

Allow loading all translations of name, description #247

adriaandegroot opened this issue Aug 19, 2019 · 1 comment

Comments

@adriaandegroot
Copy link

The following code (with appstream-qt):

AppStream::Pool pool;
pool.load();
AppStream::Component c = pool.componentsById("org.kde.krita.desktop").first();
qDebug() << c.description();

Gets the description (of Krita, in this case) in whatever the default language is; setting the environment variable LANGUAGE to fr, for instance, gets the French description.

There doesn't seem to be a way to get the description for any other language, though: setActiveLocale() on the component doesn't change the text that is returned. Calling it on the pool before load does load the other language -- but only that one.

So how does one get the description of a component, in all the languages for which a description is available for that component?

(something similar might be said about appstreamcli dump .. it only dumps the name and description in the current language, not all of them)

@ximion
Copy link
Owner

ximion commented Aug 19, 2019

This is possible: as_pool_set_locale (pool, "ALL") or pool.setLocale(QStringLiteral("ALL")) for the Qt version.
Please be aware though that as soon as you load all locale, you loose access to the system metadata cache and you will also actually load all locale into memory. The first thing means a slower pool loading speed, and the second one will mean a slight increase in memory consumption (should not be as notable as before though, due to unconditional caching).
So, depending on what you need, watching for system locale changes and reloading the pool then may be a batter plan. If you want all locale for e.g. further analysis, QA, or any other purpose, then using "ALL" is the way to go.

@ximion ximion closed this as completed Aug 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants