Pages

Pages

Previous: Translating Static Text Up to Contents Next: Translating Field Labels and Descriptions

Internationalization with Xataface

Jump:

Xataface includes the ability to internationalize your applications. Note, that multilingualization of content requires the query translation extension that is not available as open-source. Contact info at weblite.ca for more information about

Translating Database data

Manage multiple translations of database records transparently.

So far we have looked at methods of internationalizing static text in your application.  What if we also need to internationalize dynamic data?  Let's consider an example to demonstrate why we might want to do this.

Example: French translation for Faculty of Widgetry site

In the familiar Faculty of Widgetry example, we have a number of course descriptions that should be internationalized.  The Course table has the following SQL definition:

TABLE `Course` (
`CourseID` int(11) NOT NULL auto_increment,
`CourseTitle` varchar(64) NOT NULL default '',
`CourseDescription` text NOT NULL,
`HTMLOutline` text NOT NULL,
`PDFOutline` longblob NOT NULL,
`PDFOutline_mimetype` varchar(64) default NULL,
`Subject` varchar(128) NOT NULL default '',
`CourseNumber` varchar(10) NOT NULL default '',
`Credits` int(5) NOT NULL default '0',
`Starttime` time NOT NULL default '00:00:00',
`LastModified` timestamp NOT NULL default CURRENT_TIMESTAMP,
PRIMARY KEY (`CourseID`)
)

Some of the columns in this table need to be internationalized (e.g. HTMLOutline), while others will remain the same across translations (e.g. CourseNumber, Credits, Starttime, etc...).  We are going to make French and English translations for this table so we will start by adding "translation tables" for the Course table as follows:

  • Create a table named 'Course_en' with the following table definition:
    CREATE TABLE `Course_en` (
    `CourseID` int(11) NOT NULL,
    `CourseTitle` varchar(64) NOT NULL,
    `CourseDescription` text NOT NULL,
    `HTMLOutline` text NOT NULL,
    `PDFOutline` longblob NOT NULL,
    `Subject` varchar(128) NOT NULL,
    PRIMARY KEY (`CourseID`)
    )

    Notice that this table contains all of the same fields as "Course" that need to be translated as well as the Primary KEY field from the "Course" table.  This table will contain all of the English translations for the courses.  Since this table is so similar to the "Course" table itself, I find it quicker to create this table by first copying the "Course" table then removing the fields that don't need to be translated.

  • Similarly create a table named 'Course_fr' to hold the French translations as follows:
    CREATE TABLE `Course_fr` (
    `CourseID` int(11) NOT NULL,
    `CourseTitle` varchar(64) NOT NULL,
    `CourseDescription` text NOT NULL,
    `HTMLOutline` text NOT NULL,
    `PDFOutline` longblob NOT NULL,
    `Subject` varchar(128) NOT NULL,
    PRIMARY KEY (`CourseID`)
    )
  • Turn on multilingual content in the conf.ini file:
    multilingual_content=1

    Note that this line should be at the beginning of the conf.ini file before any of the sections (e.g. [_database]).

  • Add a section to the conf.ini file to list the languages that will be supported:
    [languages]
    en=en
    fr=fr

Now if you start up our application and go to view a Course record, you will notice another tab after "view" and "edit", named "translate".  Click on this tab to access a translation form that allows you to translate the record from English to French, and vice versa:


translation_form.gif

You will also notice a set of flags in the top right of the application screen now to switch from English to French.  When in English mode, the user sees only the English versions of the data.  The French mode shows the French versions.  *Note that at the time of this writing, only the French and English flags are available.  More flags are present in the distribution but have to be renamed to make them work properly.  Please contact Steve Hannah (shannah@sfu.ca) if you need a particular flag to work.

Previous: Translating Static Text Up to Contents Next: Translating Field Labels and Descriptions
blog comments powered by Disqus
Powered by Xataface
(c) 2005-2025 All rights reserved