[3.2][BETA] Guest Language Selector

A place for Extension Authors to post and receive feedback on Extensions still in development. No Extensions within this forum should be used within a live environment!
Scam Warning
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: Extensions Development rules

IMPORTANT FOR NEEDED EVENTS!!!
If you need an event for your extension please read this for the steps to follow to request the event(s)
Post Reply
MichaT
Registered User
Posts: 15
Joined: Sat Jan 05, 2019 5:44 am
Location: Thailand
Name: Michael

[3.2][BETA] Guest Language Selector

Post 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
NastyBoy
Registered User
Posts: 126
Joined: Wed May 31, 2017 7:03 pm
Location: Germany
Name: Tim
Contact:

Re: [3.2][BETA] Guest Language Selector

Post by NastyBoy »

That is a good one thank you
NastyBoy
Registered User
Posts: 126
Joined: Wed May 31, 2017 7:03 pm
Location: Germany
Name: Tim
Contact:

Re: [3.2][BETA] Guest Language Selector

Post by NastyBoy »

What exactly does he translate for guests? All forums and texts?
User avatar
pikachuturkey
Registered User
Posts: 314
Joined: Wed Dec 20, 2006 10:34 pm
Location: Türkiye(Turkey)
Name: Rıza
Contact:

Re: [3.2][BETA] Guest Language Selector

Post 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.
Health For Everyone ==> www.saglikforum.org
NastyBoy
Registered User
Posts: 126
Joined: Wed May 31, 2017 7:03 pm
Location: Germany
Name: Tim
Contact:

Re: [3.2][BETA] Guest Language Selector

Post by NastyBoy »

okay thank you
sanekplus
Registered User
Posts: 4
Joined: Thu May 14, 2020 12:17 pm

Re: [3.2][BETA] Guest Language Selector

Post 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>
 
php_BB_Lover
I've Been Banned!
Posts: 352
Joined: Tue Jun 23, 2020 5:18 am

Re: [3.2][BETA] Guest Language Selector

Post 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>
sanekplus
Registered User
Posts: 4
Joined: Thu May 14, 2020 12:17 pm

Re: [3.2][BETA] Guest Language Selector

Post 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 -->
php_BB_Lover
I've Been Banned!
Posts: 352
Joined: Tue Jun 23, 2020 5:18 am

Re: [3.2][BETA] Guest Language Selector

Post 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)
Version: phpBB 3.3.0
Theme: default
Regards
sanekplus
Registered User
Posts: 4
Joined: Thu May 14, 2020 12:17 pm

Re: [3.2][BETA] Guest Language Selector

Post 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.
php_BB_Lover
I've Been Banned!
Posts: 352
Joined: Tue Jun 23, 2020 5:18 am

Re: [3.2][BETA] Guest Language Selector

Post 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!
Version: phpBB 3.3.0
Theme: default
Regards
Post Reply

Return to “Extensions in Development”