Author: pulkomandy Date: 2010-06-29 11:34:42 +0200 (Tue, 29 Jun 2010) New Revision: 37297 Changeset: http://dev.haiku-os.org/changeset/37297/haiku Modified: haiku/trunk/src/bin/dstcheck.cpp Log: Patch by Jorma Karvonnen, mostly rewritten by me : * dstcheck is now localized * it also localize the date using the locale kit instead of strftime I also added a way to force the message to display, because it helps testing a lot. Run "dstcheck force" for that. Modified: haiku/trunk/src/bin/dstcheck.cpp =================================================================== --- haiku/trunk/src/bin/dstcheck.cpp 2010-06-28 22:16:07 UTC (rev 37296) +++ haiku/trunk/src/bin/dstcheck.cpp 2010-06-29 09:34:42 UTC (rev 37297) @@ -6,7 +6,10 @@ #include <Alert.h> #include <Application.h> +#include <Catalog.h> #include <FindDirectory.h> +#include <Locale.h> +#include <LocaleRoster.h> #include <MessageRunner.h> #include <Roster.h> #include <String.h> @@ -17,6 +20,10 @@ #include <unistd.h> +#undef B_TRANSLATE_CONTEXT +#define B_TRANSLATE_CONTEXT "dstcheck" + + const uint32 TIMEDALERT_UPDATE = 'taup'; class TimedAlert : public BAlert { @@ -67,19 +74,24 @@ void TimedAlert::GetLabel(BString &string) { - string = "Attention!\n\nBecause of the switch from daylight saving time, " - "your computer's clock may be an hour off. Currently, your computer " - "thinks it is "; + string = B_TRANSLATE("Attention!\n\nBecause of the switch from daylight " + "saving time, your computer's clock may be an hour off. Currently, " + "your computer thinks it is "); time_t t; struct tm tm; char timestring[15]; time(&t); localtime_r(&t, &tm); - strftime(timestring, 15, "%I:%M %p", &tm); + + BCountry* here; + be_locale_roster->GetDefaultCountry(&here); + + here->FormatTime(timestring, 15, t, false); + string += timestring; - string += ".\n\nIs this the correct time?"; + string += B_TRANSLATE(".\n\nIs this the correct time?"); } @@ -89,6 +101,7 @@ int main(int argc, char **argv) { + BCatalog fCatalog; time_t t; struct tm tm; tzset(); @@ -121,20 +134,24 @@ dst = tm.tm_isdst; } - if (dst != tm.tm_isdst) { - BApplication app("application/x-vnd.Haiku-cmd-dstconfig"); + if (dst != tm.tm_isdst || argc > 1) { + BApplication app("application/x-vnd.Haiku-cmd-dstconfig"); + be_locale->GetAppCatalog(&fCatalog); BString string; TimedAlert::GetLabel(string); - int32 index = (new TimedAlert("timedAlert", string.String(), "Ask me later", "Yes", "No"))->Go(); + int32 index = (new TimedAlert("timedAlert", string.String(), + B_TRANSLATE("Ask me later"), B_TRANSLATE("Yes"), + B_TRANSLATE("No")))->Go(); if (index == 0) exit(0); if (index == 2) { index = (new BAlert("dstcheck", - "Would you like to set the clock using the Time and\nDate preference utility?", - "No", "Yes"))->Go(); + B_TRANSLATE("Would you like to set the clock using the Time and" + "\nDate preference utility?"), + B_TRANSLATE("No"), B_TRANSLATE("Yes")))->Go(); if (index == 1) be_roster->Launch("application/x-vnd.Haiku-Time");