Getting localized action message and descriptions

David Zeuthen zeuthen at gmail.com
Mon Jan 24 08:18:40 PST 2011


Hi,

On Mon, Jan 24, 2011 at 11:52 AM, Gökçen Eraslan <gokcen at pardus.org.tr> wrote:
> Hello,
>
> In a program we wrote, we use polkit_action_description_get_description and
> polkit_action_description_get_message functions of polkit to display
> information about actions. But we always see action messages and description
> in English even if actions have translations in other languages. (We also use
> setlocale to set the locale according to the environmetn variables.)
>
> As far as I can see, the only thing about localization in the API is the
> locale parameter of polkit_authority_register_authentication_agent function.
> But since the application we write is not actually an agent, I think this is
> not suitable for us.
>
> Is there any way to get localized action message and descriptions for
> applications those are not agents?

The D-Bus API takes the locale as a parameter:

 http://hal.freedesktop.org/docs/polkit/eggdbus-interface-org.freedesktop.PolicyKit1.Authority.html#eggdbus-method-org.freedesktop.PolicyKit1.Authority.EnumerateActions

You can verify that it works by calling this method like this

 $ gdbus call --system --dest org.freedesktop.PolicyKit1 --object-path
/org/freedesktop/PolicyKit1/Authority --method
org.freedesktop.PolicyKit1.Authority.EnumerateActions da_DK

However the GObject API passes the empty string for the locale

 http://cgit.freedesktop.org/PolicyKit/tree/src/polkit/polkitauthority.c#n645

We should probably change the GObject API to pass getenv("LANG") if
non-NULL or something.

     David


More information about the polkit-devel mailing list