DeanWhitehouse Posted May 11, 2008 Share Posted May 11, 2008 how can i change the sites language with one PHP file do i need to use preg replace, and write down every letter in each language? Quote Link to comment https://forums.phpfreaks.com/topic/105124-language-how-to-change/ Share on other sites More sharing options...
perezf Posted May 11, 2008 Share Posted May 11, 2008 Depends on how the site is set up. Are you using database or static files? Quote Link to comment https://forums.phpfreaks.com/topic/105124-language-how-to-change/#findComment-538219 Share on other sites More sharing options...
DeanWhitehouse Posted May 11, 2008 Author Share Posted May 11, 2008 database, but i don't want it to change the stuff in the database, just to change the language on the screen, if the user wants Quote Link to comment https://forums.phpfreaks.com/topic/105124-language-how-to-change/#findComment-538382 Share on other sites More sharing options...
DeanWhitehouse Posted May 11, 2008 Author Share Posted May 11, 2008 would another way to do it, be by using define?? Quote Link to comment https://forums.phpfreaks.com/topic/105124-language-how-to-change/#findComment-538409 Share on other sites More sharing options...
BlueSkyIS Posted May 11, 2008 Share Posted May 11, 2008 i'm not quite clear on your goal. you want a CMS that automatically translates content to the selected language? or do you just need to translate static content? Quote Link to comment https://forums.phpfreaks.com/topic/105124-language-how-to-change/#findComment-538432 Share on other sites More sharing options...
DeanWhitehouse Posted May 11, 2008 Author Share Posted May 11, 2008 i just, need it so that the site is translated to another language if the viewer selects it. For example i will have a link and they can click it to change the site into there russian, and then they can click it to change it to english , i will use sessions to save this change for them, and i am going to have the link dynamic. e.g. ?lang=eng when did i mention CMS?? Quote Link to comment https://forums.phpfreaks.com/topic/105124-language-how-to-change/#findComment-538439 Share on other sites More sharing options...
BlueSkyIS Posted May 11, 2008 Share Posted May 11, 2008 i just, need it so that the site is translated to another language if the viewer selects it. For example i will have a link and they can click it to change the site into there russian, and then they can click it to change it to english , i will use sessions to save this change for them, and i am going to have the link dynamic. e.g. ?lang=eng when did i mention CMS?? "i don't want it to change the stuff in the database". i assumed you have DYNAMIC content in a database that is displayed on the site. if not, the content is STATIC. there is a major difference between translating dynamic vs. static content. Quote Link to comment https://forums.phpfreaks.com/topic/105124-language-how-to-change/#findComment-538443 Share on other sites More sharing options...
DeanWhitehouse Posted May 11, 2008 Author Share Posted May 11, 2008 well the whole page (near enough) is displayed from the database , using variables Quote Link to comment https://forums.phpfreaks.com/topic/105124-language-how-to-change/#findComment-538449 Share on other sites More sharing options...
BlueSkyIS Posted May 11, 2008 Share Posted May 11, 2008 okay, so it's what I'd call a content management system. regardless, it sounds like you will change the content and, therefore, the content must be translated whenever you do. switching between languages is the easy part. translating dynamic content is much more difficult. i can think of 2 options: manually update content for each language, or locate a translation engine API that provides the ability to do it automatically (if there is such a thing.) i don't know enough of anything but English to translate anything, but if you know multiple languages, you could translate manually. otherwise, I would look for a translation engine that allows you to send text to it for translation and then returns the translated text. if found, you could use it to translate content as it's updated, or do it on the fly as different content is accessed by visitors using different languages. Quote Link to comment https://forums.phpfreaks.com/topic/105124-language-how-to-change/#findComment-538471 Share on other sites More sharing options...
DeanWhitehouse Posted May 11, 2008 Author Share Posted May 11, 2008 so i could not just do , preg_replace(or something similar) at the start of the page, and then have it set so that if they click the language button it changes all the english alphabet to another alphabet?? Quote Link to comment https://forums.phpfreaks.com/topic/105124-language-how-to-change/#findComment-538473 Share on other sites More sharing options...
BlueSkyIS Posted May 11, 2008 Share Posted May 11, 2008 no, a switch between languages is nothing even close to that simple. Quote Link to comment https://forums.phpfreaks.com/topic/105124-language-how-to-change/#findComment-538475 Share on other sites More sharing options...
DeanWhitehouse Posted May 11, 2008 Author Share Posted May 11, 2008 ok, what about this then, two files ,one called eng.php and rus.php each file contains the variables for the page but in different languages, e.g. eng.php $pagecontent = "content"; rus.php $pagecontent = "rusian_for_content"; and on the page this is echoed, echo "$pagecontent"; i could just have an if for the require_once code yer?? Quote Link to comment https://forums.phpfreaks.com/topic/105124-language-how-to-change/#findComment-538479 Share on other sites More sharing options...
BlueSkyIS Posted May 11, 2008 Share Posted May 11, 2008 sure, but you're still left translating into russian. Quote Link to comment https://forums.phpfreaks.com/topic/105124-language-how-to-change/#findComment-538484 Share on other sites More sharing options...
DeanWhitehouse Posted May 11, 2008 Author Share Posted May 11, 2008 yer, thats fine i already have someone to do that, will this effect what is entered into the database? but , now that i think about it the database content is in english , so i will need two tables (identical) but one with russian content and one with english Quote Link to comment https://forums.phpfreaks.com/topic/105124-language-how-to-change/#findComment-538487 Share on other sites More sharing options...
DeanWhitehouse Posted May 11, 2008 Author Share Posted May 11, 2008 why can i not use preg replace? Quote Link to comment https://forums.phpfreaks.com/topic/105124-language-how-to-change/#findComment-538505 Share on other sites More sharing options...
DeanWhitehouse Posted May 11, 2008 Author Share Posted May 11, 2008 can someone tell me if this is what i need for my site?? to change language,using data from a database, as i don't understand it all. Quote Link to comment https://forums.phpfreaks.com/topic/105124-language-how-to-change/#findComment-538583 Share on other sites More sharing options...
DarkWater Posted May 11, 2008 Share Posted May 11, 2008 You won't be able to change dynamic content easily. Static content, such as menus or labels, can be changed with a language config file. But translations won't work as expected, no matter how much you want them to. Quote Link to comment https://forums.phpfreaks.com/topic/105124-language-how-to-change/#findComment-538589 Share on other sites More sharing options...
DeanWhitehouse Posted May 11, 2008 Author Share Posted May 11, 2008 so the only way would be to have all the data twice, but in different languages, I still don't see why i can't just do preg_replace and put the english alphabet in there and replace it with the russian one Quote Link to comment https://forums.phpfreaks.com/topic/105124-language-how-to-change/#findComment-538591 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.