473,396 Members | 1,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Multi-languages website : problem of architecture

Hi,

I am building a multi languages website. To simplify let's say that I need
to deal with news, projects, partners, all of them having some information
depending on the language (title, introduction, ...) and some not depending
on the language (date_online, date_offline, published, ...). The main point
is that I don't want to have to touch the structure of the database or to
modify my scripts if one or more languages were to be added. I came up with
something like this :

My architecture:
----------------------------------------------------------------------------
------
'news' table: with all information not depending on the language
news_id (primary key)
date_online
date_offline
published
...
'news_translations' table: with all information depending on the language
news_id (primary key)
lang (primary key)
title
introduction
...
The (news_id, lang) is linking the second table to the first one.

Same kind of structure for all other content that needs to be translated
(projects, partners, etc.).
Is there a better approach: something using only one table with all the
information that has to be translated, coming from any table (news,
projects, partners, etc.) ? or something else ?

Thank you,

BLob
Jan 12 '06 #1
3 1668
BLob schrieb:
Hi,

I am building a multi languages website. To simplify let's say that I need
to deal with news, projects, partners, all of them having some information
depending on the language (title, introduction, ...) and some not depending
on the language (date_online, date_offline, published, ...). The main point
is that I don't want to have to touch the structure of the database or to
modify my scripts if one or more languages were to be added. I came up with
something like this :

My architecture:
----------------------------------------------------------------------------
------
'news' table: with all information not depending on the language
news_id (primary key)
date_online
date_offline
published
...
'news_translations' table: with all information depending on the language
news_id (primary key)
lang (primary key)
title
introduction
...
The (news_id, lang) is linking the second table to the first one.

Same kind of structure for all other content that needs to be translated
(projects, partners, etc.).
Is there a better approach: something using only one table with all the
information that has to be translated, coming from any table (news,
projects, partners, etc.) ? or something else ?


I use a table 'strings' with the fields:
- stringnumber
- language
- string

and in the 'news' table I have all the fields necessary, but all
multilanguage fields contain the stringnumber instead of the text itself.

I could not say if this approach was better than yours, it is just
different. The advantage of it is that you have access to any string
regardless of the information about what object it belongs to. This
makes it easy to make fallbacks for the case some info is not present in
the desired language, somehow like

function get_string($str_nr, $lang, $main_lang) {
$string = [get string for $lang here];
if ($string == "" || $string == NULL) {
if ($lang != $main_lang)
return get_string($str_nr, $main_lang, $min_lang);
else
return false
}
else return $string;
}

HTH
Markus
Jan 12 '06 #2
I use a table 'strings' with the fields:
- stringnumber
- language
- string
I thought about this structure, but I don't know if it is better or worse
than the one I proposed in my first post. 'string' has to be a 'text' field
in the database in order to hold both data from what would otherwise be
varchar and text. Isn't this a problem ? (I don't know).
and in the 'news' table I have all the fields necessary, but all
multilanguage fields contain the stringnumber instead of the text itself.
OK.
I could not say if this approach was better than yours, it is just
different. The advantage of it is that you have access to any string
regardless of the information about what object it belongs to. This
makes it easy to make fallbacks for the case some info is not present in
the desired language, somehow like


Yes, it makes it easier for the 'translation' process. But on the other hand
I guess it makes it more complicated to search within information (search
engine), as you don't know what type of data you have without making links
to other tables. That's why I chose the other approach, but maybe I am wrong
and there is a pretty work around do do efficient searches with the
structure you described. What do you think ?

BLob
Jan 13 '06 #3
BLob schrieb:
I use a table 'strings' with the fields:
- stringnumber
- language
- string
I thought about this structure, but I don't know if it is better or worse
than the one I proposed in my first post. 'string' has to be a 'text' field
in the database in order to hold both data from what would otherwise be
varchar and text. Isn't this a problem ? (I don't know).


According to the MySQL manual a "text" field requires as much disk space
as the size of the text it holds (plus 1 byte). That's why I think it is
not a problem to use the "text" data type also for very short strings; I
actually don't understand the reason why most developers use varchar
fields with specified string lengths. But maybe I am wrong here.
Yes, it makes it easier for the 'translation' process. But on the other hand
I guess it makes it more complicated to search within information (search
engine), as you don't know what type of data you have without making links
to other tables. That's why I chose the other approach, but maybe I am wrong
and there is a pretty work around do do efficient searches with the
structure you described. What do you think ?


I built a special search index table where I store all information for
every object that has to be searchable centrally. This is extra
programming work, but I see several advantages in it:

- As the contents of a page is centralized in one field you can use the
MySQL fulltext search and take advantage of its boolean and ranking
capabilities
- When storing the contents to the search index you can pre-process it,
for example remove punctuation and convert accented characters and
whatever, which can improve the performance and quality of the search
process
- If you need to add another type of objects - say "products" - you
don't have to edit your search process, but just add the appropriate
"store to search index" method to the "products" administration.

--
Markus
Jan 13 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

37
by: ajikoe | last post by:
Hello, Is anyone has experiance in running python code to run multi thread parallel in multi processor. Is it possible ? Can python manage which cpu shoud do every thread? Sincerely Yours,...
4
by: Frank Jona | last post by:
Intellisense with C# and a multi-file assembly is not working. With VB.NET it is working. Is there a fix availible? We're using VisualStudio 2003 Regards Frank
12
by: * ProteanThread * | last post by:
but depends upon the clique: ...
0
by: frankenberry | last post by:
I have multi-page tiff files. I need to extract individual frames from the multi-page tiffs and save them as single-page tiffs. 95% of the time I receive multi-page tiffs containing 1 or more black...
6
by: Joe | last post by:
I have 2 multi-list boxes, 1 displays course categories based on a table called CATEGORIES. This table has 2 fields CATEGORY_ID, CATEGORY_NAME The other multi-list box displays courses based on...
4
by: mimmo | last post by:
Hi! I should convert the accented letters of a string in the correspondent letters not accented. But when I compile with -Wall it give me: warning: multi-character character constant Do the...
5
by: Shane Story | last post by:
I can seem to get the dimensions of a frame in a multiframe tiff. After selecting activeframe, the Width/Height is still really much larger than the page's actual dimensions. When I split a...
5
by: dkelly925 | last post by:
Is there a way to add an If Statement to the following code so if data in a field equals "x" it will launch one report and if it equals "y" it would open another report. Anyone know how to modify...
17
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, Wide character and multi-byte character are two popular encoding schemes on Windows. And wide character is using unicode encoding scheme. But each time I feel confused when...
1
by: mknoll217 | last post by:
I am recieving this error from my code: The multi-part identifier "PAR.UniqueID" could not be bound. The multi-part identifier "Salary.UniqueID" could not be bound. The multi-part identifier...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.