Rommeo Posted September 23, 2009 Share Posted September 23, 2009 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§ion=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. Quote Link to comment https://forums.phpfreaks.com/topic/175200-multilanguage-links/ Share on other sites More sharing options...
ILMV Posted September 23, 2009 Share Posted September 23, 2009 I am assuming you are already using htaccess to send /a/b/c to ?1=a&2=b&3=c... you should change your htaccess file to send the language too Quote Link to comment https://forums.phpfreaks.com/topic/175200-multilanguage-links/#findComment-923396 Share on other sites More sharing options...
Rommeo Posted September 23, 2009 Author Share Posted September 23, 2009 I am assuming you are already using htaccess to send /a/b/c to ?1=a&2=b&3=c... you should change your htaccess file to send the language too But how ? can you give me an example ? I m already getting the language by mysite.com/en or mysite.com/de Quote Link to comment https://forums.phpfreaks.com/topic/175200-multilanguage-links/#findComment-923402 Share on other sites More sharing options...
ILMV Posted September 23, 2009 Share Posted September 23, 2009 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§ion=news&newsid=rainy_day Once you can tell me this I might be able to help you... Quote Link to comment https://forums.phpfreaks.com/topic/175200-multilanguage-links/#findComment-923404 Share on other sites More sharing options...
Rommeo Posted September 23, 2009 Author Share Posted September 23, 2009 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§ion=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. Quote Link to comment https://forums.phpfreaks.com/topic/175200-multilanguage-links/#findComment-923408 Share on other sites More sharing options...
Rommeo Posted September 23, 2009 Author Share Posted September 23, 2009 Can someone please help ? I m waiting for a response before I start coding Quote Link to comment https://forums.phpfreaks.com/topic/175200-multilanguage-links/#findComment-923589 Share on other sites More sharing options...
ILMV Posted September 24, 2009 Share Posted September 24, 2009 I don't think you have explained your problem well enough, are you trying to say when I am on www.mydomain.com/uk/news/hello, you want all other links on that page to include the language? Quote Link to comment https://forums.phpfreaks.com/topic/175200-multilanguage-links/#findComment-923975 Share on other sites More sharing options...
Rommeo Posted September 24, 2009 Author Share Posted September 24, 2009 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 ? Quote Link to comment https://forums.phpfreaks.com/topic/175200-multilanguage-links/#findComment-924313 Share on other sites More sharing options...
khr2003 Posted September 24, 2009 Share Posted September 24, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/175200-multilanguage-links/#findComment-924472 Share on other sites More sharing options...
Rommeo Posted September 26, 2009 Author Share Posted September 26, 2009 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§ion=news&newsid=rainy_day 1- it's through get .. 2- I use words.. No numbers. Quote Link to comment https://forums.phpfreaks.com/topic/175200-multilanguage-links/#findComment-925471 Share on other sites More sharing options...
mikesta707 Posted September 26, 2009 Share Posted September 26, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/175200-multilanguage-links/#findComment-925493 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.