<commit_before><?php

namespace metalguardian\i18n\components;

use metalguardian\i18n\models\SourceMessage;
use Yii;
use yii\i18n\MissingTranslationEvent;

/**
 * Class TranslationEventHandler
 */
class TranslationEventHandler
{
    public static function handleMissingTranslation(MissingTranslationEvent $event)
    {
        
    }
}
<commit_msg>add create source message if not created<commit_after><?php

namespace metalguardian\i18n\components;

use metalguardian\i18n\models\SourceMessage;
use Yii;
use yii\i18n\MissingTranslationEvent;

/**
 * Class TranslationEventHandler
 */
class TranslationEventHandler
{
    public static function handleMissingTranslation(MissingTranslationEvent $event)
    {
        $driver = Yii::$app->getDb()->getDriverName();
        $caseInsensitivePrefix = $driver === 'mysql' ? ' BINARY' : null;
        $sourceMessage = SourceMessage::find()
            ->where(['category' => $event->category])
            ->andWhere(['=' . $caseInsensitivePrefix, 'message', $event->message])
            ->one();
        if (!$sourceMessage) {
            SourceMessage::create($event->category, $event->message);
        }
    }
}

{'fraction_non_alphanumeric': 0.125, 'fraction_numerical': 0.010344827586206896, 'mean_word_length': 3.700404858299595, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7578122', 'n_tokens_mistral': 329, 'n_tokens_neox': 326, 'n_words': 62}