|
1 | 1 | <?php
|
2 | 2 | /**
|
3 | 3 | * Get local name of pokemon.
|
4 |
| - * @param $pokemon_id |
5 |
| - * @param $pokemon_form_id |
6 |
| - * @param $override_language |
| 4 | + * @param int $pokemon_id |
| 5 | + * @param int $pokemon_form_id |
| 6 | + * @param string $language |
7 | 7 | * @return string
|
8 | 8 | */
|
9 |
| -function get_local_pokemon_name($pokemon_id, $pokemon_form_id, $override_language = false) |
| 9 | +function get_local_pokemon_name($pokemon_id, $pokemon_form_id, $language = null) |
10 | 10 | {
|
| 11 | + global $config, $botUser; |
11 | 12 | $q = my_query('SELECT pokemon_name, pokemon_form_name FROM pokemon WHERE pokedex_id = ? AND pokemon_form_id = ?', [$pokemon_id, $pokemon_form_id]);
|
12 | 13 | $res = $q->fetch();
|
13 | 14 | $pokemon_form_name = $res['pokemon_form_name'] ?? 'normal';
|
14 | 15 |
|
15 | 16 | debug_log('Pokemon_form: ' . $pokemon_form_name);
|
16 |
| - |
17 |
| - // Get translation type |
18 |
| - $getTypeTranslation = ($override_language == true) ? 'getPublicTranslation' : 'getTranslation'; |
| 17 | + if($language === null) $language = $botUser->userLanguage; |
19 | 18 |
|
20 | 19 | // Init pokemon name and define fake pokedex ids used for raid eggs
|
21 | 20 | $pokemon_name = '';
|
22 | 21 |
|
23 | 22 | // Get eggs from normal translation.
|
24 |
| - $pokemon_name = (in_array($pokemon_id, EGGS)) ? $getTypeTranslation('egg_' . str_replace('999', '', $pokemon_id)) : $getTypeTranslation('pokemon_id_' . $pokemon_id); |
| 23 | + $pokemon_name = (in_array($pokemon_id, EGGS)) ? |
| 24 | + getTranslation('egg_' . str_replace('999', '', $pokemon_id), $language) : |
| 25 | + getTranslation('pokemon_id_' . $pokemon_id, $language); |
25 | 26 |
|
26 | 27 | $skipFallback = false;
|
27 | 28 | if ($pokemon_form_name != 'normal') {
|
28 |
| - $pokemon_form_name = $getTypeTranslation('pokemon_form_' . $pokemon_form_id); |
| 29 | + $pokemon_form_name = getTranslation('pokemon_form_' . $pokemon_form_id, $language); |
29 | 30 | // Use only form name if form name contains Pokemon name
|
30 | 31 | // e.g. Black Kyurem, Frost Rotom
|
31 | 32 | if(strpos($pokemon_form_name, $pokemon_name, 0)) {
|
|
0 commit comments