Skip to content

Commit fd9960f

Browse files
committed
Adding localization support to cheevos.c
1 parent 9d67cc9 commit fd9960f

File tree

3 files changed

+73
-23
lines changed

3 files changed

+73
-23
lines changed

cheevos/cheevos.c

+33-23
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ static void rcheevos_activate_achievements(void)
264264
{
265265
char buffer[256];
266266
buffer[0] = '\0';
267-
/* TODO/FIXME - localize */
268267
snprintf(buffer, sizeof(buffer),
269268
"Could not activate achievement %u \"%s\": %s",
270269
achievement->id, achievement->title, rc_error_str(result));
@@ -682,17 +681,18 @@ int rcheevos_get_richpresence(char *s, size_t len)
682681

683682
if (ret <= 0 && rcheevos_locals.game.title)
684683
{
685-
/* TODO/FIXME - localize */
686-
size_t _len = strlcpy(s, "Playing ", len);
687-
strlcpy(s + _len, rcheevos_locals.game.title, len - _len);
684+
int _len = snprintf(s, len, msg_hash_to_str(MSG_CHEEVOS_RICH_PRESENCE_PLAYING),
685+
rcheevos_locals.game.title);
686+
687+
if (_len < 0)
688+
return -1;
688689
}
689690
return ret;
690691
}
691692
if (rcheevos_locals.game.title)
692693
{
693-
/* TODO/FIXME - localize */
694-
size_t _len = strlcpy(s, "Spectating ", len);
695-
return (int)strlcpy(s + _len, rcheevos_locals.game.title, len - _len);
694+
return snprintf(s, len, msg_hash_to_str(MSG_CHEEVOS_RICH_PRESENCE_SPECTATING),
695+
rcheevos_locals.game.title);
696696
}
697697
return 0;
698698
}
@@ -936,7 +936,6 @@ static void rcheevos_activate_leaderboards(void)
936936
{
937937
char buffer[256];
938938
buffer[0] = '\0';
939-
/* TODO/FIXME - localize */
940939
snprintf(buffer, sizeof(buffer),
941940
"Could not activate leaderboard %u \"%s\": %s",
942941
leaderboard->id, leaderboard->title, rc_error_str(result));
@@ -1229,9 +1228,8 @@ void rcheevos_validate_config_settings(void)
12291228
{
12301229
char buffer[256];
12311230
buffer[0] = '\0';
1232-
/* TODO/FIXME - localize */
12331231
snprintf(buffer, sizeof(buffer),
1234-
"Hardcore paused. You cannot earn hardcore achievements for %s using %s",
1232+
msg_hash_to_str(MSG_CHEEVOS_HARDCORE_PAUSED_INVALID_CORE),
12351233
rc_console_name(rcheevos_locals.game.console_id), sysinfo->library_name);
12361234
CHEEVOS_LOG(RCHEEVOS_TAG "%s\n", buffer);
12371235
rcheevos_pause_hardcore();
@@ -1742,31 +1740,44 @@ static void rcheevos_show_game_placard(void)
17421740
number_of_active++;
17431741
}
17441742

1745-
/* TODO/FIXME - localize strings */
17461743
if (number_of_core == 0)
1747-
strlcpy(msg, "This game has no achievements.", sizeof(msg));
1744+
strlcpy(msg, msg_hash_to_str(MSG_CHEEVOS_GAME_HAS_NO_ACHIEVEMENTS), sizeof(msg));
17481745
else if (!number_of_unsupported)
17491746
{
17501747
if (settings->bools.cheevos_start_active)
17511748
snprintf(msg, sizeof(msg),
1752-
"All %d achievements activated for this session.",
1749+
msg_hash_to_str(MSG_CHEEVOS_ALL_ACHIEVEMENTS_ACTIVATED),
17531750
number_of_core);
17541751
else
17551752
snprintf(msg, sizeof(msg),
1756-
"You have %d of %d achievements unlocked.",
1753+
msg_hash_to_str(MSG_CHEEVOS_NUMBER_ACHIEVEMENTS_UNLOCKED),
17571754
number_of_core - number_of_active, number_of_core);
17581755
}
17591756
else
17601757
{
1758+
char number_of_unsupported_msg[64];
1759+
int _len;
1760+
1761+
snprintf(number_of_unsupported_msg,
1762+
sizeof(number_of_unsupported_msg),
1763+
msg_hash_to_str(MSG_CHEEVOS_UNSUPPORTED_COUNT),
1764+
number_of_unsupported);
1765+
17611766
if (settings->bools.cheevos_start_active)
1762-
snprintf(msg, sizeof(msg),
1763-
"All %d achievements activated for this session (%d unsupported).",
1764-
number_of_core, number_of_unsupported);
1767+
_len = snprintf(msg, sizeof(msg),
1768+
msg_hash_to_str(MSG_CHEEVOS_ALL_ACHIEVEMENTS_ACTIVATED),
1769+
number_of_core);
17651770
else
1766-
snprintf(msg, sizeof(msg),
1767-
"You have %d of %d achievements unlocked (%d unsupported).",
1768-
number_of_core - number_of_active - number_of_unsupported,
1769-
number_of_core, number_of_unsupported);
1771+
_len = snprintf(msg, sizeof(msg),
1772+
msg_hash_to_str(MSG_CHEEVOS_NUMBER_ACHIEVEMENTS_UNLOCKED),
1773+
number_of_core - number_of_active - number_of_unsupported,
1774+
number_of_core);
1775+
1776+
_len += snprintf(msg + _len, sizeof(msg) - _len,
1777+
" (%s)", number_of_unsupported_msg);
1778+
1779+
if (_len < 0)
1780+
return;
17701781
}
17711782

17721783
msg[sizeof(msg) - 1] = 0;
@@ -2164,9 +2175,8 @@ static void rcheevos_login_callback(void* userdata)
21642175
{
21652176
char msg[256];
21662177
msg[0] = '\0';
2167-
/* TODO/FIXME - localize */
21682178
snprintf(msg, sizeof(msg),
2169-
"RetroAchievements: Logged in as \"%s\".",
2179+
msg_hash_to_str(MSG_CHEEVOS_LOGGED_IN_AS_USER),
21702180
rcheevos_locals.displayname);
21712181
runloop_msg_queue_push(msg, 0, 2 * 60, false, NULL,
21722182
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);

intl/msg_hash_us.h

+32
Original file line numberDiff line numberDiff line change
@@ -13668,6 +13668,38 @@ MSG_HASH(
1366813668
MSG_CHEEVOS_HARDCORE_MODE_ENABLE,
1366913669
"Achievements Hardcore Mode Enabled, save state & rewind were disabled."
1367013670
)
13671+
MSG_HASH(
13672+
MSG_CHEEVOS_HARDCORE_PAUSED_INVALID_CORE,
13673+
"Hardcore paused. You cannot earn hardcore achievements for %s using %s"
13674+
)
13675+
MSG_HASH(
13676+
MSG_CHEEVOS_LOGGED_IN_AS_USER,
13677+
"RetroAchievements: Logged in as \"%s\"."
13678+
)
13679+
MSG_HASH(
13680+
MSG_CHEEVOS_GAME_HAS_NO_ACHIEVEMENTS,
13681+
"This game has no achievements."
13682+
)
13683+
MSG_HASH(
13684+
MSG_CHEEVOS_ALL_ACHIEVEMENTS_ACTIVATED,
13685+
"All %d achievements activated for this session"
13686+
)
13687+
MSG_HASH(
13688+
MSG_CHEEVOS_NUMBER_ACHIEVEMENTS_UNLOCKED,
13689+
"You have %d of %d achievements unlocked"
13690+
)
13691+
MSG_HASH(
13692+
MSG_CHEEVOS_UNSUPPORTED_COUNT,
13693+
"%d unsupported"
13694+
)
13695+
MSG_HASH(
13696+
MSG_CHEEVOS_RICH_PRESENCE_PLAYING,
13697+
"Playing %s"
13698+
)
13699+
MSG_HASH(
13700+
MSG_CHEEVOS_RICH_PRESENCE_SPECTATING,
13701+
"Spectating %s"
13702+
)
1367113703
MSG_HASH(
1367213704
MSG_COMPARING_WITH_KNOWN_MAGIC_NUMBERS,
1367313705
"Comparing with known magic numbers..."

msg_hash.h

+8
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,14 @@ enum msg_hash_enums
473473
MSG_REWIND_REACHED_END,
474474
MSG_FAILED_TO_START_MOVIE_RECORD,
475475
MSG_CHEEVOS_HARDCORE_MODE_ENABLE,
476+
MSG_CHEEVOS_HARDCORE_PAUSED_INVALID_CORE,
477+
MSG_CHEEVOS_LOGGED_IN_AS_USER,
478+
MSG_CHEEVOS_GAME_HAS_NO_ACHIEVEMENTS,
479+
MSG_CHEEVOS_ALL_ACHIEVEMENTS_ACTIVATED,
480+
MSG_CHEEVOS_NUMBER_ACHIEVEMENTS_UNLOCKED,
481+
MSG_CHEEVOS_UNSUPPORTED_COUNT,
482+
MSG_CHEEVOS_RICH_PRESENCE_PLAYING,
483+
MSG_CHEEVOS_RICH_PRESENCE_SPECTATING,
476484
MSG_STATE_SLOT,
477485
MSG_REPLAY_SLOT,
478486
MSG_STARTING_MOVIE_RECORD_TO,

0 commit comments

Comments
 (0)