Xataface Translation Memory Module 0.1
Translation Memory for Xataface Applications
Public Member Functions | Static Public Member Functions | Data Fields
XFTranslationMemory Class Reference

Public Member Functions

 __construct (Dataface_Record $rec)
 Creates a new TranslationMemory record that wraps a record of the xf_tm_translation_memories table.
 getRecord ()
 Gets the encapsulated xf_tm_translation_memories record.
 getSourceLanguage ()
 Gets the 2-digit language code of the source language of this translation memory.
 getDestinationLanguage ()
 Gets the 2-digit language code of the destination language of this translation memory.
 assignTo ($recid, $secure=false)
 Assigns the current translation memory to the record with the specified id.
 addTranslation ($string, $translation, $username=null, $secure=false)
 Adds a translation to the current translation memory. If the translation already exists in the system then that same translation will be linked to the translation memory. Otherwise the translation will be created and linked.
 containsTranslation ($string, $translation)
 Checks if the current translation memory contains the specified translation.
 findTranslation ($string, $translation)
 Finds the translation record for the given translation.
 scoreTranslation ($string, $translation, $score, $username=null, $secure=false)
 Scores a translation.
 setTranslationStatus ($string, $translation, $status, $username=null, $secure=false)
 Sets the status of a translation. Should be one of.
 addTranslationComment ($string, $translation, $comment, $username=null, $secure=false)
 Adds a comment to a translation.
 getTranslations (array $sources, $minStatus=3, $maxStatus=5)
 Gets translated strings corresponding to the given source strings.

Static Public Member Functions

static getDefaultTranslationMemory ($source, $dest, $secure=false)
 Gets the default translation memory for the given source and destination languages.
static loadTranslationMemoryById ($id)
 Loads a translation memory by its translation_memory_id.
static loadTranslationMemoryFor (Dataface_Record $record, $source, $dest)
 Loads the translation memory for a given record.
static findString ($string, $language)
 Finds a record encapsulating the given string.
static addString ($string, $language, $secure=false)
 Adds the given string to the database.

Data Fields

const TRANSLATION_REJECTED = 1
const TRANSLATION_SUBMITTED = 3
const TRANSLATION_APPROVED = 5

Detailed Description

Class that handles all of the translation memory functionality.

Author:
Steve Hannah <steve@weblite.ca>

Definition at line 28 of file XFTranslationMemory.php.


Constructor & Destructor Documentation

__construct ( Dataface_Record $  rec)

Creates a new TranslationMemory record that wraps a record of the xf_tm_translation_memories table.

Parameters:
Dataface_Record$recA record from the xf_tm_translation_memories table.

Definition at line 49 of file XFTranslationMemory.php.


Member Function Documentation

static addString ( string,
language,
secure = false 
) [static]

Adds the given string to the database.

Parameters:
string$stringThe string to be added.
string$languageThe 2-digit language code of the language for the string.
boolean$secureTrue if adding the string should be subject to Xataface permissions.
Returns:
Dataface_Record Record from the xf_tm_strings table.

Definition at line 355 of file XFTranslationMemory.php.

addTranslation ( string,
translation,
username = null,
secure = false 
)

Adds a translation to the current translation memory. If the translation already exists in the system then that same translation will be linked to the translation memory. Otherwise the translation will be created and linked.

Parameters:
string$stringThe source string.
string$translationThe translated string.
string$usernameThe username of the user who is adding the string. If omitted it will use the currently logged-in user.
boolean$secureTrue if adding this translation should be subject to xataface permissions.
Returns:
Dataface_Record The translation record from the xf_tm_translations table.

Definition at line 250 of file XFTranslationMemory.php.

addTranslationComment ( string,
translation,
comment,
username = null,
secure = false 
)

Adds a comment to a translation.

Parameters:
string$stringThe source string (or int string id).
string$translationThe translated string (or int translation id)
string$usernameThe usernmae of hte user who is adding the comment (default to logged in user).
boolean$secureTrue if adding the comment should be subject to xataface permissions.
Returns:
Dataface_Record record from the xf_tm_translations_comments table.

Definition at line 515 of file XFTranslationMemory.php.

assignTo ( recid,
secure = false 
)

Assigns the current translation memory to the record with the specified id.

Parameters:
string$recidThe ID of the record to assign this translation memory to. '*' for default.
boolean$secureTrue if inserting this join record should be subject to xatafae permissions.
Returns:
void
Exceptions:
ExceptionIf it fails to save.

Definition at line 184 of file XFTranslationMemory.php.

containsTranslation ( string,
translation 
)

Checks if the current translation memory contains the specified translation.

Parameters:
string$stringThe source string
string$translationThe translated string.
Returns:
boolean True if it contains the translation.

Definition at line 315 of file XFTranslationMemory.php.

static findString ( string,
language 
) [static]

Finds a record encapsulating the given string.

Parameters:
string$stringThe string that we want to find.
Returns:
Dataface_Record The record for the string from the xf_tm_strings table.

Definition at line 334 of file XFTranslationMemory.php.

findTranslation ( string,
translation 
)

Finds the translation record for the given translation.

Parameters:
string$stringThe source string or the integer string id of the string.
string$translationThe translated String
Returns:
Dataface_Record Record from the xf_tm_translations table.

Definition at line 389 of file XFTranslationMemory.php.

static getDefaultTranslationMemory ( source,
dest,
secure = false 
) [static]

Gets the default translation memory for the given source and destination languages.

Parameters:
string$sourceThe 2-digit language code of the source language.
string$destThe 2-diggit language code of the destination language.
boolean$secureTrue if inserting a translation memory record should be subject to Xataface permissions.
Returns:
XFTranslationMemory The defautl translation memory with the given source and destination languages.

Definition at line 98 of file XFTranslationMemory.php.

getDestinationLanguage ( )

Gets the 2-digit language code of the destination language of this translation memory.

Definition at line 74 of file XFTranslationMemory.php.

getRecord ( )

Gets the encapsulated xf_tm_translation_memories record.

Returns:
Dataface_Record A record from the xf_tm_translation_memories table.

Definition at line 57 of file XFTranslationMemory.php.

getSourceLanguage ( )

Gets the 2-digit language code of the source language of this translation memory.

Definition at line 65 of file XFTranslationMemory.php.

getTranslations ( array $  sources,
minStatus = 3,
maxStatus = 5 
)

Gets translated strings corresponding to the given source strings.

Parameters:
array$sourcesArray of source strings.
int$minStatusThe minimum status of a translation to return (5=approved, 3=submitted, 1=rejected)
int$maxStatusThe maximum status of a translation to return (5=approved, 3=submitted, 1=rejected)

Definition at line 548 of file XFTranslationMemory.php.

static loadTranslationMemoryById ( id) [static]

Loads a translation memory by its translation_memory_id.

Parameters:
int$idThe translation_memory_id of the memory to load.
Returns:
XFTranslationMemory

Definition at line 203 of file XFTranslationMemory.php.

static loadTranslationMemoryFor ( Dataface_Record $  record,
source,
dest 
) [static]

Loads the translation memory for a given record.

Parameters:
Dataface_Record$recordThe record for which the translation memory is used.
string$sourceThe 2-digit language code of the source language.
string$destThe 2-digit language code of the destination language.
Returns:
XFTranslationMemory or null if it cannot be found.

Definition at line 218 of file XFTranslationMemory.php.

scoreTranslation ( string,
translation,
score,
username = null,
secure = false 
)

Scores a translation.

Parameters:
string$stringThe source string (or integer string id)
string$translationThe translation string (or integer translation id)
int$scoreThe score to be applied to the translation.
string$usernameThe username of the user who is marking it (default is currently logged in user).
boolean$secureTrue if marking this translation should be subject to Xataface permissions.
Returns:
Dataface_Record record from the xf_tm_translations_score table.

Definition at line 435 of file XFTranslationMemory.php.

setTranslationStatus ( string,
translation,
status,
username = null,
secure = false 
)

Sets the status of a translation. Should be one of.

Parameters:
string$stringThe source string (or int string id).
string$translationThe translated string (or int translation id)
string$usernameThe username of the user who is setting this (default to current logged in user.
boolean$secureTrue if setting the status should be subject to xataface permissions.
Returns:
Dataface_Record Record from the xf_tm_translations_status table.

Definition at line 479 of file XFTranslationMemory.php.


Field Documentation

Definition at line 34 of file XFTranslationMemory.php.

Definition at line 30 of file XFTranslationMemory.php.

Definition at line 32 of file XFTranslationMemory.php.


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