models/i18n/translator.php
public function getTranslations( $language, $instance, $parent_instance = false )
	{
        $sql = <<<TRANSLATIONS
        SELECT
         id,
         message,
         comment,
         SUBSTRING_INDEX(GROUP_CONCAT(destination_instance ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as destination_instance,
         SUBSTRING_INDEX(GROUP_CONCAT(language ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as language,
         SUBSTRING_INDEX(GROUP_CONCAT(translation ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as translation,
         SUBSTRING_INDEX(GROUP_CONCAT(author ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as author,
         SUBSTRING_INDEX(GROUP_CONCAT(modified ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as modified,
         SUBSTRING_INDEX(GROUP_CONCAT(is_base_lang ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as is_base_lang
        FROM
            (
                SELECT
                    m.id,
                    m.message,
                    m.comment,
                    m.instance AS message_instance,
                    t.instance AS translation_instance,
                    i.instance AS destination_instance,
                    ip.instance AS instance_parent,
                    (
                        SELECT
                            COUNT(ip_x.instance) as depth
                        FROM
                            i18n_instances i_x
                                JOIN i18n_instances ip_x ON i_x.lft BETWEEN ip_x.lft AND ip_x.rgt
                        WHERE
                            i_x.instance = t.instance
                        GROUP BY
                            i_x.instance
                    ) as instance_depth,	
                    t.lang as origin_language,
                    l.lang as language,
                    (
                        SELECT
                            COUNT(lp_x.lang) as depth
                        FROM
                            i18n_languages l_x
                                JOIN i18n_languages lp_x ON l_x.lft BETWEEN lp_x.lft AND lp_x.rgt
                        WHERE
                            l_x.lang = lp.lang
                        GROUP BY
                            l_x.lang
                    ) as language_depth,	
                    t.translation AS translation,
                    t.author AS author,
                    t.modified AS modified,
                    IF(t.lang = l.lang, 1, 0) as is_base_lang
                    
                FROM
                    i18n_messages m
                    LEFT JOIN i18n_languages l ON l.lang = ?
                    LEFT JOIN i18n_languages lp ON l.lft BETWEEN lp.lft AND lp.rgt	
                    LEFT JOIN i18n_translations t ON m.id = t.id_message AND t.lang = lp.lang
                    LEFT JOIN i18n_instances i ON i.instance = ?
                    LEFT JOIN i18n_instances ip ON i.lft BETWEEN ip.lft AND ip.rgt
                WHERE
                    t.instance = ip.instance
                ORDER BY
                    IF(t.id_message IS NULL,0,1), LOWER(CONVERT(m.message USING utf8)), m.id, t.lang = l.lang DESC
        ) tbl
        GROUP BY id;
TRANSLATIONS;

		return $this->GetArray( $sql, array(
		                                   $language,
		                                   $instance,
		                                   'tag' => 'Get all translations for current language'
		                              ) );
	}
public function getTranslations( $language, $instance, $parent_instance = false )
	{
        $sql = <<<TRANSLATIONS
        SELECT
         id,
         message,
         comment,
         SUBSTRING_INDEX(GROUP_CONCAT(destination_instance ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as destination_instance,
         SUBSTRING_INDEX(GROUP_CONCAT(language ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as language,
         SUBSTRING_INDEX(GROUP_CONCAT(translation ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as translation,
         SUBSTRING_INDEX(GROUP_CONCAT(author ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as author,
         SUBSTRING_INDEX(GROUP_CONCAT(modified ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as modified,
         SUBSTRING_INDEX(GROUP_CONCAT(is_base_lang ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as is_base_lang
        FROM
            (
                SELECT
                    m.id,
                    m.message,
                    m.comment,
                    m.instance AS message_instance,
                    t.instance AS translation_instance,
                    i.instance AS destination_instance,
                    ip.instance AS instance_parent,
                    (
                        SELECT
                            COUNT(ip_x.instance) as depth
                        FROM
                            i18n_instances i_x
                                JOIN i18n_instances ip_x ON i_x.lft BETWEEN ip_x.lft AND ip_x.rgt
                        WHERE
                            i_x.instance = t.instance
                        GROUP BY
                            i_x.instance
                    ) as instance_depth,	
                    t.lang as origin_language,
                    l.lang as language,
                    (
                        SELECT
                            COUNT(lp_x.lang) as depth
                        FROM
                            i18n_languages l_x
                                JOIN i18n_languages lp_x ON l_x.lft BETWEEN lp_x.lft AND lp_x.rgt
                        WHERE
                            l_x.lang = lp.lang
                        GROUP BY
                            l_x.lang
                    ) as language_depth,	
                    t.translation AS translation,
                    t.author AS author,
                    t.modified AS modified,
                    IF(t.lang = l.lang, 1, 0) as is_base_lang
                    
                FROM
                    i18n_messages m
                    LEFT JOIN i18n_languages l ON l.lang = ?
                    LEFT JOIN i18n_languages lp ON l.lft BETWEEN lp.lft AND lp.rgt	
                    LEFT JOIN i18n_translations t ON m.id = t.id_message AND t.lang = lp.lang
                    LEFT JOIN i18n_instances i ON i.instance = ?
                    LEFT JOIN i18n_instances ip ON i.lft BETWEEN ip.lft AND ip.rgt
                WHERE
                    t.instance = ip.instance
                ORDER BY
                    IF(t.id_message IS NULL,0,1), LOWER(CONVERT(m.message USING utf8)), m.id, t.lang = l.lang DESC
        ) tbl
        GROUP BY id;
TRANSLATIONS;

		return $this->GetArray( $sql, array(
		                                   $language,
		                                   $instance,
		                                   'tag' => 'Get all translations for current language'
		                              ) );
	}
public function getTranslations ( $ language , $ instance , $ parent_instance = false ) { $ sql =  <<<TRANSLATIONS
        SELECT
         id,
         message,
         comment,
         SUBSTRING_INDEX(GROUP_CONCAT(destination_instance ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as destination_instance,
         SUBSTRING_INDEX(GROUP_CONCAT(language ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as language,
         SUBSTRING_INDEX(GROUP_CONCAT(translation ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as translation,
         SUBSTRING_INDEX(GROUP_CONCAT(author ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as author,
         SUBSTRING_INDEX(GROUP_CONCAT(modified ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as modified,
         SUBSTRING_INDEX(GROUP_CONCAT(is_base_lang ORDER BY language_depth DESC, instance_depth DESC SEPARATOR '##-##'),'##-##',1) as is_base_lang
        FROM
            (
                SELECT
                    m.id,
                    m.message,
                    m.comment,
                    m.instance AS message_instance,
                    t.instance AS translation_instance,
                    i.instance AS destination_instance,
                    ip.instance AS instance_parent,
                    (
                        SELECT
                            COUNT(ip_x.instance) as depth
                        FROM
                            i18n_instances i_x
                                JOIN i18n_instances ip_x ON i_x.lft BETWEEN ip_x.lft AND ip_x.rgt
                        WHERE
                            i_x.instance = t.instance
                        GROUP BY
                            i_x.instance
                    ) as instance_depth,	
                    t.lang as origin_language,
                    l.lang as language,
                    (
                        SELECT
                            COUNT(lp_x.lang) as depth
                        FROM
                            i18n_languages l_x
                                JOIN i18n_languages lp_x ON l_x.lft BETWEEN lp_x.lft AND lp_x.rgt
                        WHERE
                            l_x.lang = lp.lang
                        GROUP BY
                            l_x.lang
                    ) as language_depth,	
                    t.translation AS translation,
                    t.author AS author,
                    t.modified AS modified,
                    IF(t.lang = l.lang, 1, 0) as is_base_lang
                    
                FROM
                    i18n_messages m
                    LEFT JOIN i18n_languages l ON l.lang = ?
                    LEFT JOIN i18n_languages lp ON l.lft BETWEEN lp.lft AND lp.rgt	
                    LEFT JOIN i18n_translations t ON m.id = t.id_message AND t.lang = lp.lang
                    LEFT JOIN i18n_instances i ON i.instance = ?
                    LEFT JOIN i18n_instances ip ON i.lft BETWEEN ip.lft AND ip.rgt
                WHERE
                    t.instance = ip.instance
                ORDER BY
                    IF(t.id_message IS NULL,0,1), LOWER(CONVERT(m.message USING utf8)), m.id, t.lang = l.lang DESC
        ) tbl
        GROUP BY id;
TRANSLATIONS ; return $ this -> GetArray ( $ sql , array ( $ language , $ instance , 'tag' => 'Get all translations for current language' ) ) ; }
Returns the translations list for a given langauge.

@param string $language
@return array
Returns the translations list for a given langauge .