Jump to content

Recommended Posts

Hi everyone

 

I am just doing some research into mysql and the languages it supports and thought it would be good to ask for some advice on this forum.

 

I am planning on building a site in the near future and I want to build it in such a way that I can easily add the choice to read the site in other languages.

 

After the research I have done, the plan is to have a product_tbl where all the common product fields will be kept. i.e. image, prod_id, postage_id etc

 

then to have a separate table for each language which links to the product table, these separate language tables will keep all the text for each product, so prod_name, prod_desc.

so for example: uktext_tbl with fields: uktext_id, prod_id, prod_name, prod_desc and the same for other languages.

 

the reason i have chosen to keep separate tables for each language is because from what i understand, you need to set each table upon creation to accept certain characters. so i cannot just have a separate field in the product table for the each language i.e. prod_nameuk, prod_namegr, prod_namede, prod_descuk, prod_descgr, prod_descde. is that correct?

 

I also wanted to keep everything on one site, i dont want to have a different site for each language and so i would need to change the charset within the html file depending on the language chosen by the visitor in order for the file to support the language being retrieved from the database.

 

So my question is, does this sound like a good way of doing this? is there an easier/better way of working this?

 

any suggestions on how to implement different languages into one website would be great. this is how i have figured it out in my head and how it would work best for what i want but obviously it would be great to have opinions from others more experienced in this type of website.

 

thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/203502-mysql-and-languages/
Share on other sites

You can use utf8 encoding, which covers special characters from majority of world's languages. As far as collation is concerned, you can specify which one to use in a query. This way you should be able to have just one table.

 

 

table l18n

langID, sentenceID, sentence

---------------------------------

en, 1, Sentence in english

zh, 1, 一句中文

jp, 1, 和文

Link to comment
https://forums.phpfreaks.com/topic/203502-mysql-and-languages/#findComment-1067382
Share on other sites

Hi Mchl

 

thanks for your reply. im not sure what you mean. do you mean i can specify the tables to have utf8 encoding and then they will support most languages?

 

and then for table structure i can have the following?

 

product_tbl

prod_id, prod_img, prod_price etc etc

 

 

prod_lang_tbl

prod_land_id, prod_id, lang_id, prod_name, prod_desc

 

and have all the languages for each product in my prod_lang table?

Link to comment
https://forums.phpfreaks.com/topic/203502-mysql-and-languages/#findComment-1067570
Share on other sites

Yes you can.

This forum uses utf8 encoding to store posts. As you can see in my post above it allows for storing latin, chinese and japanese characters. There are several more alphabets supported.

This will allow you to keep your database structure better organised.

Link to comment
https://forums.phpfreaks.com/topic/203502-mysql-and-languages/#findComment-1067575
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.