Best way to translate database driven content

I struggled with this for a while. One of my CMS is ready to expand with the help of the translation module. I thought of different methods, but still have not figured out what is the best.

Basically, I have a CMS that uses a template system to analyze all the data from the database to the screen. I went so far as to “separate” my templates in different folders, in order to be able to translate things that are “static”, like images with text, footers, etc.

However, there are many modules (pages, news, products) that have several fields that require translation of a database-driven method. I started with the Languages ​​table, which describes the languages ​​(id, iso_code, name). This, as far as I came ... because there were several projects that needed to be done, I still do not spend more time on this issue.

My first thought (“quick fix”) was to add some fields inside the tables (for example, “title_nl”, “title_en”), but this actually makes the database more crowded than necessary, in my opinion.

My second thought was to create a table, for example, "news_translations". Which contains the language code iso, news_id, fields that require translation. Obviously, news_id associates the translation with the original, and the iso code language is used to get the correct language from the database. Then, in my interface code, I would first check if the default language is selected (=> select "news" from the table) or the translation table (=> check in translations). If the second case does not return any results, the message “Sorry, translation is not available” is displayed and the default value (or an error message that is most suitable for the client) is displayed.

. (www.domain.com/pagename/ www.domain.com/news/1-news-item-here.html). , "" URL SEF . , 1 ( )... , , , .

, , 3, . ! , :

  • CMS
  • (, )
  • /newsitem/product
  • : URL SEF

, 3 ... :

  • (, , , 2 'translation_to' ( PrimaryKey) 'translation_is' ( ISO) - .. ( .. , , , ?)

  • , , , , . / / ( URL SEF... SEF , , , ).

?: -)

, !

+5
2

, . , , , " CONTENT_MULTI_LANG" " SITE_LOCALES".

, , . , " Content_LoadStandard" " Content_LoadMultiLang". , .

if ($this->site_locale == 'standard'){
    $contentLoader = new Content_LoadStandard();
} else {
    $contentLoader = new Content_LoadMultiLang($this->site_locale);
}

$content->blah($cheese);

CONTENT_MULTI_LANG CMS, () , .

// PSEUDO SQL
  CREATE TABLE `LOCALE` (
      `id` int(11), 
      `locale` varchar(16),    // name of locale (language)
      ...                // any other fields
)

  CREATE TABLE `CONTENT_MULTI_LANG` (
      `id` int(11), 
      `pcid` int(11),    // parent content id
      `lid` medint(),    // locale id
      `content` {$type}, // whatever type you use (varchar, text, bin, etc)
      ...                // any other fields
)

Content_LoadMultiLang .

. , , , , .

0

, Drupal, - , , . . , , .

, , .

0

All Articles