switching the language

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Scam Warning
User avatar
MikovChain
Registered User
Posts: 137
Joined: Tue Aug 29, 2006 9:19 am

Re: switching the language

Post by MikovChain »

Hi all, I export the diff file, you can see it to find how:

Code: Select all

Index: C:/WebServer/wwwroot/phpbb3xs/styles/prosilver/template/overall_header.html
===================================================================
--- C:/WebServer/wwwroot/phpbb3xs/styles/prosilver/template/overall_header.html	(revision 71)
+++ C:/WebServer/wwwroot/phpbb3xs/styles/prosilver/template/overall_header.html	(revision 72)
@@ -106,17 +106,25 @@
 				<p style="display: none;"><a href="#start_here">{L_SKIP}</a></p>
 			</div>
 
+			<div id="search-box">
 		<!-- IF S_DISPLAY_SEARCH and not S_IN_SEARCH -->
-			<div id="search-box">
+			
 				<form action="{U_SEARCH}" method="get" id="search">
-				<fieldset>
 					<input name="keywords" id="keywords" type="text" maxlength="128" title="{L_SEARCH_KEYWORDS}" class="inputbox search" value="<!-- IF SEARCH_WORDS-->{SEARCH_WORDS}<!-- ELSE -->{L_SEARCH_MINI}<!-- ENDIF -->" onclick="if(this.value=='{LA_SEARCH_MINI}')this.value='';" onblur="if(this.value=='')this.value='{LA_SEARCH_MINI}';" /> 
 					<input class="button2" value="{L_SEARCH}" type="submit" /><br />
 					<a href="{U_SEARCH}" title="{L_SEARCH_ADV_EXPLAIN}">{L_SEARCH_ADV}</a> {S_HIDDEN_FIELDS}
-				</fieldset>
 				</form>
+			
+		<!-- ENDIF -->
+		<!-- IF S_LANG_SELECT -->
+				<form method="post" action="">
+						{S_LANG_SELECT}
+						<input class="button2" type="submit" id="change_lang" name="change_lang" value="{L_CHANGE}" /> 
+				</form>
+		<!-- ENDIF -->
 			</div>
-		<!-- ENDIF -->
+		
+		
 
 			<span class="corners-bottom"><span></span></span></div>
 		</div>
Index: C:/WebServer/wwwroot/phpbb3xs/includes/session.php
===================================================================
--- C:/WebServer/wwwroot/phpbb3xs/includes/session.php	(revision 71)
+++ C:/WebServer/wwwroot/phpbb3xs/includes/session.php	(revision 72)
@@ -135,7 +135,7 @@
 
 		// Give us some basic information
 		$this->time_now				= time();
-		$this->cookie_data			= array('u' => 0, 'k' => '');
+		$this->cookie_data			= array('u' => 0, 'k' => '', 'l' => '');
 		$this->update_session_page	= $update_session_page;
 		$this->browser				= (!empty($_SERVER['HTTP_USER_AGENT'])) ? htmlspecialchars((string) $_SERVER['HTTP_USER_AGENT']) : '';
 		$this->forwarded_for		= (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) ? (string) $_SERVER['HTTP_X_FORWARDED_FOR'] : '';
@@ -174,6 +174,7 @@
 		{
 			$this->cookie_data['u'] = request_var($config['cookie_name'] . '_u', 0, false, true);
 			$this->cookie_data['k'] = request_var($config['cookie_name'] . '_k', '', false, true);
+			$this->cookie_data['l'] = request_var($config['cookie_name'] . '_l', '', false, true);
 			$this->session_id 		= request_var($config['cookie_name'] . '_sid', '', false, true);
 
 			$SID = (defined('NEED_SID')) ? '?sid=' . $this->session_id : '?sid=';
@@ -183,7 +184,7 @@
 			{
 				$this->session_id = $_SID = request_var('sid', '');
 				$SID = '?sid=' . $this->session_id;
-				$this->cookie_data = array('u' => 0, 'k' => '');
+				$this->cookie_data = array('u' => 0, 'k' => '', 'l' => '');
 			}
 		}
 		else
@@ -1198,11 +1199,17 @@
 	*/
 	function setup($lang_set = false, $style = false)
 	{
-		global $db, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache;
+		global $db, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache, $phpbb_basic_lang;
 
 		if ($this->data['user_id'] != ANONYMOUS)
 		{
-			$this->lang_name = (file_exists($phpbb_root_path . 'language/' . $this->data['user_lang'] . "/common.$phpEx")) ? $this->data['user_lang'] : $config['default_lang'];
+			if (isset($phpbb_basic_lang) && $phpbb_basic_lang){
+				$this->lang_name = (file_exists($phpbb_root_path . 'language/' . $phpbb_basic_lang . "/common.$phpEx")) ? $phpbb_basic_lang : $config['default_lang'];
+			}else if(isset($this->cookie_data['l']) && $this->cookie_data['l']){
+				$this->lang_name = (file_exists($phpbb_root_path . 'language/' . $this->cookie_data['l'] . "/common.$phpEx")) ? $this->cookie_data['l'] : $config['default_lang'];
+			}else {
+				$this->lang_name = (file_exists($phpbb_root_path . 'language/' . $this->data['user_lang'] . "/common.$phpEx")) ? $this->data['user_lang'] : $config['default_lang'];
+			}
 			$this->lang_path = $phpbb_root_path . 'language/' . $this->lang_name . '/';
 
 			$this->date_format = $this->data['user_dateformat'];
@@ -1211,7 +1218,13 @@
 		}
 		else
 		{
-			$this->lang_name = $config['default_lang'];
+			if (isset($phpbb_basic_lang) && $phpbb_basic_lang){
+				$this->lang_name = (file_exists($phpbb_root_path . 'language/' . $phpbb_basic_lang . "/common.$phpEx")) ? $phpbb_basic_lang : $config['default_lang'];
+			}else if(isset($this->cookie_data['l']) && $this->cookie_data['l']){
+				$this->lang_name = (file_exists($phpbb_root_path . 'language/' . $this->cookie_data['l'] . "/common.$phpEx")) ? $this->cookie_data['l'] : $config['default_lang'];
+			}else {
+				$this->lang_name = $config['default_lang'];
+			}
 			$this->lang_path = $phpbb_root_path . 'language/' . $this->lang_name . '/';
 			$this->date_format = $config['default_dateformat'];
 			$this->timezone = $config['board_timezone'] * 3600;
Index: C:/WebServer/wwwroot/phpbb3xs/includes/functions.php
===================================================================
--- C:/WebServer/wwwroot/phpbb3xs/includes/functions.php	(revision 71)
+++ C:/WebServer/wwwroot/phpbb3xs/includes/functions.php	(revision 72)
@@ -4092,6 +4092,7 @@
 		'L_LOGIN_LOGOUT'	=> $l_login_logout,
 		'L_INDEX'			=> $user->lang['FORUM_INDEX'],
 		'L_ONLINE_EXPLAIN'	=> $l_online_time,
 
 		'U_PRIVATEMSGS'			=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=inbox'),
 		'U_RETURN_INBOX'		=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=inbox'),
@@ -4134,6 +4135,7 @@
 		'S_DISPLAY_PM'			=> ($config['allow_privmsg'] && $user->data['is_registered'] && ($auth->acl_get('u_readpm') || $auth->acl_get('u_sendpm'))) ? true : false,
 		'S_DISPLAY_MEMBERLIST'	=> (isset($auth)) ? $auth->acl_get('u_viewprofile') : 0,
 		'S_NEW_PM'				=> ($s_privmsg_new) ? 1 : 0,
+		'S_LANG_SELECT'	=> '<select id="basic_lang" name="basic_lang">' . language_select($user->lang_name) . '</select>',
 
 		'T_THEME_PATH'			=> "{$phpbb_root_path}styles/" . $user->theme['theme_path'] . '/theme',
 		'T_TEMPLATE_PATH'		=> "{$phpbb_root_path}styles/" . $user->theme['template_path'] . '/template',
Index: C:/WebServer/wwwroot/phpbb3xs/common.php
===================================================================
--- C:/WebServer/wwwroot/phpbb3xs/common.php	(revision 71)
+++ C:/WebServer/wwwroot/phpbb3xs/common.php	(revision 72)
@@ -190,6 +190,7 @@
 $cache		= new cache();
 $db			= new $sql_db();
 
+
 // Connect to DB
 $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false);
 
@@ -199,4 +200,9 @@
 // Grab global variables, re-cache if necessary
 $config = $cache->obtain_config();
 
+$phpbb_basic_lang = basename(request_var('basic_lang', ''));
+if ($phpbb_basic_lang){
+	$user->set_cookie('l', $phpbb_basic_lang, time()+86400);
+}
+
 ?>
\ No newline at end of file
Dirk67
Registered User
Posts: 29
Joined: Sun Jun 10, 2007 10:53 am

Re: switching the language

Post by Dirk67 »

Hello MikovChain,

thank you for providing the code -> I will check this out....

Anybody got a solution for the imageset-switching problem yet ?
..:: web is what we make it ::..
...sorry for my imperfect english (I'm just a German ;-)
Dirk67
Registered User
Posts: 29
Joined: Sun Jun 10, 2007 10:53 am

Re: switching the language

Post by Dirk67 »

Dirk67 wrote:Hello MikovChain,

thank you for providing the code -> I will check this out....

Anybody got a solution for the imageset-switching problem yet ?
anything new (imageset-switching problem) up to now ?
..:: web is what we make it ::..
...sorry for my imperfect english (I'm just a German ;-)
d-iivil
Registered User
Posts: 15
Joined: Thu Aug 22, 2002 11:51 am
Location: FINLAND

Re: switching the language

Post by d-iivil »

Anyone working with this?

I would also like to make possible to fully switch language from header :)
-=Perkele=-
Dirk67
Registered User
Posts: 29
Joined: Sun Jun 10, 2007 10:53 am

Re: switching the language

Post by Dirk67 »

any news about switching language from front-end (for simple visitors as well) ??
..:: web is what we make it ::..
...sorry for my imperfect english (I'm just a German ;-)

Return to “[3.0.x] MOD Requests”