I working on a website and have a mysql-table called ‘items’, like:
item_id | item
(The second column is just for identify the item_id.)
In a language1.php I store a array with the item_id and the name of the item itself in language1, like:
$items = array(
1 -> 'Apple',
2 -> 'Orange',
...
);
Depending on the language of the user, the correct language-file is included.
There should be an autocomplete-input-box for the items-array (< 1000 items/ array). I guess, its not a good solution, to search the array in the language1.php with php (“search_array” or some function like this), but i think there is no way to maintain this system and search by mysql, isn’t it?
How are you store different languages for websites and make them searchable?
Is it necessary to store all languages in a specific column in mysql?
I would probably add an
items_localizationtable with columns likethat has a foreign key to
item_id, and either a compound primary key onitem_id, locale, or an autoincrement id field and a unique index onitem_id, locale. Some folks like working with single-column, autoincrement primary keys because of the framework they are working with, so if this describes you, use the latter solution.Alternatively if you wanted a wider localization solution you could just have a
localizationtable with columns likethat can store any sort of localization. Then you items_localization table could just be a many-many join table with columns like
You could just do a join query to get the localization you are looking for. For using the first proposed table structure:
Where you substitue your values for current locale and the autocomplete search phrase for the
?‘s.