Skip to content

Commit

Permalink
Translation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ninjasoturi committed Mar 15, 2024
1 parent f4c7dce commit 55bfbef
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 33 deletions.
6 changes: 3 additions & 3 deletions logic/alarm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 = '<b>' . getTranslation('alert_individual_poke', $recipient_language) . SP . $poke_name . '</b>' . CR;
} else {
// Any pokemon
Expand All @@ -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 = '<b>' . getTranslation('alert_cancel_individual_poke', $recipient_language) . SP . $poke_name . '</b>' . CR;
$msg_text .= EMOJI_HERE . SP . $gymname . SP . '(' . $raidtimes . ')' . CR;
$msg_text .= EMOJI_SINGLE . SP . $username . CR;
Expand Down
6 changes: 2 additions & 4 deletions logic/createRaidBossList.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php
require_once(LOGIC_PATH . '/get_raid_times.php');

/**
* Prints a list of saved raid bosses in this format
* - Darkrai 20.10. - 2.11.
Expand Down Expand Up @@ -46,7 +44,7 @@ function createRaidBossList() {
foreach($data[0] as $tempRow) {
$list .= PHP_EOL . '- ';
foreach($tempRow as $num => $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;
}
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion logic/get_overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
20 changes: 7 additions & 13 deletions logic/get_raid_times.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand All @@ -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');
Expand All @@ -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?
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion logic/raid_picture.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
5 changes: 3 additions & 2 deletions logic/sendalarmnotice.php
Original file line number Diff line number Diff line change
Expand Up @@ -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('
Expand All @@ -22,7 +23,7 @@ function sendAlertOnOffNotice($raid_id, $user_id, $alarm = null, $raid = null){
}
$gymname = '<b>' . $raid['gym_name'] . '</b>';
// 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
Expand Down
4 changes: 2 additions & 2 deletions logic/show_raid_poll.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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) ? ('<b>' . getPublicTranslation('any_pokemon') . '</b>') : ('<b>' . get_local_pokemon_name($pokemon_id_form[0],$pokemon_id_form[1], true) . '</b>'));
$msg = raid_poll_message($msg, ($current_pokemon == 0) ? ('<b>' . getPublicTranslation('any_pokemon') . '</b>') : ('<b>' . get_local_pokemon_name($pokemon_id_form[0],$pokemon_id_form[1], $config->LANGUAGE_PUBLIC) . '</b>'));

// Add counts to message.
$msg = raid_poll_print_counts($msg, $cnt_array[$current_att_time][$current_pokemon]);
Expand Down
6 changes: 3 additions & 3 deletions logic/show_raid_poll_small.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mods/edit_event_note.php
Original file line number Diff line number Diff line change
Expand Up @@ -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') . ': ';
Expand Down
2 changes: 1 addition & 1 deletion mods/edit_save.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
2 changes: 1 addition & 1 deletion mods/list_raid.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
$raid_pokemon_name = get_local_pokemon_name($raid['pokemon'], $raid['pokemon_form']);
$msg .= '<b>' . $i .'. ' . $raid_pokemon_name . '</b>' . 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++;
}
Expand Down
2 changes: 1 addition & 1 deletion mods/share_raid_by_location.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 55bfbef

Please sign in to comment.