Page 1 of 1

[3.2][BETA] Guest Language Selector

Posted: Mon Jan 07, 2019 11:04 am
by MichaT
Extension Name: Guest Language Selector
Author: MichaT

Extension Description: Shows a drop-down-box with all installed languages at the navigation bar for guests only
Extension Version: 1.0.1

Requirements: phpBB 3.2.x

Features:
  • Guests can switch between all installed languages
  • CSS file to change the display style of the drop-down-box
  • INI file to change some options
Screenshot: https://imgur.com/a/yXGf1QB

Extension Download:

Guest Language Selector v1.0.0
Guest Language Selector v1.0.1

Installation:
  1. Download the latest release.
  2. Unzip the downloaded release to `/ext/`.
  3. If done correctly, you'll have the main extension class at (your forum root)/ext/mtsd/switchlang/composer.json
  4. Navigate in the ACP to `Customise -> Manage extensions`
  5. Look for `Guest Language Selector` under the Disabled Extensions list, and click its `Enable` link.
Change log:
## 1.0.1 - 2019-01-09

- added more template variables at "overall_header_breadcrumbs_after.html" for a more flexible layout change
- now the extension automatically ignores the URL parameter "language" if the guest selected a language via the dropdownbox
- now the extension automatically ignores the stored language from the cookie if the URL parameter "language" is used
- removed the no longer required INI option "IgnoreUrlLanguage"

## 1.0.0 - 2019-01-07

- First release

Re: [3.2][BETA] Guest Language Selector

Posted: Wed Jan 09, 2019 6:58 am
by NastyBoy
That is a good one thank you

Re: [3.2][BETA] Guest Language Selector

Posted: Wed Jan 23, 2019 5:13 pm
by NastyBoy
What exactly does he translate for guests? All forums and texts?

Re: [3.2][BETA] Guest Language Selector

Posted: Wed Jan 23, 2019 7:48 pm
by pikachuturkey
NastyBoy wrote:
Wed Jan 23, 2019 5:13 pm
What exactly does he translate for guests? All forums and texts?
Guests can switch between all installed languages
Only can switch between installed language. Only Structural texts of phpbb.

Re: [3.2][BETA] Guest Language Selector

Posted: Fri Feb 01, 2019 5:36 pm
by NastyBoy
okay thank you

Re: [3.2][BETA] Guest Language Selector

Posted: Thu May 14, 2020 1:14 pm
by sanekplus
Some fixes for phpBB 3.3 compatibility.

1) New ext/mtsd/langswitch/config/services.yml

Code: Select all

services:
    mtsd.langswitch.listener:
        class: 'mtsd\langswitch\event\listener'
        arguments:
            - '@config'
            - '@template'
            - '@user'
            - '@dbal.conn'
        tags:
            - { name: 'event.listener' }
2) Fix broken path to globe.png for non-root sections like FAQ

Code: Select all

--- ext/mtsd/langswitch/event/listener.php	2020-05-14 14:58:01.480283144 +0300
+++ ext/mtsd/langswitch/event/listener.php	2020-05-14 15:01:15.361017659 +0300
@@ -80,7 +80,8 @@
 	    $this->template->assign_vars(array('LANG_LIST_START' => $template_var));
 	    
 	    //$lang_form .= '<label for="language_selector">'.$user->lang['L_LANGUAGE'].$user->lang['L_COLON'].'</label>';
-			$template_var = '<span class="langswitch_globe"><img src="./ext/mtsd/langswitch/styles/all/theme/images/globe.png"></span>';
+			global $phpbb_path_helper;
+			$template_var = '<span class="langswitch_globe"><img src="'.$phpbb_path_helper->get_web_root_path().'/ext/mtsd/langswitch/styles/all/theme/images/globe.png"></span>';
 			$this->template->assign_vars(array('LANG_GLOBE_ICON' => $template_var));
 			
 			$template_var = '<form class="langswitch_form" method="post">';
3) Remove original language selector on registration page broken by extension (actually it is not extension but prosilver patch)

Code: Select all

--- styles/prosilver/template/ucp_agreement.html	2020-05-14 15:49:17.168977907 +0300
+++ styles/prosilver/template/ucp_agreement.html	2020-05-14 16:01:24.324791843 +0300
@@ -15,12 +15,6 @@
 	}
 </script>
 
-	<form method="post" action="{S_UCP_ACTION}" id="register">
-		<p class="rightside">
-			<label for="lang">{L_LANGUAGE}{L_COLON}</label><select name="lang" id="lang" onchange="change_language(this.value); return false;" title="{L_LANGUAGE}">{S_LANG_OPTIONS}</select>
-			{S_HIDDEN_FIELDS}
-		</p>
-	</form>
 
 	<div class="clear"></div>
 

Re: [3.2][BETA] Guest Language Selector

Posted: Tue Jun 23, 2020 5:52 am
by php_BB_Lover
sanekplus wrote:
Thu May 14, 2020 1:14 pm
Some fixes for phpBB 3.3 compatibility.

1) New ext/mtsd/langswitch/config/services.yml

Code: Select all

services:
    mtsd.langswitch.listener:
        class: 'mtsd\langswitch\event\listener'
        arguments:
            - '@config'
            - '@template'
            - '@user'
            - '@dbal.conn'
        tags:
            - { name: 'event.listener' }
2) Fix broken path to globe.png for non-root sections like FAQ

Code: Select all

--- ext/mtsd/langswitch/event/listener.php	2020-05-14 14:58:01.480283144 +0300
+++ ext/mtsd/langswitch/event/listener.php	2020-05-14 15:01:15.361017659 +0300
@@ -80,7 +80,8 @@
 	    $this->template->assign_vars(array('LANG_LIST_START' => $template_var));
 	    
 	    //$lang_form .= '<label for="language_selector">'.$user->lang['L_LANGUAGE'].$user->lang['L_COLON'].'</label>';
-			$template_var = '<span class="langswitch_globe"><img src="./ext/mtsd/langswitch/styles/all/theme/images/globe.png"></span>';
+			global $phpbb_path_helper;
+			$template_var = '<span class="langswitch_globe"><img src="'.$phpbb_path_helper->get_web_root_path().'/ext/mtsd/langswitch/styles/all/theme/images/globe.png"></span>';
 			$this->template->assign_vars(array('LANG_GLOBE_ICON' => $template_var));
 			
 			$template_var = '<form class="langswitch_form" method="post">';
3) Remove original language selector on registration page broken by extension (actually it is not extension but prosilver patch)

Code: Select all

--- styles/prosilver/template/ucp_agreement.html	2020-05-14 15:49:17.168977907 +0300
+++ styles/prosilver/template/ucp_agreement.html	2020-05-14 16:01:24.324791843 +0300
@@ -15,12 +15,6 @@
 	}
 </script>
 
-	<form method="post" action="{S_UCP_ACTION}" id="register">
-		<p class="rightside">
-			<label for="lang">{L_LANGUAGE}{L_COLON}</label><select name="lang" id="lang" onchange="change_language(this.value); return false;" title="{L_LANGUAGE}">{S_LANG_OPTIONS}</select>
-			{S_HIDDEN_FIELDS}
-		</p>
-	</form>
 
 	<div class="clear"></div>
 
Hi,
there is also language-select in ucp_register.html that dosnt work.
when i select a language, it redirects to register page again,
how can i fix this too? to store the selected-language in user-profile?
thank you,

styles\prosilver\template\ucp_register.html

Code: Select all

<dl>
	<dt><label for="lang">{L_LANGUAGE}{L_COLON}</label></dt>
	<dd><select name="lang" id="lang" onchange="change_language(this.value); return false;" tabindex="6" title="{L_LANGUAGE}">{S_LANG_OPTIONS}</select></dd>
</dl>

Re: [3.2][BETA] Guest Language Selector

Posted: Tue Jun 23, 2020 11:52 am
by sanekplus
php_BB_Lover wrote:
Tue Jun 23, 2020 5:52 am
there is also language-select in ucp_register.html that dosnt work.
when i select a language, it redirects to register page again,
how can i fix this too? to store the selected-language in user-profile?
Yes, you are right
4) Prevent second original lang selector in registration form to restart registration process (also prosilver not ext patch), maybe it is better to remove second selector completely

Code: Select all

--- styles/prosilver/template/ucp_register.html	2020-06-23 14:10:28.297188370 +0300
+++ styles/prosilver/template/ucp_register.html	2020-06-23 14:18:23.897738018 +0300
@@ -59,7 +59,7 @@
 	<!-- EVENT ucp_register_options_before -->
 	<dl>
 		<dt><label for="lang">{L_LANGUAGE}{L_COLON}</label></dt>
-		<dd><select name="lang" id="lang" onchange="change_language(this.value); return false;" tabindex="6" title="{L_LANGUAGE}">{S_LANG_OPTIONS}</select></dd>
+		<dd><select name="lang" id="lang" onchange="document.cookie = '{COOKIE_NAME}_lang=' + this.value + '; path={COOKIE_PATH}'; return false;" tabindex="6" title="{L_LANGUAGE}">{S_LANG_OPTIONS}</select></dd>
 	</dl>
 
 	<!-- INCLUDE timezone_option.html -->

Re: [3.2][BETA] Guest Language Selector

Posted: Wed Jun 24, 2020 3:43 am
by php_BB_Lover
sanekplus wrote:
Tue Jun 23, 2020 11:52 am
php_BB_Lover wrote:
Tue Jun 23, 2020 5:52 am
there is also language-select in ucp_register.html that dosnt work.
when i select a language, it redirects to register page again,
how can i fix this too? to store the selected-language in user-profile?
Yes, you are right
4) Prevent second original lang selector in registration form to restart registration process (also prosilver not ext patch), maybe it is better to remove second selector completely

Code: Select all

--- styles/prosilver/template/ucp_register.html	2020-06-23 14:10:28.297188370 +0300
+++ styles/prosilver/template/ucp_register.html	2020-06-23 14:18:23.897738018 +0300
@@ -59,7 +59,7 @@
 	<!-- EVENT ucp_register_options_before -->
 	<dl>
 		<dt><label for="lang">{L_LANGUAGE}{L_COLON}</label></dt>
-		<dd><select name="lang" id="lang" onchange="change_language(this.value); return false;" tabindex="6" title="{L_LANGUAGE}">{S_LANG_OPTIONS}</select></dd>
+		<dd><select name="lang" id="lang" onchange="document.cookie = '{COOKIE_NAME}_lang=' + this.value + '; path={COOKIE_PATH}'; return false;" tabindex="6" title="{L_LANGUAGE}">{S_LANG_OPTIONS}</select></dd>
 	</dl>
 
 	<!-- INCLUDE timezone_option.html -->
thank you, worked!
two questions for you:
1. what code should i edit, to show the language-select in the same place, after user-login too? (when users change the language from here, it changes their profile language too, or vice versa)
2. is it possible to fix this extension, not to edit theme files? (ucp_agreement.html, ucp_register.html)

Re: [3.2][BETA] Guest Language Selector

Posted: Wed Jun 24, 2020 11:36 am
by sanekplus
php_BB_Lover wrote:
Wed Jun 24, 2020 3:43 am
two questions for you:
1. what code should i edit, to show the language-select in the same place, after user-login too? (when users change the language from here, it changes their profile language too, or vice versa)
2. is it possible to fix this extension, not to edit theme files? (ucp_agreement.html, ucp_register.html)
Sorry, I don't know, I'm not professional phpBB developer, I just adopt this extension to my goals in the simplest way: before login user can change language using extension, after login user can change language using profile setting.

Re: [3.2][BETA] Guest Language Selector

Posted: Wed Jun 24, 2020 7:17 pm
by php_BB_Lover
sanekplus wrote:
Wed Jun 24, 2020 11:36 am
php_BB_Lover wrote:
Wed Jun 24, 2020 3:43 am
two questions for you:
1. what code should i edit, to show the language-select in the same place, after user-login too? (when users change the language from here, it changes their profile language too, or vice versa)
2. is it possible to fix this extension, not to edit theme files? (ucp_agreement.html, ucp_register.html)
Sorry, I don't know, I'm not professional phpBB developer, I just adopt this extension to my goals in the simplest way: before login user can change language using extension, after login user can change language using profile setting.
Thank you, I was just thinking about to change the language by both (extension and profile setting) after login. But i don't know how to show the language-select to logged-in users!