XarayaTranslationMemory
1.6
|
Public Member Functions | |
__construct ($stringID=0, $projectID=0, $original="", $localeID=1, $translation="", $sentenceID=0, $lastSeen=0, $rowOrder=0) | |
GetStringID () | |
GetProjectID () | |
GetOriginal () | |
GetLocaleID () | |
GetTranslation () | |
GetSentenceID () | |
GetLastSeen () | |
SetTranslation ($translation) | |
SetRowOrder ($index) | |
Save () | |
DestroyData () | |
FindSimilar ($FindText="", $localeID=0, $FilterPercent=60) | |
FindText ($findText="", $localeID=0, $findOriginal, $start=0, $limit=100) | |
Static Public Member Functions | |
static | InitSentenceLengthCache () |
static | InitWordSentencesCache () |
Static Public Attributes | |
static | $SentenceLengthCache |
static | $WordSentencesCache |
Private Member Functions | |
FindSentenceIndex ($findSimilarToo) | |
StoreSentenceIndex () | |
Private Attributes | |
$StringID | |
$ProjectID | |
$Original | |
$LocaleID | |
$Translation | |
$SentenceID | |
$LastSeen | |
$RowOrder | |
$Matches | |
$Words | |
Handles one string's data: original string, translation, locale, store new, load stored, etc.
Definition at line 26 of file TranslationString.php.
TranslationString::__construct | ( | $stringID = 0 , |
|
$projectID = 0 , |
|||
$original = "" , |
|||
$localeID = 1 , |
|||
$translation = "" , |
|||
$sentenceID = 0 , |
|||
$lastSeen = 0 , |
|||
$rowOrder = 0 |
|||
) |
Fetch a string from the database or create a new one from passed data.
TranslationString object can be constructed three ways:
$original = "", $stringID > 0: the specified string will be loaded from the database.
$original != "", $stringID > 0: the object instance is initailized with that data as if it was loaded from the database.
$original != "", $stringID = 0: in the way to create a new string with ->Save();
$stringID | Specifies which string to load from the database, 0 if passing all other data! |
$projectID | To which project this string belongs. |
$original | The original language string. |
$localeID | The locale ID of the specified translation. |
$translation | The translation of the $original string to $loccaleID locale. |
$sentenceID | ID of the ($origingal) string in the SentenceIndex table. |
$lastSeen | Unix timestamp of this string's last insert or update. |
$rowOrder | The row order index of this string in its project, see SetRowOrder(). |
Definition at line 65 of file TranslationString.php.
References $DB, GetDbConn(), and GetTables().
TranslationString::DestroyData | ( | ) |
Destroy the currently loaded string in the database, irreversible.
This object will hold the old string's data as if it was a new, not Save()-d one.
Definition at line 365 of file TranslationString.php.
References $DB, GetDbConn(), and GetTables().
|
private |
Find similar sentences in the sentence index database
If $findSimilarToo is true the similar sentences will be stored in the internal $this->Matches array. The key is the sentence ID, the value is the match percentage. If $findSimilarToo is false, only one result will be returned, the exact match. $this->Matches remains empty! (Exact match = same words same times, not exactly the same string!)
$findSimilarToo | If false, the search will end with the first exact match. |
Definition at line 584 of file TranslationString.php.
References $DB, $SentenceLengthCache, GetDbConn(), and GetTables().
Referenced by FindSimilar(), and Save().
TranslationString::FindSimilar | ( | $FindText = "" , |
|
$localeID = 0 , |
|||
$FilterPercent = 60 |
|||
) |
Public function to find existing sentences in the string database
Finds similar sentences and returns them in an array ordered by match percentage descending. Return format: array[stringID]["string"][] = array, TranslationString objects with all matches array[stringID]["percent"] = integer, match percentage If parameters are omitted, the current string object's text and localeID will be used. If parameters are specified, the current string is changed to those.
$FindText | The sentence or text to find, if emtpy, uses this object's Original string. |
$localeID | Find strings only in this locale. |
$FilterPercent | Drop results below this match percentage, defaults to 60. |
Definition at line 396 of file TranslationString.php.
References $DB, $Matches, FindSentenceIndex(), GetDbConn(), and GetTables().
TranslationString::FindText | ( | $findText = "" , |
|
$localeID = 0 , |
|||
$findOriginal, | |||
$start = 0 , |
|||
$limit = 100 |
|||
) |
Find strings based on part of the string.
Can find in both Original string and Translation, uses LIKE string% match for the select. There is no percentage data returned from this function, otherwise the array is the same like in FindSimilar().
$findText | The sentence or text to find, if emtpy, uses this object's Original o Translation. |
$localeID | Find strings only in this locale. |
$findOriginal | bool: true finds in Original strings, false finds in Translations. |
$start | int: Start at this result entry (for paging). |
$limit | int: Limit search results to this number. |
Definition at line 503 of file TranslationString.php.
References $DB, $LocaleID, $Original, $Translation, fixstr(), GetDbConn(), and GetTables().
TranslationString::GetLastSeen | ( | ) |
Get the current string's last update timestamp.
Definition at line 231 of file TranslationString.php.
References $LastSeen.
TranslationString::GetLocaleID | ( | ) |
Get the current string's locale id.
Definition at line 198 of file TranslationString.php.
References $LocaleID.
TranslationString::GetOriginal | ( | ) |
Get the current string's original (English) text.
Definition at line 187 of file TranslationString.php.
References $Original.
TranslationString::GetProjectID | ( | ) |
Get the current string's string project id.
Definition at line 176 of file TranslationString.php.
References $ProjectID.
TranslationString::GetSentenceID | ( | ) |
Get the current string's sentence index ID, based on what words this string contains.
Definition at line 220 of file TranslationString.php.
References $SentenceID.
TranslationString::GetStringID | ( | ) |
Get the current string's string id.
Definition at line 165 of file TranslationString.php.
References $StringID.
TranslationString::GetTranslation | ( | ) |
Get the current string's translation.
Definition at line 209 of file TranslationString.php.
References $Translation.
|
static |
Initialize the static sentence cache which contains word counts of each sentence.
The pre-cached wordcounts are used for searching similar things, match percent comparison is based on these numbers, becasue not all words of the SIMILAR strings will be loaded from the database on FindSimilar(), only those words what this searched string also has. Thus complete word-word percent comparsion needs this length data.
Sets TranslationString::$SentenceLengthCache
Definition at line 124 of file TranslationString.php.
References $DB, $SentenceLengthCache, GetDbConn(), and GetTables().
Referenced by CacheIndexes().
|
static |
LATER Initialize the static words sentence cache which contains in which sentences the given word occures.
Definition at line 143 of file TranslationString.php.
References $DB, $WordSentencesCache, GetDbConn(), and GetTables().
TranslationString::Save | ( | ) |
Store the string in the database and create indexes for it.
Checks if the same Original exists in the same Project. In this case no new string created, just updated.
Definition at line 272 of file TranslationString.php.
References $DB, $SentenceID, $SentenceLengthCache, $StringID, FindSentenceIndex(), GetDbConn(), GetTables(), and StoreSentenceIndex().
TranslationString::SetRowOrder | ( | $index | ) |
Set the current string's row order index, this will be used for ordering by StringIterators.
Using this value you can make sure, that strings are in good order, even if newer strings in the same project will get much higher StringID in later imports.
$index | The index of this string in its project, for better GUI displays. |
Definition at line 255 of file TranslationString.php.
Referenced by TranslationImportXaraya\ImportFile().
TranslationString::SetTranslation | ( | $translation | ) |
Set the current string's translation, call Save() to apply to the database.
$translation | The current string's new translated text. |
Definition at line 242 of file TranslationString.php.
|
private |
Insert the current sentence into the sentence index database
Called by this class after trying FindSentenceIndex for already existing match. If the find did not found a 100% match in the sentence index, this function can be called to add the current sentence.
Definition at line 666 of file TranslationString.php.
References $DB, GetDbConn(), and GetTables().
Referenced by Save().
|
private |
The date and time when this string was last updated.
Definition at line 34 of file TranslationString.php.
Referenced by GetLastSeen().
|
private |
Language, encoding of this string. Default: HU_hu.utf-8.
Definition at line 31 of file TranslationString.php.
Referenced by FindText(), and GetLocaleID().
|
private |
Other strings found to be similar, after calling a find!.
Definition at line 37 of file TranslationString.php.
Referenced by FindSimilar().
|
private |
The original English string.
Definition at line 30 of file TranslationString.php.
Referenced by FindText(), and GetOriginal().
|
private |
The ID of the project to which this string belogns.
Definition at line 29 of file TranslationString.php.
Referenced by GetProjectID().
|
private |
The row order index of this string in its project, see SetRowOrder().
Definition at line 35 of file TranslationString.php.
|
private |
The ID of this sentence in TranslaitonSentences table.
Definition at line 33 of file TranslationString.php.
Referenced by GetSentenceID(), and Save().
|
static |
Cache for strings' lengths: InitSentenceLengtCache()
Definition at line 40 of file TranslationString.php.
Referenced by FindSentenceIndex(), InitSentenceLengthCache(), and Save().
|
private |
ID of this string in TranslationStrings table.
Definition at line 28 of file TranslationString.php.
Referenced by GetStringID(), and Save().
|
private |
The tranlsation of $Original to $LocaleID.
Definition at line 32 of file TranslationString.php.
Referenced by FindText(), and GetTranslation().
|
private |
Contains the ($Original) words of this string
Definition at line 38 of file TranslationString.php.
|
static |
LATER Cache for "word in which sentences": InitWordSentencesCache()
Definition at line 41 of file TranslationString.php.
Referenced by InitWordSentencesCache().