<commit_before><?php
/*
 * Created by <NAME> on 2009-10-15.
 * Copyright (c) 2009 <NAME>.
 * All rights reserved.
 */

/**
 * Internationalization plugin for RapidDataMapper.
 */
class Db_Plugin_I18n extends Db_Plugin
{
	/**
	 * Columns to internationalize.
	 * 
	 * @var array
	 */
	protected $columns = array();
	
	/**
	 * A list to keep track of the decorators we've added.
	 * 
	 * @var array
	 */
	protected $decorators = array();
	
	/**
	 * The name of the column containing the language key.
	 * 
	 * @var string
	 */
	protected $lang_key = 'lang';
	
	/**
	 * The column keeping track of which language is currently used.
	 * 
	 * @var Db_Descriptor_Column
	 */
	protected $lang_column = null;
	
	/**
	 * The suffix for the table alias when aliasing the table containing the translations.
	 * 
	 * @var string
	 */
	protected $alias_suffix = 'Translation';
	
	/**
	 * Prefix for the table containing the internationalization data.
	 */
	protected $table_prefix = '';
	
	/**
	 * Suffix for the table containing the internationalization data.
	 * 
	 * @var string
	 */
	protected $table_suffix = '_lang';
	
	/**
	 * Table containing the language data.
	 * 
	 * @var string
	 */
	protected $lang_table = false;
	
	/**
	 * Default language for the translated text.
	 * 
	 * @var string
	 */
	protected $default_language = 'en';
	
	/**
	 * @param  array	Associative array containing the settings
	 */
	function __construct(array $options)
	{
		if(empty($options['columns']))
		{
			throw new Db_Exception('Db_Plugin_I18n: Missing "columns" option in options given to constructor');
		}
		else
		{
			$this->columns = (Array)$options['columns'];
		}
		
		if( ! empty($options['table_prefix']))
		{
			$this->table_prefix = $options['table_prefix'];
		}
		
		if( ! empty($options['table_suffix']))
		{
			$this->table_suffix = $options['table_suffix'];
		}
		
		if( ! empty($options['lang_table']))
		{
			$this->lang_table = $options['lang_table'];
		}
		
		if( ! empty($options['alias_suffix']))
		{
			$this->alias_suffix = $options['alias_suffix'];
		}
		
		$this->lang_key = empty($options['lang_key']) ? 'lang' : $options['lang_key'];
		
		if(in_array($this->lang_key, $this->columns))
		{<commit_msg>Forgot to add a way to change the default language<commit_after><?php
/*
 * Created by <NAME> on 2009-10-15.
 * Copyright (c) 2009 <NAME>.
 * All rights reserved.
 */

/**
 * Internationalization plugin for RapidDataMapper.
 */
class Db_Plugin_I18n extends Db_Plugin
{
	/**
	 * Columns to internationalize.
	 * 
	 * @var array
	 */
	protected $columns = array();
	
	/**
	 * A list to keep track of the decorators we've added.
	 * 
	 * @var array
	 */
	protected $decorators = array();
	
	/**
	 * The name of the column containing the language key.
	 * 
	 * @var string
	 */
	protected $lang_key = 'lang';
	
	/**
	 * The column keeping track of which language is currently used.
	 * 
	 * @var Db_Descriptor_Column
	 */
	protected $lang_column = null;
	
	/**
	 * The suffix for the table alias when aliasing the table containing the translations.
	 * 
	 * @var string
	 */
	protected $alias_suffix = 'Translation';
	
	/**
	 * Prefix for the table containing the internationalization data.
	 */
	protected $table_prefix = '';
	
	/**
	 * Suffix for the table containing the internationalization data.
	 * 
	 * @var string
	 */
	protected $table_suffix = '_lang';
	
	/**
	 * Table containing the language data.
	 * 
	 * @var string
	 */
	protected $lang_table = false;
	
	/**
	 * Default language for the translated text.
	 * 
	 * @var string
	 */
	protected $default_language = 'en';
	
	/**
	 * @param  array	Associative array containing the settings
	 */
	function __construct(array $options)
	{
		if(empty($options['columns']))
		{
			throw new Db_Exception('Db_Plugin_I18n: Missing "columns" option in options given to constructor');
		}
		else
		{
			$this->columns = (Array)$options['columns'];
		}
		
		if( ! empty($options['default_language']))
		{
			$this->default_language = $options['default_language'];
		}
		
		if( ! empty($options['table_prefix']))
		{
			$this->table_prefix = $options['table_prefix'];
		}
		
		if( ! empty($options['table_suffix']))
		{
			$this->table_suffix = $options['table_suffix'];
		}
		
		if( ! empty($options['lang_table']))
		{
			$this->lang_table = $options['lang_table'];
		}
		
		if( ! empty($options['alias_suffix']))
		{
			$this->alias_suffix = $options['alias_suffix'];
		}
		
		$this->lang_key = empty($options['lang_key']) ? 'lang' : $options['lang_key'];
		
		if(in_array($this->lang_key, $this->columns))
		{
{'fraction_non_alphanumeric': 0.1471747700394218, 'fraction_numerical': 0.00700832238282961, 'mean_word_length': 3.232622798887859, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 24, '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': '199627', 'n_tokens_mistral': 1665, 'n_tokens_neox': 1375, 'n_words': 377}