![]() |
Xataface 2.0
Xataface Application Framework
|
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 |
Definition at line 12 of file TranslationTool.php.
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.
Dataface_Record | &$record | The record for which we are checking the version. |
string | $language | The 2-digit language code for the language we are checking. |
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.
Dataface_Record | &$record | The record we are interested in. |
string | $language | 2-digit language code |
float | $version | <major_version>.<minor_version> |
string | $fieldname | Optional field name to get changes for. |
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.
Dataface_Record | $record | The record whose translation status we want to select. |
string | $language | 2-digit language code for the translation of interest. |
string | $name | The name of the HTML select widget. e.g. <select name="..."> |
string | $onchange | Optional string containing onchange javascript. |
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.
Dataface_Record | &$record | The record for which we want to know the translation status. |
string | $language | The 2-digit language code. |
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.
string | $newDefault | The 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.
Dataface_Record | The original record. | |
string | $language | 2-digit language code. |
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.
$schema |
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 |
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 |
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.