mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-10 19:09:45 +01:00
UtilityClass.cpp: make time formats and numbers translatable
This replaces SDL_snprintf by VFormat for the time strings, and makes number_words get translated numbers. This commit is part of rewritten history of the localization branch. The original (unsquashed) commit history can be found here: https://github.com/Dav999-v/VVVVVV/tree/localization-orig
This commit is contained in:
parent
70a6cf407c
commit
93a3c40c39
1 changed files with 16 additions and 6 deletions
|
@ -5,7 +5,9 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
|
#include "Localization.h"
|
||||||
#include "Maths.h"
|
#include "Maths.h"
|
||||||
|
#include "VFormat.h"
|
||||||
|
|
||||||
static const char* GCChar(const SDL_GameControllerButton button)
|
static const char* GCChar(const SDL_GameControllerButton button)
|
||||||
{
|
{
|
||||||
|
@ -183,24 +185,27 @@ void UtilityClass::format_time(char* buffer, const size_t buffer_size, int secon
|
||||||
if (h > 0)
|
if (h > 0)
|
||||||
{
|
{
|
||||||
/* H:MM:SS / H:MM:SS.CC */
|
/* H:MM:SS / H:MM:SS.CC */
|
||||||
SDL_snprintf(buffer, buffer_size,
|
vformat_buf(buffer, buffer_size,
|
||||||
frames == -1 ? "%d:%02d:%02d" : "%d:%02d:%02d.%02d",
|
loc::gettext(frames == -1 ? "{hrs}:{min|digits=2}:{sec|digits=2}" : "{hrs}:{min|digits=2}:{sec|digits=2}.{cen|digits=2}"),
|
||||||
|
"hrs:int, min:int, sec:int, cen:int",
|
||||||
h, m, s, frames * 100 / 30
|
h, m, s, frames * 100 / 30
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (m > 0 || always_minutes || frames == -1)
|
else if (m > 0 || always_minutes || frames == -1)
|
||||||
{
|
{
|
||||||
/* M:SS / M:SS.CC */
|
/* M:SS / M:SS.CC */
|
||||||
SDL_snprintf(buffer, buffer_size,
|
vformat_buf(buffer, buffer_size,
|
||||||
frames == -1 ? "%d:%02d" : "%d:%02d.%02d",
|
loc::gettext(frames == -1 ? "{min}:{sec|digits=2}" : "{min}:{sec|digits=2}.{cen|digits=2}"),
|
||||||
|
"min:int, sec:int, cen:int",
|
||||||
m, s, frames * 100 / 30
|
m, s, frames * 100 / 30
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* S.CC */
|
/* S.CC */
|
||||||
SDL_snprintf(buffer, buffer_size,
|
vformat_buf(buffer, buffer_size,
|
||||||
"%d.%02d",
|
loc::gettext("{sec}.{cen|digits=2}"),
|
||||||
|
"sec:int, cen:int",
|
||||||
s, frames * 100 / 30
|
s, frames * 100 / 30
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -216,6 +221,11 @@ std::string UtilityClass::timestring( int t )
|
||||||
|
|
||||||
std::string UtilityClass::number_words( int _t )
|
std::string UtilityClass::number_words( int _t )
|
||||||
{
|
{
|
||||||
|
if (loc::lang != "en")
|
||||||
|
{
|
||||||
|
return loc::getnumber(_t);
|
||||||
|
}
|
||||||
|
|
||||||
static const std::string ones_place[] = {"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"};
|
static const std::string ones_place[] = {"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"};
|
||||||
static const std::string tens_place[] = {"Ten", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"};
|
static const std::string tens_place[] = {"Ten", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"};
|
||||||
static const std::string teens[] = {"Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"};
|
static const std::string teens[] = {"Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"};
|
||||||
|
|
Loading…
Reference in a new issue