This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Jump to the post that solved this thread.
Change default language
#1
[Solved] Change default language
Good afternoon,

I would like to ask a little help. I'm translating the whole sentence into Portuguese from the code and wanted the table in my "tr_PT_tx" database to be the default when creating a user.

I have already made a change to a file in /etc/sentora/panel/dryden/ui/language.class.php leaving it like this:
PHP Code:
<?php

/**
 * @copyright 2014-2015 Sentora Project (http://www.sentora.org/) 
 * Sentora is a GPL fork of the ZPanel Project whose original header follows:
 *
 * Language translation class.
 * @package zpanelx
 * @subpackage dryden -> ui
 * @version 1.0.1
 * @author Russell Skinner (rskinner@zpanelcp.com)
 * @copyright ZPanel Project (http://www.zpanelcp.com/)
 * @link http://www.zpanelcp.com/
 * @license GPL (http://www.gnu.org/licenses/gpl.html)
 */
class ui_language {

    static $LangCol;

    /**
     * Used to translate a text string into the language preference of the user.
     * @author Pascal Peyremorte (ppeyremorte@sentora.org)
     * @global db_driver $zdbh The ZPX database handle.
     * @param $message The string to translate.
     * @return string The transalated string.
     */
    static function translate($message) {
        global $zdbh;

        if (empty(self::$LangCol)) {
            $uid ctrl_auth::CurrentUserID();
            $sql $zdbh->prepare('SELECT ud_language_vc FROM x_profiles WHERE ud_user_fk=' $uid);
            $sql->execute();
            $lang $sql->fetch();
            self::$LangCol 'tr_' $lang['ud_language_vc'] . '_tx';
        }
        if (self::$LangCol == 'tr_PT_tx')
            return $message//no translation required, portuguese used

        $SlashedMessage addslashes($message); //protect special chars
        $sql $zdbh->prepare('SELECT ' self::$LangCol ' FROM x_translations WHERE tr_PT_tx =:message');
        $sql->bindParam(':message'$SlashedMessage);
        $sql->execute();
        $result $sql->fetch();

        if ($result) {
            if (!fs_director::CheckForEmptyValue($result[self::$LangCol]))
                return $result[self::$LangCol]; //valid translation present
            else
                return $message//translated message empty
        } else { //message not found in the table
            //add unfound message to the table with empties translations
            $sql $zdbh->prepare('INSERT INTO x_translations SET tr_PT_tx=:message');
            $sql->bindParam(':message'$SlashedMessage);
            $sql->execute();
            return $message;
        }
    }

    /**
     * Return array of column names for a table.
     * @author Russell Skinner (rskinner@zpanelcp.com)
     * @param string $table The table name to return that column names from.
     * @return array List of column names.
     */
    static function GetColumnNames($table) {
        global $zdbh;
        $sql "select column_name from information_schema.columns where lower(table_name)=lower(:table)";
        $stmt $zdbh->prepare($sql);
        $stmt->bindParam(':table'$table);
        try {
            if ($stmt->execute()) {
                $raw_column_data $stmt->fetchAll(PDO::FETCH_ASSOC);
                foreach ($raw_column_data as $outer_key => $array) {
                    foreach ($array as $inner_key => $value) {
                        if (!(int) $inner_key) {
                            $column_names[] = $value;
                        }
                    }
                }
            }
            return $column_names;
        } catch (Exception $e) {
            
        
}
    }

}

?>

However, there is still some file to move so that when creating a new user the default language is the PT.

I await answers to help me.

Greetings.
Reply
Thanks given by:
#2
[Solved] RE: Change default language
There used to be a setting for default language without having to change any code. I'll have to take a look since I haven't used it in years Tongue
-TGates - Head of Support

SEARCH the Forums or read the DOCUMENTATION before posting!
Modules Maintained: 13 - Module Installs: 108k+

Find my support or modules helpful? Donate HERE
Get your domains using my affiliate link:
GoDaddy - Domains
Reply
Thanks given by:
#3
[Solved] RE: Change default language
Sure thank you, can you get me the solution as soon as possible?
Reply
Thanks given by:
#4
[Solved] RE: Change default language
I can not find anywhere a setting for 'Default Language' which I had thought was in the core some where...


I also was not able to find where it actually enters the default language into the user's x_profiles database table Huh 

In the file: \modules\manage_clients\code\controller.ext.php lines 532-542 is where it adds the user's information to the x_profiles database, but no reference of the language:

Code:
$sql = $zdbh->prepare("INSERT INTO x_profiles (ud_user_fk, ud_fullname_vc, ud_group_fk, ud_package_fk, ud_address_tx, ud_postcode_vc, ud_phone_vc, ud_created_ts) VALUES (:userid, :fullname, :packageid, :groupid, :address, :postcode, :phone, :time)");
Maybe try changing that line to:

Code:
$sql = $zdbh->prepare("INSERT INTO x_profiles (ud_user_fk, ud_fullname_vc, ud_language_vc, ud_group_fk, ud_package_fk, ud_address_tx, ud_postcode_vc, ud_phone_vc, ud_created_ts) VALUES (:userid, :fullname, 'PT', :packageid, :groupid, :address, :postcode, :phone, :time)");

I think that because of the way the language system works, setting a language other than English as the default may have issues with lines that are not translated or empty. You may need to test that.
-TGates - Head of Support

SEARCH the Forums or read the DOCUMENTATION before posting!
Modules Maintained: 13 - Module Installs: 108k+

Find my support or modules helpful? Donate HERE
Get your domains using my affiliate link:
GoDaddy - Domains
Reply
Thanks given by:
#5
[Solved] RE: Change default language
Hi,
But just put the PT or will I have to insert the complete table?
Reply
Thanks given by:
#6
[Solved] RE: Change default language
Just PT
-TGates - Head of Support

SEARCH the Forums or read the DOCUMENTATION before posting!
Modules Maintained: 13 - Module Installs: 108k+

Find my support or modules helpful? Donate HERE
Get your domains using my affiliate link:
GoDaddy - Domains
Reply
Thanks given by:
#7
[Solved] RE: Change default language
Blush  If there is a way to read the language of the computer is very good, I find that idea is very useful
Reply
Thanks given by:
Jump to the post that solved this thread.


Possibly Related Threads...
Thread Author Replies Views Last Post
[split] phpmyadmin change passwords burdreport2 1 628 04-26-2018, 01:15 AM
Last Post: TGates
Sentora Change Storage To Specific Domain sathish2009 1 832 03-24-2018, 09:05 AM
Last Post: Me.B
Change client's data folder problem dimnas 1 717 02-14-2018, 03:49 AM
Last Post: TGates

Forum Jump:


Users browsing this thread: 1 Guest(s)