mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-10 21:16:24 +02:00
Add function ApplySafeSubstitution for translation strings with parameters
This commit is contained in:
1 parent
755269c90d
commit
8a59ed0062
10 files changed
+64
-23
No files matched your search
@@ -368,3 +368,31 @@ std::string UnescapeMenuString(const char *input, char *shortcutChar) {
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
std::string ApplySafeSubstitutions(const char *format, const std::string &string1, const std::string &string2, const std::string &string3) {
|
||||
size_t formatLen = strlen(format);
|
||||
std::string output;
|
||||
output.reserve(formatLen + 20);
|
||||
for (size_t i = 0; i < formatLen; i++) {
|
||||
char c = format[i];
|
||||
if (c != '%') {
|
||||
output.push_back(c);
|
||||
continue;
|
||||
}
|
||||
if (i >= formatLen - 1) {
|
||||
break;
|
||||
}
|
||||
switch (format[i + 1]) {
|
||||
case '1':
|
||||
output += string1; i++;
|
||||
break;
|
||||
case '2':
|
||||
output += string2; i++;
|
||||
break;
|
||||
case '3':
|
||||
output += string3; i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
Reference in new issue
Block a user