logicopinion Posted September 21, 2007 Share Posted September 21, 2007 Hello, I am Realy Newbie In PHP and also i am new user here on phpfreaks. i was helped several times here, and now i have one more question about php - how to. i want to build simple page with several languages, but i have no idea how can i use (index.php?page=mypage&lang_id=en) such function, how can i do it (Lang_id=somelanguage) need some simple example if there is one. thanks a lot. Quote Link to comment https://forums.phpfreaks.com/topic/70206-language-how-to/ Share on other sites More sharing options...
Psycho Posted September 21, 2007 Share Posted September 21, 2007 I posted a solution for that in this thread: http://www.phpfreaks.com/forums/index.php/topic,159661.0.html Let me know if you have any questions. Quote Link to comment https://forums.phpfreaks.com/topic/70206-language-how-to/#findComment-352621 Share on other sites More sharing options...
logicopinion Posted September 21, 2007 Author Share Posted September 21, 2007 it is somethng different, i want other thing. EXACTLY: i want to know how does it change language when i switch from one language to another, where are that words stored and how are they read by php. (i am realy newbie in php) and most code in above URL u provided is bounch of "ABRA CADABRA" for me. Quote Link to comment https://forums.phpfreaks.com/topic/70206-language-how-to/#findComment-352626 Share on other sites More sharing options...
Psycho Posted September 21, 2007 Share Posted September 21, 2007 Well that code in that other post is one process that can be used to detemine which language to show the user. Once you know what language to show, then you need to come up with a process of getting the text. Basically you need to break down all text on a page into logical protions. Then create a library of the diffeerent text for the languages. Here is one example: Assume you have a page with two links "Home" and "Details". Also on the page is a welcome message stating "Hello, welcome to my site". You would then need three variables for that text. So, you could create different language files that define those variables: File: english.php <?php define ('_HOME_LINK_', 'Home'); define ('_DETAILS_LINK_', 'Details'); define ('_WELCOME_', 'Hello, welcome to my site'); ?> File: spanish.php <?php define ('_HOME_LINK_', 'Casero'); define ('_DETAILS_LINK_', 'detalles'); define ('_WELCOME_', 'Hola, recepción a mi sitio'); ?> Then in your actual page you will select the file to use based upon the selected language (using a script such as I posted in the other thread). Then use those when you build the page: <?php //Determine the language $language = determineLanguageFuntion(); //Include the appropriate language file to create the text variables include($language.'.php'); //Create the home link echo '<a href="home.php">._HOME_LINK_.</a>'; //Create the details link echo '<a href="details.php">._DETAILS_LINK_.</a>'; //Create the welcome message echo _WELCOME_; ?> Quote Link to comment https://forums.phpfreaks.com/topic/70206-language-how-to/#findComment-352656 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.