diff --git a/logic/alarm.php b/logic/alarm.php index 2bcfc65f..ca242ed8 100644 --- a/logic/alarm.php +++ b/logic/alarm.php @@ -36,7 +36,6 @@ function alarm($raid_id_array, $user_id, $action, $info = '', $tg_json = []) $raid_id = $raid['id']; $gymname = $raid['gym_name']; - $raidtimes = str_replace(CR, '', str_replace(' ', '', get_raid_times($raid, false, true))); // Get attend time. if(!in_array($action, ['new_att','new_boss','change_time','group_code_private','group_code_public'])) { @@ -73,6 +72,7 @@ function alarm($raid_id_array, $user_id, $action, $info = '', $tg_json = []) { if(!isset($answer['lang']) or empty($answer['lang'])) $recipient_language = $config->LANGUAGE_PUBLIC; else $recipient_language = $GLOBALS['languages'][$answer['lang']]; + $raidtimes = str_replace(CR, '', str_replace(' ', '', get_raid_times($raid, $recipient_language, true))); // Adding a guest if($action == 'extra') { debug_log('Alarm additional trainer: ' . $info); @@ -115,7 +115,7 @@ function alarm($raid_id_array, $user_id, $action, $info = '', $tg_json = []) if($info != '0') { // Only a specific pokemon $pokemon = explode("-",$info,2); - $poke_name = get_local_pokemon_name($pokemon[0],$pokemon[1]); + $poke_name = get_local_pokemon_name($pokemon[0], $pokemon[1], $recipient_language); $msg_text = '' . getTranslation('alert_individual_poke', $recipient_language) . SP . $poke_name . '' . CR; } else { // Any pokemon @@ -130,7 +130,7 @@ function alarm($raid_id_array, $user_id, $action, $info = '', $tg_json = []) } else if($action == 'pok_cancel_individual') { debug_log('Alarm Pokemon: ' . $info); $pokemon = explode("-",$info,2); - $poke_name = get_local_pokemon_name($pokemon[0],$pokemon[1]); + $poke_name = get_local_pokemon_name($pokemon[0], $pokemon[1], $recipient_language); $msg_text = '' . getTranslation('alert_cancel_individual_poke', $recipient_language) . SP . $poke_name . '' . CR; $msg_text .= EMOJI_HERE . SP . $gymname . SP . '(' . $raidtimes . ')' . CR; $msg_text .= EMOJI_SINGLE . SP . $username . CR; diff --git a/logic/createRaidBossList.php b/logic/createRaidBossList.php index ab0fc3b6..bda93c23 100644 --- a/logic/createRaidBossList.php +++ b/logic/createRaidBossList.php @@ -1,6 +1,4 @@ $row) { - $pokemonName = get_local_pokemon_name($row['pokedex_id'], $row['pokemon_form_id']); + $pokemonName = get_local_pokemon_name($row['pokedex_id'], $row['pokemon_form_id'], $config->LANGUAGE_PUBLIC); if($num != 0) $list .= ', '; $list .= $pokemonName; } @@ -70,7 +68,7 @@ function createRaidBossList() { } $list .= PHP_EOL . '- '; } - $pokemonName = get_local_pokemon_name($row['pokedex_id'], $row['pokemon_form_id']); + $pokemonName = get_local_pokemon_name($row['pokedex_id'], $row['pokemon_form_id'], $config->LANGUAGE_PUBLIC); if($num != 0) $list .= ', '; $list .= $pokemonName; $prevStartDate = $startDate; diff --git a/logic/get_overview.php b/logic/get_overview.php index 7621bb63..966ed576 100644 --- a/logic/get_overview.php +++ b/logic/get_overview.php @@ -60,7 +60,7 @@ function get_overview( $active_raids, $chat_title, $chat_username ) // Raid has not started yet - adjust time left message if ($now < $start_time) { - $msg .= get_raid_times($row, true); + $msg .= get_raid_times($row, $config->LANGUAGE_PUBLIC); // Raid has started already } else { // Add time left message. diff --git a/logic/get_raid_times.php b/logic/get_raid_times.php index a8fc8dd0..6f408e6e 100644 --- a/logic/get_raid_times.php +++ b/logic/get_raid_times.php @@ -2,19 +2,13 @@ /** * Get raid time message. * @param array $raid - * @param bool $override_language + * @param bool $language * @param bool $unformatted * @return string */ -function get_raid_times($raid, $override_language = true, $unformatted = false) +function get_raid_times($raid, $language = null, $unformatted = false) { global $config; - // Get translation type - if($override_language == true) { - $getTypeTranslation = 'getPublicTranslation'; - } else { - $getTypeTranslation = 'getTranslation'; - } // Init empty message string. $msg = ''; @@ -31,8 +25,8 @@ function get_raid_times($raid, $override_language = true, $unformatted = false) $year_start = utctime($raid['start_time'], 'Y'); // Translation for raid day and month - $raid_day = $getTypeTranslation('weekday_' . $weekday_start); - $raid_month = $getTypeTranslation('month_' . $month_start); + $raid_day = getTranslation('weekday_' . $weekday_start, $language); + $raid_month = getTranslation('month_' . $month_start, $language); // Days until the raid starts $dt_now = utcdate('now'); @@ -44,9 +38,9 @@ function get_raid_times($raid, $override_language = true, $unformatted = false) // Raid times. if($unformatted == false) { if($config->RAID_POLL_POKEMON_NAME_FIRST_LINE == true) { - $msg .= get_local_pokemon_name($raid['pokemon'], $raid['pokemon_form'], $override_language) . ':' . SP; + $msg .= get_local_pokemon_name($raid['pokemon'], $raid['pokemon_form'], $language) . ':' . SP; } else { - $msg .= $getTypeTranslation('raid') . ':' . SP; + $msg .= getTranslation('raid', $language) . ':' . SP; } } // Is the raid in the same week? @@ -66,7 +60,7 @@ function get_raid_times($raid, $override_language = true, $unformatted = false) // Adds 'at 17:00' to the output. if($unformatted == false) { - $msg .= SP . $getTypeTranslation('raid_egg_opens_at'); + $msg .= SP . getTranslation('raid_egg_opens_at', $language); } $msg .= SP . dt2time($raid['start_time']); } else { diff --git a/logic/raid_picture.php b/logic/raid_picture.php index c0024410..44218d9c 100644 --- a/logic/raid_picture.php +++ b/logic/raid_picture.php @@ -489,7 +489,7 @@ function create_raid_picture($raid, $standalone_photo = false, $debug = false) { // Raid times if(!$raid['raid_ended']) { - $time_text = get_raid_times($raid, true, true); + $time_text = get_raid_times($raid, $config->LANGUAGE_PUBLIC, true); } else { $time_text = getPublicTranslation('raid_done'); } diff --git a/logic/sendalarmnotice.php b/logic/sendalarmnotice.php index dbf232dd..cd263f6b 100644 --- a/logic/sendalarmnotice.php +++ b/logic/sendalarmnotice.php @@ -8,7 +8,8 @@ * @param boolean $alarm * @param array $raid Raid array from get_raid() */ -function sendAlertOnOffNotice($raid_id, $user_id, $alarm = null, $raid = null){ +function sendAlertOnOffNotice($raid_id, $user_id, $alarm = null, $raid = null) { + global $botUser; if(empty($raid)){ // Request limited raid info $request = my_query(' @@ -22,7 +23,7 @@ function sendAlertOnOffNotice($raid_id, $user_id, $alarm = null, $raid = null){ } $gymname = '' . $raid['gym_name'] . ''; // parse raidtimes - $raidtimes = str_replace(CR, '', str_replace(' ', '', get_raid_times($raid, false, true))); + $raidtimes = str_replace(CR, '', str_replace(' ', '', get_raid_times($raid, $botUser->userLanguage, true))); if(empty($alarm)){ // Get the new value diff --git a/logic/show_raid_poll.php b/logic/show_raid_poll.php index bfc0c36b..26ace6aa 100644 --- a/logic/show_raid_poll.php +++ b/logic/show_raid_poll.php @@ -37,7 +37,7 @@ function show_raid_poll($raid, $inline = false) } // Get raid times. - $msg = raid_poll_message($msg, get_raid_times($raid, true, ($raid['event_pokemon_title'] == 0 ? true : false)), true); + $msg = raid_poll_message($msg, get_raid_times($raid, $config->LANGUAGE_PUBLIC, ($raid['event_pokemon_title'] == 0 ? true : false)), true); // Get current time and time left. $time_now = utcnow(); @@ -373,7 +373,7 @@ function show_raid_poll($raid, $inline = false) if($cnt_array[$current_att_time]['other_pokemon'] > 0 ) { // Add pokemon name. $pokemon_id_form = explode("-",$current_pokemon,2); - $msg = raid_poll_message($msg, ($current_pokemon == 0) ? ('' . getPublicTranslation('any_pokemon') . '') : ('' . get_local_pokemon_name($pokemon_id_form[0],$pokemon_id_form[1], true) . '')); + $msg = raid_poll_message($msg, ($current_pokemon == 0) ? ('' . getPublicTranslation('any_pokemon') . '') : ('' . get_local_pokemon_name($pokemon_id_form[0],$pokemon_id_form[1], $config->LANGUAGE_PUBLIC) . '')); // Add counts to message. $msg = raid_poll_print_counts($msg, $cnt_array[$current_att_time][$current_pokemon]); diff --git a/logic/show_raid_poll_small.php b/logic/show_raid_poll_small.php index dd4b3da2..6f328709 100644 --- a/logic/show_raid_poll_small.php +++ b/logic/show_raid_poll_small.php @@ -3,11 +3,11 @@ /** * Show small raid poll. * @param $raid - * @param $override_language * @return string */ -function show_raid_poll_small($raid, $override_language = false) +function show_raid_poll_small($raid) { + global $botUser; // Build message string. $msg = ''; @@ -31,7 +31,7 @@ function show_raid_poll_small($raid, $override_language = false) // Start time and end time if(!empty($raid['start_time']) && !empty($raid['end_time'])) { // Get raid times message. - $msg .= get_raid_times($raid, $override_language); + $msg .= get_raid_times($raid, $botUser->userLanguage); } // Count attendances diff --git a/mods/edit_event_note.php b/mods/edit_event_note.php index cee3f3ba..c24ae268 100644 --- a/mods/edit_event_note.php +++ b/mods/edit_event_note.php @@ -20,7 +20,7 @@ $msg = ''; $msg .= getTranslation('raid_saved') . CR; -$msg .= show_raid_poll_small($raid, false) . CR2; +$msg .= show_raid_poll_small($raid) . CR2; if($mode == 'e') { $msg.= getTranslation('event_note_edit') . ': '; diff --git a/mods/edit_save.php b/mods/edit_save.php index 92dd8647..56d6b02b 100644 --- a/mods/edit_save.php +++ b/mods/edit_save.php @@ -60,7 +60,7 @@ // Build message string. $msg = ''; $msg .= getTranslation('raid_saved') . CR; -$msg .= show_raid_poll_small($raid, false) . CR; +$msg .= show_raid_poll_small($raid) . CR; // User_id tag. $user_id_tag = '#' . $update['callback_query']['from']['id']; diff --git a/mods/list_raid.php b/mods/list_raid.php index c61aa52a..0dcf85ba 100644 --- a/mods/list_raid.php +++ b/mods/list_raid.php @@ -83,7 +83,7 @@ $raid_pokemon_name = get_local_pokemon_name($raid['pokemon'], $raid['pokemon_form']); $msg .= '' . $i .'. ' . $raid_pokemon_name . '' . CR; if(!empty($raid['event_name'])) $msg .= $raid['event_name'] . CR; - $msg .= get_raid_times($raid,false, true) . CR . CR; + $msg .= get_raid_times($raid, $botUser->userLanguage, true) . CR . CR; $keys[][] = button($i . '. ' . $raid_pokemon_name,['list_raid', 'r' => $raid['id']]); $i++; } diff --git a/mods/share_raid_by_location.php b/mods/share_raid_by_location.php index 54fb133b..2435d262 100644 --- a/mods/share_raid_by_location.php +++ b/mods/share_raid_by_location.php @@ -97,7 +97,7 @@ $end = dt2time($raid['end_time']); $time_left = $raid['t_left']; if ($now < $start) { - $text .= get_raid_times($raid, true); + $text .= get_raid_times($raid, $botUser->userLanguage); // Raid has started already } else { // Add time left message.