How to change the language of a website in php - php

I've been searching over the internet about this problem a week ago but I could not get the exact answer. I went to my friends who are also web developers but they could not give me the right answer.
I just want to know how to change the language of my website to the desired language by the user. In my case, I used drop down button and if the user change the language, let's say for example, from English to Chinese vv, the website's text will change to automatically chinese. These, texts came from the database.
Does anybody know about this? Need much help. thanks

You need load different text from a database according to users selection (usually stored as session data). For very small list such as menu text, you can store them in your script.

If you just want to change front end text and has no functionality of storing that in database, then i will recommend you to use google translate tool for the websites.
Refer this link for the plugin: https://translate.google.com/manager/website/
I hope this helps you.

You can use i18n to create a multilingual website. To do this follow the link
http://www.onlinetutz.com/create-a-multilingual-website-using-php-with-i18n/
it helps you!!

Related

Creating a Website for a Shop with Multiple Locations

I have a quick question. We are building a site for a shop that has 12 different locations. So there is a Portal page, and then the 12 locations pages.
The design is the same for each location, just different text and rotator images. What I did before for another site was just used PHP and a Database, and had a site.php?shop=city&page=about and just did some rewrites so it would be /city/about/ which works good.
That way when I need to make an overall design change, it will apply to all locations instead of duplicating the site 12 times and if I catch one thing, I need to do it on all 12 sites.
One thing that we don't like about that is if someone in the team needs to make a change to the text, they would need to go in the MySQL Database to make the content changes which they are unfamiliar with. I could create a basic CMS but I would like some suggestions on what else I can do to make this easy on everyone.
If I need to create one of the sites and duplicate it 11 times, I could do that but was just seeing if there were any easier ways you guys know of, where it would still be easy for people to update the content with FTP.
Thanks!
From my point of view you have a few options:
Build a basic update form with a basic WYSIWYG editor, more or less a very basic CMS
Use an include file structure then the user only needs to edit a text file for example for changes to reflect on the site, note they may need to know basic HTML and FTP is likely to be required
Give access to phpMyAdmin, again note they may need to know a little HTML (edit: as already suggested I just noticed, sorry need to load answers while I'm typing)
Install an out of the box CMS in the 'locations' or 'stores' directory and only have it used on these pages
Personally I would just build a simple CMS in this case... then again I have built around 15 CMS' in the past so it only takes me about an hour to code something like this.
Hope that helps you.
It is not ftp, but if you gave them access to phpmyadmin, with a login that only has access to that table then they could edit the data.

how to make a mutlilangual web site by translating the text with javascript

I am going to make my web application in 3 different languages, I would like to know if there is a better way to translate the text with javascript, is there any script that will scan the pages for predefined keywords and then replace them with other keywords in another language
example:
There is a menu: home,about,contact. now the menu is generated with PHP, but if the user clicks on another language, I will be storing it in session, then the javascript will detect that language and replace that menu with home,about,contact but in the chosen language.
After reading this text that I wrote it sounded to like noobish question! :) But I need this right now and I am not really good with javascript. anyway thank you for your time and help.
I think what you are looking for is locale or localization support .
Spring ( java) has this Example here
That should give you some ideas.
A PHP example can be found here PHP example
I think what you are looking for can be found here:
http://translate.google.com/translate_tools
Just use that code, copy and paste, and you will be able to translate all the pages.

Codeigniter Multi-lingual language identifier

I am trying to implement CI uri identifier plugin - http://codeigniter.com/wiki/URI_Language_Identifier/
I set the code on a base codeignitor setup. The “ingore_lang” is set to “en”. I am using “alt_site_url” to generate alternative language links.
Now with english it is working all good, links are fine.
But when I click on any other language, the next set of alternate language urls is not replacing the abbr to the present link. For eg. if Spanish is selected, on the new page the link to italian language becomes:
mysite/es/it
I have also observed that the alternate language links never show “english” in the list. I assume they are still taking english as current language.
Please help, am I missing something? I applied the code to all specified files as guided.
Thanks
You should remove 'en' from the lang_ignore var, that should add english to alt languages list. Not sure about the es/it part...
Could you post the code of the implementation you used? I'm also using this in my application and it works fine for me.

crawling different languages of a page which is depending on sessions in php

Hi Friends
I am sorry if i am irritating with problem.
I have a website with two languages in every page.
I mean that,the default language is swedish and if you press on eng flag it will change the session and will display in english and the whole site will run with english.
my problem is the google(search engine) is not crawling my english content.
can you suggest me some solution.
Thanks in advance.
Your site should have URLs like /en/somthing.html & /fr/somthing.html if you are considering google to index your pages.
If you enable non-cookie session id's in PHP, you will enable crawlers to follow links containing session id's as GET parameters, as well as language information. This will effectively allow crawlers to index pages in different languages.
I am not 100% sure whether Google will ignore default ?PHPSESSID=... parameter, but you may as well give it a try without altering a line of your code, but merely changing php configuration.
Parameters that control this behavior are session.use_trans_sid and session.use_only_cookies.

Where do I start with a changing homepage?

I'm building a website with a homepage that has a different article everyday. I know how to change it using html, but that requires daily maintenance. Is there anyway I can change a picture and text daily without changing code everyday? I'd also like to be able to see the previous days' article by using an 'older' button or something.
I'm not asking for the whole code by the way, just for someone to point me in the right direction. Thank you
It sounds like you're looking for WordPress.
How about a Content Management System like Joomla? If you're just doing static content updates, that may work well for you
You probably need to utilize CMS to match your needs.
You Can Make this by adding the article and images into the database. or images in the folder.
You can google for better article for doing this.or you can use cms e.g. joomla , wordpress.
Thanks

Categories