Skip to content

Commit b46e31e

Browse files
committed
Fix crashing if translated string is blank
Fixes #2571
1 parent 0012be6 commit b46e31e

File tree

6 files changed

+33
-0
lines changed

6 files changed

+33
-0
lines changed

imageview/arm9/source/language.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "common/twlmenusettings.h"
1010
#include "common/inifile.h"
11+
// #include "common/logging.h"
1112

1213
#define STRING(what,def) std::string STR_##what;
1314
#include "language.inl"
@@ -18,6 +19,11 @@
1819
*/
1920
std::string getString(CIniFile &ini, const std::string &item, const std::string &defaultValue) {
2021
std::string out = ini.GetString("LANGUAGE", item, defaultValue);
22+
// logPrint("%s: %s\n", item.c_str(), out.c_str());
23+
if (out == "") {
24+
// Fallback to default string if translated string is blank
25+
out = defaultValue;
26+
}
2127

2228
// Convert "\n" to actual newlines
2329
for (uint i = 0; i < out.length() - 1; i++) {

manual/arm9/source/language.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "common/twlmenusettings.h"
1010
#include "common/inifile.h"
11+
// #include "common/logging.h"
1112

1213
#define STRING(what,def) std::string STR_##what;
1314
#include "language.inl"
@@ -18,6 +19,11 @@
1819
*/
1920
std::string getString(CIniFile &ini, const std::string &item, const std::string &defaultValue) {
2021
std::string out = ini.GetString("LANGUAGE", item, defaultValue);
22+
// logPrint("%s: %s\n", item.c_str(), out.c_str());
23+
if (out == "") {
24+
// Fallback to default string if translated string is blank
25+
out = defaultValue;
26+
}
2127

2228
// Convert "\n" to actual newlines
2329
for (uint i = 0; i < out.length() - 1; i++) {

quickmenu/arm9/source/language.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "common/twlmenusettings.h"
1010
#include "common/inifile.h"
11+
// #include "common/logging.h"
1112

1213
#define STRING(what,def) std::string STR_##what;
1314
#include "language.inl"
@@ -18,6 +19,11 @@
1819
*/
1920
std::string getString(CIniFile &ini, const std::string &item, const std::string &defaultValue) {
2021
std::string out = ini.GetString("LANGUAGE", item, defaultValue);
22+
// logPrint("%s: %s\n", item.c_str(), out.c_str());
23+
if (out == "") {
24+
// Fallback to default string if translated string is blank
25+
out = defaultValue;
26+
}
2127

2228
// Convert "\n" to actual newlines
2329
for (uint i = 0; i < out.length() - 1; i++) {

romsel_dsimenutheme/arm9/source/language.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
*/
2020
std::string getString(CIniFile &ini, const std::string &item, const std::string &defaultValue) {
2121
std::string out = ini.GetString("LANGUAGE", item, defaultValue);
22+
// logPrint("%s: %s\n", item.c_str(), out.c_str());
23+
if (out == "") {
24+
// Fallback to default string if translated string is blank
25+
out = defaultValue;
26+
}
2227

2328
// Convert "\n" to actual newlines
2429
for (uint i = 0; i < out.length() - 1; i++) {

settings/arm9/source/language.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ extern bool useTwlCfg;
2121
*/
2222
std::string getString(CIniFile &ini, const std::string &item, const std::string &defaultValue) {
2323
std::string out = ini.GetString("LANGUAGE", item, defaultValue);
24+
// logPrint("%s: %s\n", item.c_str(), out.c_str());
25+
if (out == "") {
26+
// Fallback to default string if translated string is blank
27+
out = defaultValue;
28+
}
2429

2530
// Convert "\n" to actual newlines
2631
for (uint i = 0; i < out.length() - 1; i++) {

title/arm9/source/language.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
*/
2020
std::string getString(CIniFile &ini, const std::string &item, const std::string &defaultValue) {
2121
std::string out = ini.GetString("LANGUAGE", item, defaultValue);
22+
// logPrint("%s: %s\n", item.c_str(), out.c_str());
23+
if (out == "") {
24+
// Fallback to default string if translated string is blank
25+
out = defaultValue;
26+
}
2227

2328
// Convert "\n" to actual newlines
2429
for (uint i = 0; i < out.length() - 1; i++) {

0 commit comments

Comments
 (0)