We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

switching language question

Development and Programming

florian's avatar
florian
395 posts
15 years ago
florian's avatar florian

I followed the alternative method outlined in the wiki to build a bilingual web site. Everything seems to be working ok, but I am having problems switching between the languages.

I am using the recommended JS method to switch.

< script type="text/JavaScript">
<!--
function switchLanguage(lang) {
    u = location.href.split('/');
    u[3] = lang;
    location.href = u.join('/');
}
//-->
< /script>
<a href="/en/" title="English">EN</a> | 
<a href="/fr/" title="Français">FR</a>

{I deleted the o from nclick to make sure that the code would disply in the forum}

When I click on the link trying to switch, the /index.php does not get added to my url. I tried adding the index.php in the line ‘switchLanguage(‘fr/index.php’} which works on the first click but when i switch language again, the index.php gets appended behind my url again.

I dont know JS so I was hoping that someone could let me know what to add to the code to make it switch between languages and also use the index.php.

       
florian's avatar
florian
395 posts
15 years ago
florian's avatar florian

I switched to the php method which is also outlined on the wiki and this looks like it is working better.

I had to change the php code from the wiki with something that I found on the forums to make it work. If anybody wants the code, just post here.

       
phoebe_reed's avatar
phoebe_reed
82 posts
15 years ago
phoebe_reed's avatar phoebe_reed

Hi,

I’m making a multi language site right now…. I just tried the intial way, it’s worrking OK.

Can you tell me what you like better about the php method? What trouble were you running into w/ the other one? Was it about switching langauges?

Trying to avoid trouble down the line w/ the global variable/include method that I’ve chosen….

Thanks,

Phoebe

       
florian's avatar
florian
395 posts
15 years ago
florian's avatar florian

the js method didnt work right for me as far as switching between the languages goes. I used the php method before with some code that I found on the forums some time ago. I am using that code rather than the code listed in the wiki. Not sure what it does different but it works well for me.

the one issue I have is with the breadcrumb navigation. It’s really difficult to build a working breadcrumb with bilingual site as I cant really use url segments (ex segment_1 etc) to display the breadcrumbs.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.