Language Switch / Phrase ?

erich37

Well-known member
I do have a forum with 2 languages (english and german).

- when looking at the forum in english language, the language-switch-link at the bottom-left says "english".

- when looking at the forum in german language, the language-switch-link at the bottom-left says "german".

However this is rather confusing for a visitor, as when he is viewing the forum in german-language and sees a link at the bottom left which says "Deutsch", he will rather not understand what this means and that this is the link in order to change the language into english.

Is there a way to change the wording for the language-switch-link at the bottom-left ? Like changing the phrase for this link to "Change Language" ? The issue is that there is not a phrase existing for this language-switch-link, but the naming is coming from the installed language-file.

However the name of the language file needs to be remaining, as I still want to show the wording "english" and "german" within the pop-up-window.

Suggestion for XF-developers:
please add an additional phrase for the language-switch at the bottom-left.
 
Admin CP -> Appearance -> Templates -> footer

Replace this:

Code:
				<xen:if is="{$canChangeLanguage}">
					<dt>{xen:phrase language}</dt>
					<dd><a href="{xen:link 'misc/language', '', 'redirect={$requestPaths.requestUri}'}" class="OverlayTrigger Tooltip" title="{xen:phrase language_chooser}">{$visitorLanguage.title}</a></dd>
				</xen:if>

with this:

Code:
				<xen:if is="{$canChangeLanguage}">
					<dt>{xen:phrase language}</dt>
					<dd><a href="{xen:link 'misc/language', '', 'redirect={$requestPaths.requestUri}'}" class="OverlayTrigger Tooltip">{xen:phrase language_chooser}</a></dd>
				</xen:if>

That will use the language_chooser phrase in place of the name of the active language.
 
how do I go about just having the language-switch without the pop-up-window ?

Like just showing two flags (country-flag-image for each language) and when clicking on the flag, the language changes on the fly.
 
how do I go about just having the language-switch without the pop-up-window ?

Like just showing two flags (country-flag-image for each language) and when clicking on the flag, the language changes on the fly.

The language records are not available to the footer template. An addon is required to properly fetch and display those links inline with the footer.

Alternatively you can just hard code the links by using code like this:

Code:
				<xen:if is="{$canChangeLanguage}">
					<dd><a href="{xen:link 'misc/language', '', 'language_id=1', '_xfToken={$visitor.csrf_token_page}', 'redirect={$redirect}'}">English</a></dd>
					<dd><a href="{xen:link 'misc/language', '', 'language_id=2', '_xfToken={$visitor.csrf_token_page}', 'redirect={$redirect}'}">German</a></dd>
				</xen:if>
 
The language records are not available to the footer template. An addon is required to properly fetch and display those links inline with the footer.

Alternatively you can just hard code the links by using code like this:

Code:
				<xen:if is="{$canChangeLanguage}">
					<dd><a href="{xen:link 'misc/language', '', 'language_id=1', '_xfToken={$visitor.csrf_token_page}', 'redirect={$redirect}'}">English</a></dd>
					<dd><a href="{xen:link 'misc/language', '', 'language_id=2', '_xfToken={$visitor.csrf_token_page}', 'redirect={$redirect}'}">German</a></dd>
				</xen:if>

Hey Jake,

what would be the code for adding this into the sidebar ?
So having this language-switch in the sidebar with 2 images ?

Appreciate your help!
 
what would be the code for adding this into the sidebar ?
So having this language-switch in the sidebar with 2 images ?

This would be a good template for that:

Admin CP -> Appearance -> Templates -> sidebar_visitor_panel

Here is the same code with some formatting for the sidebar. You can add it to the bottom of the template:

Code:
<div class="section">
	<div class="secondaryContent">
		<h3>{xen:phrase language_chooser}</h3>
		<a href="{xen:link 'misc/language', '', 'language_id=1', '_xfToken={$visitor.csrf_token_page}', 'redirect={$redirect}'}">English</a>
		<a href="{xen:link 'misc/language', '', 'language_id=2', '_xfToken={$visitor.csrf_token_page}', 'redirect={$redirect}'}">German</a>
	</div>
</div>

Here is what it looks like:

Screen shot 2011-02-19 at 8.51.35 PM.webp

You can replace the text with images if you want:

Code:
<div class="section">
	<div class="secondaryContent">
		<h3>{xen:phrase language_chooser}</h3>
		<a href="{xen:link 'misc/language', '', 'language_id=1', '_xfToken={$visitor.csrf_token_page}', 'redirect={$redirect}'}"><img src="PATH/TO/english.gif" border="0" /></a>
		<a href="{xen:link 'misc/language', '', 'language_id=2', '_xfToken={$visitor.csrf_token_page}', 'redirect={$redirect}'}"><img src="PATH/TO/german.gif" border="0" /></a>
	</div>
</div>
 
Hi Jake,

I do have the languages now in the sidebar thanks to your help.

Is there a way to show in the sidebar which language is currently selected (active)? Like making the selected language in bold font-style ?
 
Is there a way to show in the sidebar which language is currently selected (active)? Like making the selected language in bold font-style ?

This code will do that:

Code:
<div class="section">
	<div class="secondaryContent">
		<h3>{xen:phrase language_chooser}</h3>
		<a href="{xen:link 'misc/language', '', 'language_id=1', '_xfToken={$visitor.csrf_token_page}', 'redirect={$redirect}'}"<xen:if is="{$visitor.language_id} == 1"> style="font-weight: bold;"</xen:if>>English</a>
		<a href="{xen:link 'misc/language', '', 'language_id=2', '_xfToken={$visitor.csrf_token_page}', 'redirect={$redirect}'}"<xen:if is="{$visitor.language_id} == 2"> style="font-weight: bold;"</xen:if>>German</a>
	</div>
</div>

It gets pretty messy with the conditions since we are hard-coding the languages instead of pulling records from the database, but it works.
 
Hi Jake,

could you please help me on the following:

I do have the language-list in the sidebar, but I would like to change it so that when hovering over the language, that the bg-color changes when hovering over a certain language.
I can not get the CSS working so that it shows the full width of the sidebar when hovering over the text (so that the bg-color is not just over the text but has the full width of the sidebar.
Very similar than when hovering over the items when opening the "quick navigation menu".

So I do not want to show which language is active, just having the language-list without the links being underlined. But when hovering over the languages, then the bg-color should show (but with the full width of the sidebar).

Do you have an idea of how to do this?
 
Also our board uses two languages. For first time visitors and guests I think it would be better to show the language flags on a more logical place. How could I make it look & function like my mockup?
Thanks!
Would really like a setup like this! If anyone figures out how to do this, please share your changes here.
 
Also our board uses two languages. For first time visitors and guests I think it would be better to show the language flags on a more logical place. How could I make it look & function like my mockup?
Thanks!

Admin CP -> Appearance -> Templates -> login_bar

Add the red code:

Rich (BB code):
<xen:require css="login_bar.css" />

<div id="loginBar">
	<div class="pageWidth">
		<div class="pageContent">	
			<h3 id="loginBarHandle">
				<label for="LoginControl"><a href="{xen:link login}" class="concealed noOutline">{xen:if $xenOptions.registrationSetup.enabled, {xen:phrase log_in_or_sign_up}, {xen:phrase log_in}}</a></label>
			</h3>
			
			<h3 id="loginBarHandle" style="margin-right: 150px;">
				<label>
					<a href="{xen:link 'misc/language', '', 'language_id=1', '_xfToken={$visitor.csrf_token_page}', 'redirect={$redirect}'}"><img src="path/to/flag1.jpg" border="0" /></a>
					<a href="{xen:link 'misc/language', '', 'language_id=2', '_xfToken={$visitor.csrf_token_page}', 'redirect={$redirect}'}"><img src="path/to/flag2.jpg" border="0" /></a>
				</label>
			</h3>

			<span class="helper"></span>

			<xen:edithint template="login_bar_form" />
		</div>
	</div>
</div>

Add more instances of the blue code to add more flags. You need to enter the languageids and paths to the flag images though. This only shows for guests because the loginbar only shows for guests.

The result:

Screen shot 2011-11-20 at 10.12.38 PM.webp
 
This is a good mod. It looks really good. I use it because i see in my stats there is a lot guests who use google translate to translate my forum. Possibly because the language chooser is at the bottom and hard to find.
Thanks.

Although, It's too bad xenforo doesn't translate the node titles.
 
Last edited:
@Jake Bunce

Hello Jake,

Beautiful work but it doesn't work on my theme.
Nothing change even when I have changed the template "footer" or "login_bar"... :/

Any reason about this? Are these codes available for XF 1.43?

Thanks.
 
Back
Top Bottom