Re: [gpm] (more) useful popups



On Wed, 2007-03-21 at 09:59 +0000, Alfredo Matos wrote:
> This would make simpler comparisons, IMHO, and you could translate
> action i guess.

Yes, I worried about the strcmp, although worst case scenario is we hit
this once an hour and have to do 4xstrcmp's - not exactly a bit problem.

> But that would still leave the part you mentioned about
> tenses and sentences, which have no easy workaround, even for
> translation. So your approach makes code more readable and modifiable.
> And manageable for translation.

I've split the lines, and made the function more modular:

title = _("Laptop battery critically low");
remaining_text = gpm_get_timestring (unit->time_discharge);
time_text = gpm_manager_get_time_until_action_text (manager);

/* we have to do different warnings depending on the policy */
gpm_conf_get_string (manager->priv->conf, GPM_CONF_BATT_CRITICAL, &action);

/* use different text for different actions */
if (strcmp (action, ACTION_NOTHING) == 0) {
	action_text = g_strdup_printf (_("Plug in your AC adapter to avoid losing data."));

} else if (strcmp (action, ACTION_SUSPEND) == 0) {
	action_text = g_strdup_printf (_("This computer will suspend in %s if the AC is not connected."), time_text);

} else if (strcmp (action, ACTION_HIBERNATE) == 0) {
	action_text = g_strdup_printf (_("This computer will hibernate in %s if the AC is not connected."), time_text);

} else if (strcmp (action, ACTION_SHUTDOWN) == 0) {
	action_text = g_strdup_printf (_("This computer will shutdown in %s if the AC is not connected."), time_text);
}

message = g_strdup_printf (_("You have approximately <b>%s</b> of remaining battery life (%d%%). %s"),
			   remaining_text, unit->percentage, action_text);

g_free (action);
g_free (action_text);
g_free (remaining_text);
g_free (time_text);

Which is probably better.

Richard.





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]