Xataface 2.0
Xataface Application Framework
Public Member Functions | Data Fields
Dataface_TranslationTool Class Reference

Public Member Functions

 Dataface_TranslationTool ()
 getHTMLStatusSelector (&$record, $language, $name, $onchange='')
 createTranslationsTable ()
 updateTranslationsTable ()
 createTranslationSubmissionsTable ()
 updateTranslationSubmissionsTable ()
 submitTranslation (&$record, $params=array())
 getRecordId (&$record)
 translateRecord (&$record, $sourceLanguage, $destLanguage)
 translateRecords (&$records, $sourceLanguage, $destLanguage)
 getTranslationId (&$record, $language)
 getTranslationRecord (&$record, $language)
 getCanonicalVersion (&$record, $language)
 markNewCanonicalVersion (&$record, $language=null)
 invalidateTranslations (&$record)
 setTranslationStatus (&$record, $language, $status)
 untranslate (&$record, $language, $fieldname=null)
 getChanges (&$record, $version, $lang=null, $fieldname=null)
 migrateDefaultLanguage ($newDefault, $tables=null)
 requiresMigration ()
 getMigratableTables ()
 migrate ()
 printTranslationStatusAlert ($record, $language=null)

Data Fields

 $schema
 $submission_schema
 $translation_status_codes

Detailed Description

Definition at line 12 of file TranslationTool.php.


Member Function Documentation

createTranslationsTable ( )

Creates the table to store the translation information.

Definition at line 101 of file TranslationTool.php.

createTranslationSubmissionsTable ( )

Creates the table to store the translation information.

Definition at line 159 of file TranslationTool.php.

Definition at line 55 of file TranslationTool.php.

getCanonicalVersion ( &$  record,
language 
)

Returns the canonical version of the translation for a record.

Parameters:
Dataface_Record&$recordThe record for which we are checking the version.
string$languageThe 2-digit language code for the language we are checking.
Returns:
string Canonical version in the form major_version.minor_version

Definition at line 305 of file TranslationTool.php.

getChanges ( &$  record,
version,
lang = null,
fieldname = null 
)

Returns the changes for a given record in a particular language, since a given version number.

Parameters:
Dataface_Record&$recordThe record we are interested in.
string$language2-digit language code
float$version<major_version>.<minor_version>
string$fieldnameOptional field name to get changes for.
Returns:
mixed Either a Dataface_Record object with the changes, or a string with the changes for $fieldname.

Definition at line 439 of file TranslationTool.php.

getHTMLStatusSelector ( &$  record,
language,
name,
onchange = '' 
)

Returns a string containing an HTML select list for selecting the translation status of a given record.

Parameters:
Dataface_Record$recordThe record whose translation status we want to select.
string$language2-digit language code for the translation of interest.
string$nameThe name of the HTML select widget. e.g. <select name="...">
string$onchangeOptional string containing onchange javascript.
Returns:
string

Definition at line 69 of file TranslationTool.php.

getMigratableTables ( )

Returns the tables that are eligible to be migrated.

Definition at line 551 of file TranslationTool.php.

getRecordId ( &$  record)

Returns the record id of a given record as it would appear in the record_id field of the translations table. It is basically a urlencode string of the record keys.

Definition at line 226 of file TranslationTool.php.

getTranslationId ( &$  record,
language 
)

Definition at line 242 of file TranslationTool.php.

getTranslationRecord ( &$  record,
language 
)

Gets a record from the dataface__translations table that stores the pertinent translation status information for the given record in the specified language.

Parameters:
Dataface_Record&$recordThe record for which we want to know the translation status.
string$languageThe 2-digit language code.
Returns:
Dataface_Record

Definition at line 286 of file TranslationTool.php.

invalidateTranslations ( &$  record)

Invalidates the non-original translations. This will set the translation statuses as follows: Unknown -> Unknown Machine -> Out-of-date (Machine translation) Approved -> Out-of-date Unverified -> Out-of-date (Unverified) Original -> Original Out-of-date * -> Out-of-date *

Definition at line 343 of file TranslationTool.php.

markNewCanonicalVersion ( &$  record,
language = null 
)

Marks a new canonical version for a given record's translation. The canonical version is an integer stored in the dataface__translations table's major_version column. It allows administrators to keep track of which version a translation corresponds to.

Definition at line 318 of file TranslationTool.php.

migrate ( )

Definition at line 580 of file TranslationTool.php.

migrateDefaultLanguage ( newDefault,
tables = null 
)

The early versions of the Dataface QueryTranslation extension stored even the default language translations in a translation table. This is not necessary, and even undesired when you consider that the default language should be a fall-back point for records that do not contain the proper translation. This method copies the translation data from the translation table of a particular language into the main table. Use this with caution as it will overwrite data from the underlying table.

Parameters:
string$newDefaultThe 2-digit language code for the new default language.

Definition at line 464 of file TranslationTool.php.

printTranslationStatusAlert ( record,
language = null 
)

Definition at line 586 of file TranslationTool.php.

requiresMigration ( )

This is to satisfy the Dataface Modules API so that migrations can be run using the manage_migrate action.

Definition at line 533 of file TranslationTool.php.

setTranslationStatus ( &$  record,
language,
status 
)

Definition at line 378 of file TranslationTool.php.

submitTranslation ( &$  record,
params = array() 
)

Definition at line 214 of file TranslationTool.php.

translateRecord ( &$  record,
sourceLanguage,
destLanguage 
)

Definition at line 239 of file TranslationTool.php.

translateRecords ( &$  records,
sourceLanguage,
destLanguage 
)

Definition at line 240 of file TranslationTool.php.

untranslate ( &$  record,
language,
fieldname = null 
)

Untranslates a record that currently has a machine translation. Since machine translation will only work on records that do not already have translations sometimes it is necessary to clear the existing translation so that it can be retranslated. This method will only work on records that are marked as machine translated.

Parameters:
Dataface_RecordThe original record.
string$language2-digit language code.
Returns:
boolean True if it succeeds.

Definition at line 401 of file TranslationTool.php.

updateTranslationsTable ( )

Definition at line 131 of file TranslationTool.php.

updateTranslationSubmissionsTable ( )

Definition at line 189 of file TranslationTool.php.


Field Documentation

$schema
Initial value:
 array(
                'id'=>array('Field'=>'id','Type'=>'int(11)','Key'=>'PRI','Null'=>'NOT NULL','Extra'=>'auto_increment'),
                'record_id'=>array('Field'=>'record_id','Type'=>'varchar(126)','Key'=>'record_key','Null'=>'NOT NULL','Extra'=>''),
                'language'=>array('Field'=>'language','Type'=>'varchar(2)','Key'=>'record_key','Null'=>'NOT NULL','Extra'=>''),
                'table'=>array('Field'=>'table','Type'=>'varchar(128)','Key'=>'record_key', 'Null'=>'NOT NULL','Extra'=>''),
                'version'=>array('Field'=>'version','Type'=>'int(11)','Key'=>'','Null'=>'NOT NULL','Default'=>1,'Extra'=>''),
                'translation_status'=>array('Field'=>'translation_status','Type'=>'int(11)','Key'=>'','Null'=>'NOT NULL','Default'=>0,'Extra'=>''),
                'last_modified'=>array('Field'=>'last_modified','Type'=>'datetime','Key'=>'','Null'=>'','Default'=>'0000-00-00','Extra'=>'')
                )

A schema for the translations table.

Definition at line 17 of file TranslationTool.php.

$submission_schema
Initial value:
 array(
                'id'=>array('Field'=>'id','Type'=>'int(11)','Key'=>'PRI','Null'=>'NOT NULL','Extra'=>'auto_increment'),
                'record_id'=>array('Field'=>'record_id','Type'=>'varchar(126)','Key'=>'record_key','Null'=>'NOT NULL','Extra'=>''),
                'language'=>array('Field'=>'language','Type'=>'varchar(2)','Key'=>'record_key','Null'=>'NOT NULL','Extra'=>''),
                'url'=>array('Field'=>'url','Type'=>'text','Key'=>'','Null'=>'NOT NULL','Default'=>'','Extra'=>''),
                'original_text'=>array('Field'=>'original_text','Type'=>'text','Key'=>'','Null'=>'NOT NULL','Default'=>'','Extra'=>''),
                'translated_text'=>array('Field'=>'translated_text','Type'=>'text','Key'=>'','Null'=>'NOT NULL','Default'=>'','Extra'=>''),
                'translated_by'=>array('Field'=>'translated_by','Type'=>'varchar(128)','Key'=>'','Null'=>'NOT NULL','Default'=>'','Extra'=>''),
                'date_submitted'=>array('Field'=>'last_modified','Type'=>'timestamp','Key'=>'','Null'=>'','Default'=>'','Extra'=>'')
                )

Definition at line 27 of file TranslationTool.php.

$translation_status_codes
Initial value:
 array(
                TRANSLATION_STATUS_UNTRANSLATED => 'Untranslated',
                TRANSLATION_STATUS_UNKNOWN => 'Unknown translation status',
                TRANSLATION_STATUS_SOURCE => 'Source translation',
                TRANSLATION_STATUS_MACHINE => 'Machine translation',
                TRANSLATION_STATUS_UNVERIFIED => 'Unverified translation',
                TRANSLATION_STATUS_APPROVED => 'Approved translation',
                TRANSLATION_STATUS_NEEDS_UPDATE => 'Out-of-date',
                TRANSLATION_STATUS_NEEDS_UPDATE_MACHINE =>'Out-of-date (Machine translation)',
                TRANSLATION_STATUS_NEEDS_UPDATE_UNVERIFIED =>'Out-of-date (Unverified)',
                TRANSLATION_STATUS_EXTERNAL => 'Managed Externally'
                )

Translation status codes to map integers to messages for translation_status column of the dataface__translations table.

Definition at line 42 of file TranslationTool.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations