jacklul / inlinegamesbot

A Telegram bot providing games that can be played in any chat via inline keyboards.
https://telegram.me/inlinegamesbot
GNU Affero General Public License v3.0
119 stars 115 forks source link

language of the robot #24

Closed 98rostami closed 3 years ago

98rostami commented 3 years ago

I forked the project then i translated the messages.pot file in poedit and uploaded the translation file In the file /src/Helper/Language.php I changed the following variables to fa_IR $default_language $current_language Then I did a deploy in heroku, but the bot language is still English! For the test, the word Hi! At /src/Command/UserStartCommand.php i do replaced to Hello without changing it in the messages.pot file and the bot displays Hello! This means that the language file is not applied at all! What exactly should I do to make the bot language Persian? Thank you for your answer

jacklul commented 3 years ago

Please stay in one issue ticket, no need to create another one.

I've updated the source code as well as POT file, take a look at the develop branch and update your fork.

The translation procedure should look like this:

pavanyogi commented 2 years ago

We are using the example-bot code as a starter code. I tried to follow the above steps in order to make the bot multilingual. But we got some errors.

Commands/StartCommand.php

public function execute(): ServerResponse
{
    $this->getMessage()->getText(true);

    return $this->replyToChat(
        '<b>' . __('Hi!') . '</b>' . PHP_EOL .
        'Type /help to see all commands!'
    );
}

Error:

PHP Fatal error:  Uncaught Error: Call to undefined function Longman\\TelegramBot\\Commands\\SystemCommands\\__() in /home/pavany/Documents/aux/qbix/telegram-bot/example-bot/Commands/Custom/StartCommand.php:103\nStack trace:\n#0 /home/pavany/Documents/aux/qbix/telegram-bot/example-bot/vendor/longman/telegram-bot/src/Commands/Command.php(197): Longman\\TelegramBot\\Commands\\SystemCommands\\StartCommand->execute()\n#1 /home/pavany/Documents/aux/qbix/telegram-bot/example-bot/vendor/longman/telegram-bot/src/Telegram.php(674): Longman\\TelegramBot\\Commands\\Command->preExecute()\n#2 /home/pavany/Documents/aux/qbix/telegram-bot/example-bot/vendor/longman/telegram-bot/src/Telegram.php(646): Longman\\TelegramBot\\Telegram->executeCommand('start')\n#3 /home/pavany/Documents/aux/qbix/telegram-bot/example-bot/vendor/longman/telegram-bot/src/Telegram.php(557): Longman\\TelegramBot\\Telegram->processUpdate(Object(Longman\\TelegramBot\\Entities\\Update))\n#4 /home/pavany/Documents/aux/qbix/telegram-bot/example-bot/vendor/php-telegram-bot/telegram-bot-manager/src in /home/pavany/Documents/aux/qbix/telegram-bot/example-bot/Commands/Custom/StartCommand.php on line 103

I think it might be related to auto loading, etc?

jacklul commented 2 years ago

We are using the example-bot code as a starter code. I tried to follow the above steps in order to make the bot multilingual. But we got some errors.

These instructions are specific to this repository and it's custom code. The translation support in this project is using handcrafted class - /src/Helper/Language.php and gettext library.

The error is caused by not having global __() function registered from the mentioned library. You should probably write your own class based on mine as it's really buggy and not production ready.