1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Language Switch / Phrase ?

Discussion in 'XenForo Questions and Support' started by erich37, Jan 26, 2011.

  1. erich37

    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.
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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.
     
    rafass, Robert F Schmitz and erich37 like this.
  3. erich37

    erich37 Well-Known Member

    you are great Jake !

    the guys should hire you as Moderator over here...............
     
  4. erich37

    erich37 Well-Known Member

    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.
     
  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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>
    
     
    erich37 likes this.
  6. erich37

    erich37 Well-Known Member

    thanks Jake for your kind help!

    works like a charm!
     
  7. erich37

    erich37 Well-Known Member

    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!
     
  8. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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.png

    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>
    
     
    erich37 likes this.
  9. erich37

    erich37 Well-Known Member

    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 ?
     
  10. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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.
     
    erich37 likes this.
  11. erich37

    erich37 Well-Known Member

    perfect, thanks!
    works like a charm!
     
  12. erich37

    erich37 Well-Known Member

    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?
     
  13. Bellinis

    Bellinis Active Member

    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!
     

    Attached Files:

    erich37, Jake Bunce and Andrej like this.
  14. Andrej

    Andrej Well-Known Member

    Would really like a setup like this! If anyone figures out how to do this, please share your changes here.
     
  15. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Admin CP -> Appearance -> Templates -> login_bar

    Add the red code:

    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.png
     
    51463, erich37, Andrej and 1 other person like this.
  16. erich37

    erich37 Well-Known Member

    yeah, but it is not possible to have the Forum-Nodes switch to another language....
     
  17. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    It looks good for me. Did you fix it?

    Screen shot 2011-11-28 at 4.47.20 PM.png
     
  18. Bellinis

    Bellinis Active Member

    Yup, fixed it :D Thanks.
     
  19. 51463

    51463 Well-Known Member

    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: Jul 28, 2014
  20. Betclever

    Betclever Active Member

    @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.
     

Share This Page