<commit_before><?php
/** 
 * MINZ - Copyright 2011 <NAME>
 * Sous licence AGPL3 <http://www.gnu.org/licenses/>
 */

/**
 * This class is used for the internationalization.
 * It uses files in `./app/i18n/`
 */
class Minz_Translate {
	/**
	 * $lang_name is the name of the current language to use.
	 */
	private static $lang_name;

	/**
	 * $lang_path is the pathname of i18n files (e.g. ./app/i18n/en/).
	 */
	private static $lang_path;

	/**
	 * $translates is a cache for i18n translation.
	 */
	private static $translates = array();

	/**
	 * Load $lang_name and $lang_path based on configuration and selected language.
	 */
	public static function init() {
		$l = Minz_Configuration::language();
		self::$lang_name = Minz_Session::param('language', $l);
		self::$lang_path = APP_PATH . '/i18n/' . self::$lang_name . '/';
	}

	/**
	 * Alias for init().
	 */
	public static function reset() {
		self::init();
	}

	/**
	 * Translate a key into its corresponding value based on selected language.
	 * @param $key the key to translate.
	 * @param additional parameters for variable keys.
	 * @return the value corresponding to the key.
	 *         If no value is found, return the key itself.
	 */ 
	public static function t($key) {
		$group = explode('.', $key);

		if (count($group) < 2) {
			// Minz_Log::debug($key . ' is not in a valid format');
			$top_level = 'gen';
		} else {
			$top_level = array_shift($group);
		}

		$filename = self::$lang_path . $top_level . '.php';

		// Try to load the i18n file if it's not done yet.
		if (!isset(self::$translates[$top_level])) {
			if (!file_exists($filename)) {
				Minz_Log::debug($top_level . ' is not a valid top level key');
				return $key;
			}

			self::$translates[$top_level] = include($filename);<commit_msg>Verbose for unvalid key format<commit_after><?php
/** 
 * MINZ - Copyright 2011 <NAME>
 * Sous licence AGPL3 <http://www.gnu.org/licenses/>
 */

/**
 * This class is used for the internationalization.
 * It uses files in `./app/i18n/`
 */
class Minz_Translate {
	/**
	 * $lang_name is the name of the current language to use.
	 */
	private static $lang_name;

	/**
	 * $lang_path is the pathname of i18n files (e.g. ./app/i18n/en/).
	 */
	private static $lang_path;

	/**
	 * $translates is a cache for i18n translation.
	 */
	private static $translates = array();

	/**
	 * Load $lang_name and $lang_path based on configuration and selected language.
	 */
	public static function init() {
		$l = Minz_Configuration::language();
		self::$lang_name = Minz_Session::param('language', $l);
		self::$lang_path = APP_PATH . '/i18n/' . self::$lang_name . '/';
	}

	/**
	 * Alias for init().
	 */
	public static function reset() {
		self::init();
	}

	/**
	 * Translate a key into its corresponding value based on selected language.
	 * @param $key the key to translate.
	 * @param additional parameters for variable keys.
	 * @return the value corresponding to the key.
	 *         If no value is found, return the key itself.
	 */ 
	public static function t($key) {
		$group = explode('.', $key);

		if (count($group) < 2) {
			Minz_Log::debug($key . ' is not in a valid format');
			$top_level = 'gen';
		} else {
			$top_level = array_shift($group);
		}

		$filename = self::$lang_path . $top_level . '.php';

		// Try to load the i18n file if it's not done yet.
		if (!isset(self::$translates[$top_level])) {
			if (!file_exists($filename)) {
				Minz_Log::debug($top_level . ' is not a valid top level key');
				return $key;
			}

			self::$translates[$top_level] = include($filename);
{'fraction_non_alphanumeric': 0.15354330708661418, 'fraction_numerical': 0.010123734533183352, 'mean_word_length': 3.136046511627907, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5863382', 'n_tokens_mistral': 1281, 'n_tokens_neox': 1154, 'n_words': 367}