<commit_before><?php

class ApplicationI18n {

  private $_locale;
  private $_words;

  private function __construct($default) {
    $this->_locale  = null;
    $this->_words   = ApplicationConfig::i18n($default);
    return $this;
  }

  public static function init($default = "tr") {
    if (isset($_SESSION[self::storage_key()])) {
      if ($_SESSION[self::storage_key()]->_locale)
        return;
    }
    $_SESSION[self::storage_key()] = new ApplicationI18n($default);
  }

  public static function locale($locale = "tr") {
    $_SESSION[self::storage_key()]->_locale = $locale;
    $_SESSION[self::storage_key()]->_words = ApplicationConfig::i18n($locale);
  }

  public static function get_locale() {
    return $_SESSION[self::storage_key()]->_locale;
  }

  public static function translate($_word) {
    $words = explode(".", $_word);
    $current_words = [];
    foreach ($words as $word)
      $current_words = ($current_words == []) ? self::get_first_word($word) : $current_words[$word];
    return $current_words;
  }

  private static function get_first_word($word) {
    $words = $_SESSION[self::storage_key()]->_words;

    if (!isset($words[$word]))
      throw new Exception("Yerel ayar dosyasında böyle bir kelime mevcut değil → " . $word);
    return $words[$word];
  }

  private static function storage_key() {
    return '_i18n';
  }
}
?>
<commit_msg>Update ApplicationI18n.php<commit_after><?php

class ApplicationI18n {

  private $_locale;
  private $_words;

  private function __construct($default) {
    $this->_locale = $default;
    $this->_words  = ApplicationConfig::i18n($default);
    return $this;
  }

  public static function init($default = "tr") {
    if (isset($_SESSION[self::storage_key()])) {
      if ($_SESSION[self::storage_key()]->_locale)
        return;
    }
    $_SESSION[self::storage_key()] = new ApplicationI18n($default);
  }

  public static function locale($locale = "tr") {
    $_SESSION[self::storage_key()]->_locale = $locale;
    $_SESSION[self::storage_key()]->_words = ApplicationConfig::i18n($locale);
  }

  public static function get_locale() {
    return $_SESSION[self::storage_key()]->_locale;
  }

  public static function translate($_word) {
    $words = explode(".", $_word);
    $current_words = [];
    foreach ($words as $word)
      $current_words = ($current_words == []) ? self::get_first_word($word) : $current_words[$word];
    return $current_words;
  }

  private static function get_first_word($word) {
    $words = $_SESSION[self::storage_key()]->_words;

    if (!isset($words[$word]))
      throw new Exception("Yerel ayar dosyasında böyle bir kelime mevcut değil → " . $word);
    return $words[$word];
  }

  private static function storage_key() {
    return '_i18n';
  }
}
?>

{'fraction_non_alphanumeric': 0.16167448574521834, 'fraction_numerical': 0.007939372067845544, 'mean_word_length': 4.030852994555354, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '1842157', 'n_tokens_mistral': 898, 'n_tokens_neox': 876, 'n_words': 181}