Allow using %f with translated message
This commit is contained in:
parent
e122d045cc
commit
490b865ddd
@ -58,15 +58,15 @@ protected:
|
||||
if (isSuccess())
|
||||
{
|
||||
int rank = -1;
|
||||
float score = 0.0;
|
||||
float score = 0.0f;
|
||||
getXMLData()->get("rank", &rank);
|
||||
getXMLData()->get("scores", &score);
|
||||
if (rank > 0)
|
||||
{
|
||||
// I18N: In the network player dialog show rank and
|
||||
// score of a player
|
||||
result = _("%s has a rank of %d with score %d.",
|
||||
m_name, rank, (int)score);
|
||||
result = _("%s has a rank of %d with score %f.",
|
||||
m_name, rank, score);
|
||||
}
|
||||
}
|
||||
*done = true;
|
||||
|
@ -358,7 +358,8 @@ namespace StringUtils
|
||||
}
|
||||
else
|
||||
{
|
||||
if(sv[i][1]=='s' || sv[i][1]=='d' || sv[i][1]=='i')
|
||||
if(sv[i][1]=='s' || sv[i][1]=='d' || sv[i][1]=='i' ||
|
||||
sv[i][1]=='f')
|
||||
{
|
||||
if (insertValID >= all_vals.size())
|
||||
{
|
||||
@ -430,7 +431,8 @@ namespace StringUtils
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sv[i][1]=='s' || sv[i][1]=='d' || sv[i][1]=='i')
|
||||
if (sv[i][1]=='s' || sv[i][1]=='d' || sv[i][1]=='i' ||
|
||||
sv[i][1]=='f')
|
||||
{
|
||||
if (insertValID >= all_vals.size())
|
||||
{
|
||||
|
@ -21,6 +21,7 @@
|
||||
#ifndef HEADER_STRING_UTILS_HPP
|
||||
#define HEADER_STRING_UTILS_HPP
|
||||
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
@ -74,6 +75,16 @@ namespace StringUtils
|
||||
return oss.str();
|
||||
} // toString template
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
template <>
|
||||
inline std::string toString(const double& any)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss.precision(std::numeric_limits<double>::max_digits10);
|
||||
oss << any;
|
||||
return oss.str();
|
||||
} // toString template
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Specialisiation for bools to return 'true' or 'false'*/
|
||||
inline std::string toString(const bool& b)
|
||||
@ -115,7 +126,7 @@ namespace StringUtils
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/**
|
||||
* Replaces the first %s or %i/%d in the string with the first value
|
||||
* Replaces the first %s or %i/%d/%f in the string with the first value
|
||||
* converted to a string), the 2nd %s or %d with the second value etc.
|
||||
* So this is basically a simplified s(n)printf replacement, but doesn't
|
||||
* do any fancy formatting (and no type checks either - so you can print
|
||||
|
Loading…
Reference in New Issue
Block a user