[virt-tools-list] [libosinfo v3 2/3] Translate all (potentially) user visible strings

Zeeshan Ali (Khattak) zeeshanak at gnome.org
Wed Oct 31 13:37:56 UTC 2012


On Wed, Oct 31, 2012 at 11:30 AM, Christophe Fergeau
<cfergeau at redhat.com> wrote:
> On Tue, Oct 30, 2012 at 11:08:52PM +0200, Zeeshan Ali (Khattak) wrote:
>> diff --git a/tools/osinfo-db-validate.c b/tools/osinfo-db-validate.c
>> index f5855d1..2760b00 100644
>> --- a/tools/osinfo-db-validate.c
>> +++ b/tools/osinfo-db-validate.c
>> @@ -33,7 +33,7 @@ static gboolean verbose = FALSE;
>>
>>  static const GOptionEntry entries[] = {
>>      { "verbose", 'v', 0, G_OPTION_ARG_NONE, (void*)&verbose,
>> -      "Verbose progress information", NULL, },
>> +      N_("Verbose progress information"), NULL, },
>>      { NULL, 0, 0, 0, NULL, NULL, NULL }
>>  };
>>
>> @@ -255,12 +256,13 @@ gint main(gint argc, gchar **argv)
>>
>>      g_type_init();
>>
>> -    context = g_option_context_new("- Validate XML documents ");
>> +    context = g_option_context_new(_("- Validate XML documents "));
>>
>> -    g_option_context_add_main_entries(context, entries, NULL);
>> +    g_option_context_add_main_entries(context, entries, GETTEXT_PACKAGE);
>
> This change is enough to get everything translated, no need to add a call
> to g_option_context_set_translation_domain ?

Yes, I tested this to work against my dummy translation. :)

$ LANG=fi_FI.utf8 osinfo-db-validate --help
Käyttö:
  osinfo-db-validate [VALITSIN…] - Validate XML documents

Ohjevalitsimet:
  -h, --help        Näytä ohjevalitsimet

Sovelluksen valitsimet:
  -v, --verbose     Something totally weird
                            ^^^^^^^^^^^^^^

>> diff --git a/tools/osinfo-query.c b/tools/osinfo-query.c
>> index e68be90..eff323a 100644
>> --- a/tools/osinfo-query.c
>> +++ b/tools/osinfo-query.c
>> @@ -287,10 +287,10 @@ static gboolean print_results_text(OsinfoList *list,
>>              g_print(" | ");
>>          first = FALSE;
>>
>> -        if (strlen(labels[i].label) > labels[i].width)
>> +        if (strlen(gettext(labels[i].label)) > labels[i].width)
>>              pad = 0;
>>          else
>> -            pad = labels[i].width - strlen(labels[i].label);
>> +            pad = labels[i].width - strlen(gettext(labels[i].label));
>
> I'd have a slight preference for _() here rather than gettext(), but I'm
> fine either way.

The example code in N_ docs in glib reference manual seems to suggest
that gettext is more appropriate in this context.

-- 
Regards,

Zeeshan Ali (Khattak)
FSF member#5124




More information about the virt-tools-list mailing list