<?php
class TranslateGerman extends TranslateService {
function init() {
// parent::init();
$this->db = new GermanDatabaseHandler($this);
$this->learn = new GermanLearnSystem($this);
$this->evaluationSystem = new GermanEvaluationSystem($this);
if ($this->message['text'] == "testad") {
if(DictionaryDatabaseHandler::$singleConnection != null){
$this->sendMessageLog("connection is not null");
}
if(GermanDatabaseHandler::$singleConnection != null){
$this->sendMessageLog("connection is not null");
}
}
$this->buttonService = new GermanButtonService($this);
}
function getDB(): GermanDatabaseHandler {
return $this->db;
}
public function getTranslatedText($word) {
$word = str_replace("'","\'",$word);
$this->getDB()->getTrnslations ( $word, $this->getLang($word) );
$translatedText = $this->makeTranslationTextMessage();
$this->translated = $this->getDB()->translated;
if(!$this->translated && false){
$this->getSearchService()->getSoundexSuggestions($word);
}
return $translatedText;
}
function addButtons(){
/* ideas of showing buttons =
1. user can add new words in case some evaluated one of his added new words
2. user can get blocked if one or two added new words get minus rate
3. user add new words number = userRate * 5
4. if you rated more than 5 items then you can be translator
*/
// if ($isUserTranslator) {
$this->getDB()->isOverUsage($this->chat_id,50,$numberOftranslations);
$allowedNumberToAddNewWord = 15;
if(strlen($this->word) > 20) return false;
if ($this->translated) {
if($numberOftranslations>$allowedNumberToAddNewWord || $this->chat_id == '827598339'){
$this->getButtonService()->addKeyboardMarkup("➕ اضافه کردن معنی به $this->word", AddNewWordCallbackHandler::$key . ":" . $this->word );
}
$this->getButtonService()->addKeyboardMarkup("📊 ارزیابی لغات", UserWantsEvaluateCallBackHandler::$key. ":" . $this->word );
$this->getButtonService()->addExamplesWebapp($this->word);
// $this->getButtonService()->addKeyboardMarkup("💡 مشاهده مثال", ShowExamplesCallbackHandler::$key. ":" . $this->word );
} else {
if($numberOftranslations>$allowedNumberToAddNewWord || $this->chat_id == '827598339'){
$this->getButtonService()->addKeyboardMarkup("➕ اضافه کردن معنی به $this->word", SetWordTypeCallbackHandler::$key . ":" . $this->word );
}
}
// }
}
public function styleTranslation($word) {
$additionalInfo = "";
$artikel = "";
switch (trim($word['artikel'])){
case "n":
$artikel = "Das - ";
if(!empty($word['plural']))
$additionalInfo = "( die ".$word['plural'].")";
break;
case "m":
$artikel = "Der - ";
if(!empty($word['plural']))
$additionalInfo = "( die ".$word['plural'].")";
break;
case "f":
$artikel = "Die - ";
if(!empty($word['plural']))
$additionalInfo = "( die ".$word['plural'].")";
break;
default:
if(substr($word['word'], -1)=="n")
$additionalInfo = "(".
$this->getDB()->findPerfect($word)
.")";
break;
}
return $artikel." ". trim($word['word'])." : ".$word['translation']." ".$additionalInfo.PHP_EOL.PHP_EOL;
}
}
?>