Language in database?

I have learned some things about PHP and I am still
learning. My question is I have seen how a MySQL database is good for retrieving
the data that matches things like a user’s id. I am constructing a web site
that I want to have a dropdown at the top to switch the language. I am
imagining that the content could be just like accessing the data where it
matches an ID, but in this case would match something like “EN” or “SP” for the
language choice. Would it be advisable to have the content (text) of each language
in the MySQL database? Are there any known recommended ways to do this?

What content?

Instructions? General page labels and such? Some content you create?

The entire web site. For example the web site is now all in english, I want a drop-down to change the whole site to Spanish. Thanks

Without seeing your actual site or the data model, it is hard to give a completely accurate answer, but “Yes”, you certainly could have all content for your site in several languages in your database.

It might make sense to break out each language-version of the content into a one-to-many or many-to-many relationship.

That way instead of having an article that is 10,000 characters long being doubled or tripled in the given record, you have one Article record for English, one for German, and one for Spanish if you follow me?

Yes, just use utf8_general_ci for all your tables.

Thanks guys, this is a very helpful start. I do follow what you are saying, don’t have each entry in database, instead have an entry like Spanish with all the content that relates. Or it could even point to a link. I am going to research this utf8_general_ci. Great!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.