Jump to content

Recommended Posts

I  m building a multi-language website. My original links are like :

mysite.com/en/news/rainy_day

 

it goes to :

mysite.com/index.php?lang=en&section=news&newsid=rainy_day

 

My problem is;

When you enter the website and choose the language "german", then everything in the website should be in german even the address of the news-link. So for example, when you click the news ;

 

if the website is german mode : it should go to;

mysite.com/de/nachrichten    ( for specific news : mysite.com/de/nachrichten/regenreich_tag )

 

if the website is english mode : it should go to;

mysite.com/en/news          ( for specific news : mysite.com/en/news/rainy_day )

 

So I ll have 2 kinds of addresses. How can I do this ?

My solution is, I ll have a links file ( like the language.php file ) and I ll include it also when a language is choosen. But I m wondering if there is any other way ? or easy way to do this ? and I don't know if there will be unexpected results of doing this.

 

I need your ideas.

Link to comment
https://forums.phpfreaks.com/topic/175200-multilanguage-links/
Share on other sites

Right, answer me this question.

 

How are you converting this link:

mysite.com/en/news/rainy_day

 

To this:

mysite.com/index.php?lang=en&section=news&newsid=rainy_day

 

 

Once you can tell me this I might be able to help you...

 

by .htaccess file. -mod_rewrite.

I hope you get my problem is changing the "address-set" ( all addresses in links ) in order to chosen language. I have no problem printing anything in different language.

 

Link to comment
https://forums.phpfreaks.com/topic/175200-multilanguage-links/#findComment-923408
Share on other sites

OK, let me explain;

 

lets say you entered the page and there are buttons.

news-

daily -

writers

 

If the page is in english mode buttons' addresses will be this :

news - www.mysite.com/en/news

daily - www.mysite.com/en/daily

writers - www.mysite.com/en/writers

 

but if the page is in german mode buttons' address will be this :

Nachrichten - <a href="www.mysite.com/de/nachrichten">Nachrichten</a>

Diurnally - www.mysite.com/de/diurnally

Schreiberinnen - www.mysite.com/de/screiberinnen

 

When you load the page in any language, The page will be in selected language ALSO I want the addresses ( where it's bold above:www.mysite.com/de/nachrichten ) to be changed. So my question is, how can I change the addresses for a specific language ? should I include them from a file ?

 

Link to comment
https://forums.phpfreaks.com/topic/175200-multilanguage-links/#findComment-924313
Share on other sites

It is a bit hard to answer your questions knowing little about your website design.

First how do does your website knows whether it is in an "english mode" or "gernman mode"? Is it through "$_GET", "$_COOKIES", "$_SESSIONS" or anything else?

Second: how do get the id in the url for the news? Is it through number or words? I noticed this bit in the url "&newsid=rainy_day" is not that supposed to be "&newsid=105" or any other number?

 

In anyway once you figure out the answers for both of these questions you can make a simple if statement or switch condition like this:

if($_GET['mode'] == 'english')
{
$link = "mysite.com/de/nachrichten/rainy_day";
}elseif($_GET['mode'] == 'german'){
$link ="mysite.com/de/nachrichten/regenreich_tag";
}

or something like that

Link to comment
https://forums.phpfreaks.com/topic/175200-multilanguage-links/#findComment-924472
Share on other sites

It is a bit hard to answer your questions knowing little about your website design.

First how do does your website knows whether it is in an "english mode" or "gernman mode"? Is it through "$_GET", "$_COOKIES", "$_SESSIONS" or anything else?

Second: how do get the id in the url for the news? Is it through number or words? I noticed this bit in the url "&newsid=rainy_day" is not that supposed to be "&newsid=105" or any other number?

Everything is clear in my first post :

mysite.com/index.php?lang=en&section=news&newsid=rainy_day

1- it's through get ..

2- I use words.. No numbers.

Link to comment
https://forums.phpfreaks.com/topic/175200-multilanguage-links/#findComment-925471
Share on other sites

I would suggest doing what you did in the first post. Wherever you put your links in your page,  just have a simple if (or possibly a switch statement if you are going to have many languages) statement that chooses which link page to include. That way you can easily just add more links and more languages without having to change a lot of code. if all the links for each language are going to be different anyways, there isn't much else PHP can do that is as simple

Link to comment
https://forums.phpfreaks.com/topic/175200-multilanguage-links/#findComment-925493
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.