PHP - Website Localization
Similar TutorialsHello there, I have a CMS which I've trying to create localization for. The idea is in the admin area you check a radio button and it changes the language of the entire admin interface. There is a mysql database with a table called nb_settings that has a column called lang. Up to this point I've gotten it to work but am having problems adding additional languages. The localization files have names like lang.nl.php,lang.en.php and so on.. The original code that works is this in a file called settings.php: ... <?php if($row['lang'] == nl) { echo '<input name="lang" type="radio" value="nl" checked="checked" /> '.($_CONSTANTS['NL']).' <input name="lang" type="radio" value="en" /> '.($_CONSTANTS['EN']).' <input name="lang" type="radio" value="de" /> '.($_CONSTANTS['DE']).''; } elseif($row['lang'] == en) { echo '<input name="lang" type="radio" value="nl" /> '.($_CONSTANTS['NL']).' <input name="lang" type="radio" value="en" checked="checked" /> '.($_CONSTANTS['EN']).' <input name="lang" type="radio" value="de" /> '.($_CONSTANTS['DE']).''; } elseif($row['lang'] == de) { echo '<input name="lang" type="radio" value="nl" /> '.($_CONSTANTS['NL']).' <input name="lang" type="radio" value="en" /> '.($_CONSTANTS['EN']).' <input name="lang" type="radio" value="de" checked="checked" /> '.($_CONSTANTS['DE']).''; } ?> ... Another file called common.php is used as well and has the following: <?php session_start(); header('Cache-control: private'); // IE 6 FIX $sql = "SELECT * FROM nb_settings"; $query = mysql_query($sql); $row = mysql_fetch_assoc($query); if($row['lang'] == nl) { include('languages/lang.nl.php'); } elseif($row['lang'] == en) { include('languages/lang.en.php'); } elseif($row['lang'] == de) { include('languages/lang.de.php'); } ?> But I am havng trouble adding more languages and expanding this. There is a folder called languages into which I put the individual localization files. Just adding similar lines of code as shown below in both common and settings files doesn't do it: ie: 1)modifying settings.php to become: <?php if($row['lang'] == nl) { echo '<input name="lang" type="radio" value="nl" checked="checked" /> '.($_CONSTANTS['NL']).' <input name="lang" type="radio" value="en" /> '.($_CONSTANTS['EN']).' <input name="lang" type="radio" value="de" /> '.($_CONSTANTS['DE']).' <input name="lang" type="radio" value="fra" /> '.($_CONSTANTS['FRA']).''; } elseif($row['lang'] == en) { echo '<input name="lang" type="radio" value="nl" /> '.($_CONSTANTS['NL']).' <input name="lang" type="radio" value="en" checked="checked" /> '.($_CONSTANTS['EN']).' <input name="lang" type="radio" value="de" /> '.($_CONSTANTS['DE']).' <input name="lang" type="radio" value="fra" /> '.($_CONSTANTS['FRA']).''; } elseif($row['lang'] == de) { echo '<input name="lang" type="radio" value="nl" /> '.($_CONSTANTS['NL']).' <input name="lang" type="radio" value="en" /> '.($_CONSTANTS['EN']).' <input name="lang" type="radio" value="de" checked="checked" /> '.($_CONSTANTS['DE']).' <input name="lang" type="radio" value="fra" /> '.($_CONSTANTS['FRA']).''; } elseif($row['lang'] == fra) { echo '<input name="lang" type="radio" value="nl" /> '.($_CONSTANTS['NL']).' <input name="lang" type="radio" value="en" /> '.($_CONSTANTS['EN']).' <input name="lang" type="radio" value="de" /> '.($_CONSTANTS['DE']).' <input name="lang" type="radio" value="fra" checked="checked" /> '.($_CONSTANTS['FRA']).''; } ?> 2)and adding in common.php: elseif($row['lang'] == fra) { include('languages/lang.fra.php'); } Both don't work. The php is obviously not correctly parse and the syntax may have issues. Can anyone help me out with how to add additional languages? I'm trying to make a League of Legends (a video game) community website, both as a personal project and for practice. Now the game has a lot of champions, each of whom have 5 unique abilities. Now, I thought about manually inputting all the details about each champion into a MySQL database, but that would long and tedious, and I don't really have the time for it now. Also, the game patches very oftern (like, once every 2 weeks) which changes many of the stats, etc. of the champion, and it is not possible for me to keep manually updating these every time there is a patch. Fortunately, there is a League of Legends Wiki which has all the data I need in their specific champion pages, which they keep updated per patch. So I was wondering if there was any way to get the data from the divs in the wiki, and have it display on my site. What I want to do in my website is that whenever someone types a champion's name (in a post or whatever), I want it to display a hover-over dialog with some of the champions details. And a lot of other features such as that. In plain English I need a way to : > Tell PHP to go to the wiki's source code on a specific page > Find a specific div container > Get X data from there > Pass X data into a function to display the hover-over I think this way, I would not have to maintain a database as I can leech off the wiki's data. I have not coded anything like this before, so I would like a few pointers as to how to achieve this. Any help will be appreciated! I tried searching on google but couldn't find any relevant information, please redirect me to relevant source or help me with the code. I want to pass a domain name in text field which will be scanned and then the script will display entire site map. Not external links or links on a page. Sorry it is not easy for me to explain. Eg. if i pass abc.com Script will display abc.com/12/adn.php abc.com/asd/asd/ etc Whatever their url format is. All the links on that domain. hello My database is in a same server with seperate domain name , then I want to insert from website1 mysql data on website2 mysql data. can anyone help me? Is it possible to download files from a website to my online websites root directory? reason I'm asking is because I have been downloading large video files to my computer which take about 20 minutes!! Then I use FTP to upload them to my site but it takes about 2-3 hours per video!! I was looking for a faster way! All help would be great! My code on website is not validate on W3 Validator.
<?xml version="1.0" encoding="ISO-8859-1"?> This would be an example of a page I'm referring to: http://www.curse.com...other-downloads
I want to get the file name and compare it to another name (to see if they are the same or not). I have no idea how to access that page from my website. I'm guessing PHP would be best although if you don't think so tell me what you think would be better (I was thinking javascript but don't think that's cross-site compatible). Is there a PHP function to get the value of the href which is in this case (as of this posting) "Railcraft 9.4.0.0".
I used inspect element to see the code of the page but have no idea if this is possible or if I'm even going about this the right way. The code would have to work on this entire website (all pages have the smae layout as this one though! Any help is greatly appreciated!
Hello everybody!
I have been asked by a customer to develop a GTP website (Get To Pay, those websites where people earn money from clicking on ads). I managed to write the backend, signup and login but I am unsure how the ads part, with built-in user-tracking works and fallback link works.
I would really appreciate any kind of help.
Thank you very much!
P.S. For the user tracking I was thinking of sessions with matching ip and user agents together with an anti-proxy online service (e.g. MaxMind, Proxystop, ...)
Hello everyone and thank you for reading this.
My goal: Build a site like sportingnewschicago.com
What it does? It has different sectiions of different teams. Then it displays the tittle of the news and makes them be able to click on to go to the news site. The site some how checks a list of sites and post them on their respected section. But only ones that have not already been listed.
What i want to do? Well i want to try to learn how to do this. Is this something i can make with the help of members here? It would only have index.php and thats it.
Please let me know if anyone would be interested in teaching me as i do it. If not i would understand. Thank you.
Hi, I haven't used any php for a while, but i am making a website, and i need some advice on how to do the following: I want the website to change an image once every 24 hours, the image will revert back to the original image after 2 minutes. Does anyone have an idea how I could start doing this? I am working on a website and I am at a standstill. I would rather speak to someone one on one but its been very difficult to find someone that could help. I have the scripts that I want but when I add the scripts to the mainpage everything stops working. I really don't want to go to wordpress because I am almost done with this one. Thanks.
Hi there Can anyone please help me. I am trying to get my website working but i am struggling big time with the php. The things i need to do are not to complicated however my lack of skill with php is making me struggle. I need help in making the php work on my website. Can anyone help please. (Please note it is not a commercial or business website.) Anyone who can help please contact me. Thanks How would I show the PHP code on the website page? I'm not sure if this should be under PHP or HTML or what, but, like on the forums where you see the <?php echo 'sdfjksdf'; ?> etc. How do I make it so I can write PHP on the website? Hi, I have a requirement of making the single website for different locations, customer running a enterprise, and he wants me to show corresponding items for corresponding locations(nearly around 30 locations) I am very confused how to make this(making separate sub domains for separate location), pls help me regarding this. Thanks, hi, how can i make a autoupdate currency table currency value CHF USD EURO KD (Kuwaiti Dinars) 1 Converted Value Converted Value Converted Value when the page loads, it will convert the currency and the value of CHF, USD and EURO are real time please kindly help tia hi, how can i make a autoupdate currency table currency value CHF USD EURO KD (Kuwaiti Dinars) 1 Converted Value Converted Value Converted Value when the page loads, it will convert the currency and the value of CHF, USD and EURO are real time please kindly help tia Hello I want get content of website and insert it to my website This website have 2000 page and each one have 10 post. I developed some code but I've some problem: Code: [Select] for($i=1;$i<=3;$i++) //$i is website pages { //download main page $maincatst = file_get_contents($catlink.$i); //$catlink select link of category of website //number of post in main page for ($j=1;$j<=10;$j++) { $linkposttmp = TextBetween('before link','after link',$maincatst) ; $link = TextBetween('before link','after link>',$linkposttmp); // download content of each link $main_post_str = file_get_contents($link); My problem is when run this file only download first link of each mainpage. anyone can help me? Hi, I'm working on a design for a new website of mine, but I'm kind of stuck on how to fit in the php aspect of it. There's going to be a lot of different pages and different things you're able to do on each page. I guess I'm trying to figure out how to take my design for the website and break it up into a template system. I don't know anything about using templates though. The last time I tried to make a template I just winged it and it turned out really bad with a lot of confusing code slapped together with html all around it. Right now all I have is a single page made (front page) and I want to use this as my base template. Could anyone explain to me the proper way to go about this, or perhaps link me to a tutorial covering this. Thanks, Hi how can I have the same website in a different language? So for the visitor, they would click on the appropriate flag and the site would then be displayed in their language. Hi, I am wondering if it is possible to monitor how long someone is on a website for and to limit them for example: 30 minutes. An example of this would be one of those Tv Online websites which allow you to only watch 30 minutes of video time. If you try refreshing the page it will still not allow you. My question is, Is it an ip check which does this? Sorry If it such a broad topic. Nick |