Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(cheevos) use translated strings for achievement messages #16987

Merged
merged 2 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 56 additions & 51 deletions cheevos/cheevos.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,11 +756,8 @@ int rcheevos_get_richpresence(char* s, size_t len)
if (!rcheevos_is_game_loaded())
return 0;

/* TODO/FIXME - localize */
{
size_t _len = strlcpy(s, "Spectating ", len);
return (int)strlcpy(s + _len, rc_client_get_game_info(rcheevos_locals.client)->title, len - _len);
}
return snprintf(s, len, msg_hash_to_str(MSG_CHEEVOS_RICH_PRESENCE_SPECTATING),
rc_client_get_game_info(rcheevos_locals.client)->title);
}

return (int)rc_client_get_rich_presence_message(rcheevos_locals.client, s, (size_t)len);
Expand Down Expand Up @@ -1750,8 +1747,8 @@ void rcheevos_validate_config_settings(void)
* auto setting should achieve the most accurate frame rate anyway, so
* disallow any manual values */
if (!settings->bools.video_frame_delay_auto && settings->uints.video_frame_delay != 0) {
const char* error = "Hardcore paused. Manual video frame delay setting not allowed.";
CHEEVOS_LOG(RCHEEVOS_TAG "%s\n", error);
const char* error = msg_hash_to_str(MSG_CHEEVOS_HARDCORE_PAUSED_MANUAL_FRAME_DELAY);
CHEEVOS_LOG(RCHEEVOS_TAG "%s\n", msg_hash_to_str_us(MSG_CHEEVOS_HARDCORE_PAUSED_MANUAL_FRAME_DELAY));
rcheevos_pause_hardcore();

runloop_msg_queue_push(error, 0, 4 * 60, false, NULL,
Expand All @@ -1768,8 +1765,8 @@ void rcheevos_validate_config_settings(void)
* running at less than 60Hz because 1 is the default value - many users
* wouldn't know how to change it to auto. */
if (settings->uints.video_swap_interval > 1) {
const char* error = "Hardcore paused. vsync swap interval above 1 not allowed.";
CHEEVOS_LOG(RCHEEVOS_TAG "%s\n", error);
const char* error = msg_hash_to_str(MSG_CHEEVOS_HARDCORE_PAUSED_VSYNC_SWAP_INTERVAL);
CHEEVOS_LOG(RCHEEVOS_TAG "%s\n", msg_hash_to_str_us(MSG_CHEEVOS_HARDCORE_PAUSED_VSYNC_SWAP_INTERVAL));
rcheevos_pause_hardcore();

runloop_msg_queue_push(error, 0, 4 * 60, false, NULL,
Expand All @@ -1780,8 +1777,8 @@ void rcheevos_validate_config_settings(void)
/* this causes N blank frames to be rendered between real frames, thus
* can slow down the actual number of rendered frames per second. */
if (settings->uints.video_black_frame_insertion > 0) {
const char* error = "Hardcore paused. Black frame insertion not allowed.";
CHEEVOS_LOG(RCHEEVOS_TAG "%s\n", error);
const char* error = msg_hash_to_str(MSG_CHEEVOS_HARDCORE_PAUSED_BLACK_FRAME_INSERTION);
CHEEVOS_LOG(RCHEEVOS_TAG "%s\n", msg_hash_to_str_us(MSG_CHEEVOS_HARDCORE_PAUSED_BLACK_FRAME_INSERTION));
rcheevos_pause_hardcore();

runloop_msg_queue_push(error, 0, 4 * 60, false, NULL,
Expand All @@ -1793,8 +1790,8 @@ void rcheevos_validate_config_settings(void)
the purposes of shaders that update faster than content. Thus
* can slow down the actual number of rendered frames per second. */
if (settings->uints.video_shader_subframes > 1) {
const char* error = "Hardcore paused. Shader subframes not allowed.";
CHEEVOS_LOG(RCHEEVOS_TAG "%s\n", error);
const char* error = msg_hash_to_str(MSG_CHEEVOS_HARDCORE_PAUSED_SHADER_SUBFRAMES);
CHEEVOS_LOG(RCHEEVOS_TAG "%s\n", msg_hash_to_str_us(MSG_CHEEVOS_HARDCORE_PAUSED_SHADER_SUBFRAMES));
rcheevos_pause_hardcore();

runloop_msg_queue_push(error, 0, 4 * 60, false, NULL,
Expand All @@ -1815,9 +1812,11 @@ void rcheevos_validate_config_settings(void)
if (!rc_libretro_is_setting_allowed(disallowed_settings, key, val))
{
char buffer[128];
/* TODO/FIXME - localize */
snprintf(buffer, sizeof(buffer), "Hardcore paused. Setting not allowed: %s=%s", key, val);
snprintf(buffer, sizeof(buffer),
msg_hash_to_str_us(MSG_CHEEVOS_HARDCORE_PAUSED_SETTING_NOT_ALLOWED), key, val);
CHEEVOS_LOG(RCHEEVOS_TAG "%s\n", buffer);
snprintf(buffer, sizeof(buffer),
msg_hash_to_str(MSG_CHEEVOS_HARDCORE_PAUSED_SETTING_NOT_ALLOWED), key, val);
rcheevos_pause_hardcore();

runloop_msg_queue_push(buffer, 0, 4 * 60, false, NULL,
Expand All @@ -1839,10 +1838,8 @@ void rcheevos_validate_config_settings(void)
if (console_id && !rc_libretro_is_system_allowed(sysinfo->library_name, console_id))
{
char buffer[256];
buffer[0] = '\0';
/* TODO/FIXME - localize */
snprintf(buffer, sizeof(buffer),
"Hardcore paused. You cannot earn hardcore achievements for %s using %s",
msg_hash_to_str(MSG_CHEEVOS_HARDCORE_PAUSED_SYSTEM_NOT_FOR_CORE),
rc_console_name(console_id), sysinfo->library_name);
CHEEVOS_LOG(RCHEEVOS_TAG "%s\n", buffer);
rcheevos_pause_hardcore();
Expand Down Expand Up @@ -2324,7 +2321,8 @@ static void rc_hash_reset_cdreader_hooks(void)

static void rcheevos_show_game_placard(void)
{
char msg[256], unsupported_clause[64] = "";
char msg[256];
int len;
const settings_t* settings = config_get_ptr();
rc_client_user_game_summary_t summary;

Expand All @@ -2334,37 +2332,46 @@ static void rcheevos_show_game_placard(void)

rc_client_get_user_game_summary(rcheevos_locals.client, &summary);

if (summary.num_unsupported_achievements)
{
snprintf(unsupported_clause, sizeof(unsupported_clause), " (%d unsupported)",
(int)summary.num_unsupported_achievements);
}

/* TODO/FIXME - localize strings */
if (summary.num_core_achievements == 0)
{
if (summary.num_unofficial_achievements == 0)
strlcpy(msg, "This game has no achievements.", sizeof(msg));
len = snprintf(msg, sizeof(msg), "%s", msg_hash_to_str(MSG_CHEEVOS_GAME_HAS_NO_ACHIEVEMENTS));
else
snprintf(msg, sizeof(msg),
"Activated %d unofficial achievements%s.",
(int)summary.num_unofficial_achievements,
unsupported_clause);
len = snprintf(msg, sizeof(msg),
msg_hash_to_str(MSG_CHEEVOS_UNOFFICIAL_ACHIEVEMENTS_ACTIVATED),
(int)summary.num_unofficial_achievements);
}
else if (rc_client_get_encore_mode_enabled(rcheevos_locals.client))
{
snprintf(msg, sizeof(msg),
"All %d achievements activated for this session%s.",
(int)summary.num_core_achievements,
unsupported_clause);
len = snprintf(msg, sizeof(msg),
msg_hash_to_str(MSG_CHEEVOS_ALL_ACHIEVEMENTS_ACTIVATED),
(int)summary.num_core_achievements);
}
else
{
snprintf(msg, sizeof(msg),
"You have %d of %d achievements unlocked%s.",
(int)summary.num_unlocked_achievements,
(int)summary.num_core_achievements,
unsupported_clause);
len = snprintf(msg, sizeof(msg),
msg_hash_to_str(MSG_CHEEVOS_NUMBER_ACHIEVEMENTS_UNLOCKED),
(int)summary.num_unlocked_achievements,
(int)summary.num_core_achievements);
}

if (summary.num_unsupported_achievements)
{
if (len < sizeof(msg) - 4)
{
msg[len++] = ' ';
msg[len++] = '(';

len += snprintf(&msg[len], sizeof(msg) - len,
msg_hash_to_str(MSG_CHEEVOS_UNSUPPORTED_COUNT),
(int)summary.num_unsupported_achievements);

if (len < sizeof(msg) - 1)
{
msg[len++] = ')';
msg[len] = '\0';
}
}
}

msg[sizeof(msg) - 1] = 0;
Expand Down Expand Up @@ -2479,10 +2486,8 @@ static void rcheevos_client_login_callback(int result,
/* show notification (if enabled) */
if (settings->bools.cheevos_visibility_account)
{
/* TODO/FIXME - localize */
char msg[256];
snprintf(msg, sizeof(msg),
"RetroAchievements: Logged in as \"%s\".",
char msg[128];
snprintf(msg, sizeof(msg), msg_hash_to_str(MSG_CHEEVOS_LOGGED_IN_AS_USER),
user->display_name);
runloop_msg_queue_push(msg, 0, 2 * 60, false, NULL,
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
Expand Down Expand Up @@ -2522,14 +2527,15 @@ static void rcheevos_client_load_game_callback(int result,
if (!settings->bools.cheevos_verbose_enable)
return;

snprintf(msg, sizeof(msg), "RetroAchievements: Game could not be identified.");
snprintf(msg, sizeof(msg), "%s", msg_hash_to_str(MSG_CHEEVOS_GAME_NOT_IDENTIFIED));
}
else
{
snprintf(msg, sizeof(msg), "RetroAchievements game load failed: %s",
error_message ? error_message : "Unknown error");
if (!error_message)
error_message = "Unknown error";

CHEEVOS_LOG(RCHEEVOS_TAG "%s\n", msg);
snprintf(msg, sizeof(msg), msg_hash_to_str(MSG_CHEEVOS_GAME_LOAD_FAILED), error_message);
CHEEVOS_LOG(RCHEEVOS_TAG "Game load failed: %s\n", error_message);
}

runloop_msg_queue_push(msg, 0, 2 * 60, false, NULL,
Expand Down Expand Up @@ -3453,9 +3459,8 @@ static void rcheevos_client_change_media_callback(int result,
if (!error_message)
error_message = "Unknown error";

snprintf(msg, sizeof(msg), "RetroAchievements change media failed: %s",
error_message);
CHEEVOS_LOG(RCHEEVOS_TAG "%s\n", msg);
snprintf(msg, sizeof(msg), msg_hash_to_str(MSG_CHEEVOS_CHANGE_MEDIA_FAILED), error_message);
CHEEVOS_LOG(RCHEEVOS_TAG "Change media failed: %s\n", error_message);
}

runloop_msg_queue_push(msg, 0, 2 * 60, false, NULL,
Expand Down
72 changes: 68 additions & 4 deletions intl/msg_hash_us.h
Original file line number Diff line number Diff line change
Expand Up @@ -14321,10 +14321,6 @@ MSG_HASH(
MSG_CANNOT_INFER_NEW_CONFIG_PATH,
"Cannot infer new config path. Use current time."
)
MSG_HASH(
MSG_CHEEVOS_HARDCORE_MODE_ENABLE,
"Achievements Hardcore Mode Enabled, save state & rewind were disabled."
)
MSG_HASH(
MSG_COMPARING_WITH_KNOWN_MAGIC_NUMBERS,
"Comparing with known magic numbers..."
Expand Down Expand Up @@ -15509,6 +15505,10 @@ MSG_HASH(
MSG_FAILED_TO_RECEIVE_HEADER_FROM_HOST,
"Failed to receive header from host."
)
MSG_HASH(
MSG_CHEEVOS_LOGGED_IN_AS_USER,
"RetroAchievements: Logged in as \"%s\"."
)
MSG_HASH(
MSG_CHEEVOS_LOAD_STATE_PREVENTED_BY_HARDCORE_MODE,
"You must pause or disable Achievements Hardcore Mode to load states."
Expand All @@ -15529,6 +15529,70 @@ MSG_HASH(
MSG_CHEEVOS_COMPLETED_GAME,
"Completed %s"
)
MSG_HASH(
MSG_CHEEVOS_HARDCORE_MODE_ENABLE,
"Achievements Hardcore Mode Enabled, save state & rewind were disabled."
)
MSG_HASH(
MSG_CHEEVOS_GAME_HAS_NO_ACHIEVEMENTS,
"This game has no achievements."
)
MSG_HASH(
MSG_CHEEVOS_ALL_ACHIEVEMENTS_ACTIVATED,
"All %d achievements activated for this session"
)
MSG_HASH(
MSG_CHEEVOS_UNOFFICIAL_ACHIEVEMENTS_ACTIVATED,
"Activated %d unofficial achievements"
)
MSG_HASH(
MSG_CHEEVOS_NUMBER_ACHIEVEMENTS_UNLOCKED,
"You have %d of %d achievements unlocked"
)
MSG_HASH(
MSG_CHEEVOS_UNSUPPORTED_COUNT,
"%d unsupported"
)
MSG_HASH(
MSG_CHEEVOS_RICH_PRESENCE_SPECTATING,
"Spectating %s"
)
MSG_HASH(
MSG_CHEEVOS_HARDCORE_PAUSED_MANUAL_FRAME_DELAY,
"Hardcore paused. Manual video frame delay setting not allowed."
)
MSG_HASH(
MSG_CHEEVOS_HARDCORE_PAUSED_SHADER_SUBFRAMES,
"Hardcore paused. Shader subframes not allowed."
)
MSG_HASH(
MSG_CHEEVOS_HARDCORE_PAUSED_VSYNC_SWAP_INTERVAL,
"Hardcore paused. vsync swap interval above 1 not allowed."
)
MSG_HASH(
MSG_CHEEVOS_HARDCORE_PAUSED_BLACK_FRAME_INSERTION,
"Hardcore paused. Black frame insertion not allowed."
)
MSG_HASH(
MSG_CHEEVOS_HARDCORE_PAUSED_SETTING_NOT_ALLOWED,
"Hardcore paused. Setting not allowed: %s=%s"
)
MSG_HASH(
MSG_CHEEVOS_HARDCORE_PAUSED_SYSTEM_NOT_FOR_CORE,
"Hardcore paused. You cannot earn hardcore achievements for %s using %s"
)
MSG_HASH(
MSG_CHEEVOS_GAME_NOT_IDENTIFIED,
"RetroAchievements: Game could not be identified."
)
MSG_HASH(
MSG_CHEEVOS_GAME_LOAD_FAILED,
"RetroAchievements game load failed: %s"
)
MSG_HASH(
MSG_CHEEVOS_CHANGE_MEDIA_FAILED,
"RetroAchievements change media failed: %s"
)
MSG_HASH(
MSG_RESAMPLER_QUALITY_LOWEST,
"Lowest"
Expand Down
18 changes: 17 additions & 1 deletion msg_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,6 @@ enum msg_hash_enums
MSG_FAST_FORWARD,
MSG_REWIND_REACHED_END,
MSG_FAILED_TO_START_MOVIE_RECORD,
MSG_CHEEVOS_HARDCORE_MODE_ENABLE,
MSG_STATE_SLOT,
MSG_REPLAY_SLOT,
MSG_STARTING_MOVIE_RECORD_TO,
Expand Down Expand Up @@ -4073,11 +4072,28 @@ enum msg_hash_enums
MSG_CHEAT_SEARCH_ADD_MATCH_SUCCESS,
MSG_CHEAT_SEARCH_ADD_MATCH_FAIL,
MSG_CHEAT_SEARCH_DELETE_MATCH_SUCCESS,
MSG_CHEEVOS_LOGGED_IN_AS_USER,
MSG_CHEEVOS_LOAD_STATE_PREVENTED_BY_HARDCORE_MODE,
MSG_CHEEVOS_HARDCORE_MODE_DISABLED,
MSG_CHEEVOS_HARDCORE_MODE_DISABLED_CHEAT,
MSG_CHEEVOS_MASTERED_GAME,
MSG_CHEEVOS_COMPLETED_GAME,
MSG_CHEEVOS_HARDCORE_MODE_ENABLE,
MSG_CHEEVOS_GAME_HAS_NO_ACHIEVEMENTS,
MSG_CHEEVOS_ALL_ACHIEVEMENTS_ACTIVATED,
MSG_CHEEVOS_UNOFFICIAL_ACHIEVEMENTS_ACTIVATED,
MSG_CHEEVOS_NUMBER_ACHIEVEMENTS_UNLOCKED,
MSG_CHEEVOS_UNSUPPORTED_COUNT,
MSG_CHEEVOS_RICH_PRESENCE_SPECTATING,
MSG_CHEEVOS_HARDCORE_PAUSED_MANUAL_FRAME_DELAY,
MSG_CHEEVOS_HARDCORE_PAUSED_VSYNC_SWAP_INTERVAL,
MSG_CHEEVOS_HARDCORE_PAUSED_SHADER_SUBFRAMES,
MSG_CHEEVOS_HARDCORE_PAUSED_BLACK_FRAME_INSERTION,
MSG_CHEEVOS_HARDCORE_PAUSED_SETTING_NOT_ALLOWED,
MSG_CHEEVOS_HARDCORE_PAUSED_SYSTEM_NOT_FOR_CORE,
MSG_CHEEVOS_GAME_NOT_IDENTIFIED,
MSG_CHEEVOS_GAME_LOAD_FAILED,
MSG_CHEEVOS_CHANGE_MEDIA_FAILED,
MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS,
MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM,
MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD,
Expand Down
Loading