CodeIgniter Forums
Multi-language - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Multi-language (/showthread.php?tid=29219)

Pages: 1 2


Multi-language - El Forum - 04-02-2010

[eluser]momen[/eluser]
hello i want make site Multi-language using database

when the admin add language form control panel

this language display the user site and you cane used it

any one can help me
thanks


Multi-language - El Forum - 04-02-2010

[eluser]Sbioko[/eluser]
Why database? You can use translation files in language folder. There is no need in this.


Multi-language - El Forum - 04-02-2010

[eluser]momen[/eluser]
the Idea add the language name of data base and upload the translation files in language folder of this language


Multi-language - El Forum - 04-02-2010

[eluser]Sbioko[/eluser]
I don't see any reason for using database. Maybe, you can explain what you want in more informative way.


Multi-language - El Forum - 04-02-2010

[eluser]momen[/eluser]
the admin site want control the language
that mean's
1- add language for any time
2- display the language you want
ex
this admin now want add language japan's
go the admin control add the language japan's
and upload file after that this language display the site


Multi-language - El Forum - 04-02-2010

[eluser]Sbioko[/eluser]
Ok, maybe you don't understand me or I don't understand you. You want to have panel like that(for example):
Quote:Choose language: English | Russian | Ukrainian | Spanish | ..
Correct? If yes, then you need to use session library to remember user's choice of language. And no database. Database can be accessed from Session library, if you want it(config.php).


Multi-language - El Forum - 04-02-2010

[eluser]momen[/eluser]
i can found solve this problem using libraries lang_detect but
why add the language to file lang_detect.php

when write the file using (fopen) i can write the same file
when write array language will write last language
ex
$config['lang_avail'] = array(
'en' => 'english',
'en-uk' => 'en-uk',
'de' => 'german',
'de-at' => 'de-at'
);
when write
$config["lang_avail"]=array("France"=>"France");

the problem why convert array form database to Associative Arrays

the code
////
function write_config()
{
$head="<?php if (!defined('BASEPATH')) exit('No direct script access allowed');\n";
$url=$this->session->CI->config->config['base_url'];
$myFile = "application/config/lang_detect.php";
$fh = fopen($myFile, 'w+') or die("can't open file");
fwrite($fh,$head);
////////////////////
$query=$this->db->get('languages');

foreach ($query->result() as $row )
{
$bo=$row->name;
$bo2=$row->image;

}

$do=$bo;
$do2=$bo2;

$m=explode('.',$do2);
$body='$config["lang_avail"]=array("'.$m[0].'"=>"'.$do.'");';

fwrite($fh,$body);

$man='$config["lang_default"]="en";';
fwrite($fh,$man);
$man2='$config["lang_selected"]="en";';
fwrite($fh,$man2);
$man3='$config["lang_cookie_name"]="ci_language";';
fwrite($fh,$man3);
$man4='$config["lang_expiration"]="63072000";';
fwrite($fh,$man4);
$end='?>';
fwrite($fh,$end);

}


Multi-language - El Forum - 04-02-2010

[eluser]Sbioko[/eluser]
Excuse me, but I didn't understand anything.


Multi-language - El Forum - 04-02-2010

[eluser]momen[/eluser]
i want convert select array form data base

to Associative Arrays


Multi-language - El Forum - 04-02-2010

[eluser]PéturV[/eluser]
[quote author="momen" date="1270254977"]i want convert select array form data base

to Associative Arrays[/quote]

If I understand you right....

Code:
$query = $this->db->get('users');

if ($query->num_rows() > 0)
{    
    $row = $query->row_array();
    echo $row['id'];
}