WordContextService
in package
Service for language and text context retrieval.
Provides methods for:
- Language configuration (romanization, dictionaries)
- Text-to-language mapping
- Sentence retrieval and formatting
- Term data export
Tags
Table of Contents
Properties
Methods
- __construct() : mixed
- Constructor.
- exportTermAsJson() : string
- Export term data as JSON for JavaScript.
- getLanguageData() : array{showRoman: bool, translateUri: string, name: string}
- Get language data for display settings.
- getLanguageDictionaries() : array{name: string, dict1: string, dict2: string, translate: string}
- Get language dictionaries for a text.
- getLanguageIdFromText() : int|null
- Get language ID from a text ID.
- getSentenceForTerm() : string
- Get sentence for a term.
- getSentenceIdAtPosition() : int|null
- Get sentence ID at a text position.
- getSentenceTextAtPosition() : string|null
- Get sentence text at a text position.
- shouldShowRomanization() : bool
- Check if romanization should be shown for a text's language.
- textToClassName() : string
- Convert text to hex class name for CSS.
Properties
$sentenceService
private
SentenceService
$sentenceService
Methods
__construct()
Constructor.
public
__construct([SentenceService|null $sentenceService = null ]) : mixed
Parameters
- $sentenceService : SentenceService|null = null
-
Sentence service
exportTermAsJson()
Export term data as JSON for JavaScript.
public
exportTermAsJson(int $wordId, string $text, string $roman, string $translation, int $status) : string
Parameters
- $wordId : int
-
Word ID
- $text : string
-
Term text
- $roman : string
-
Romanization
- $translation : string
-
Translation with tags
- $status : int
-
Word status
Return values
string —JSON encoded data
getLanguageData()
Get language data for display settings.
public
getLanguageData(int $langId) : array{showRoman: bool, translateUri: string, name: string}
Parameters
- $langId : int
-
Language ID
Return values
array{showRoman: bool, translateUri: string, name: string} —Language data
getLanguageDictionaries()
Get language dictionaries for a text.
public
getLanguageDictionaries(int $textId) : array{name: string, dict1: string, dict2: string, translate: string}
Parameters
- $textId : int
-
Text ID
Return values
array{name: string, dict1: string, dict2: string, translate: string}getLanguageIdFromText()
Get language ID from a text ID.
public
getLanguageIdFromText(int $textId) : int|null
Parameters
- $textId : int
-
Text ID
Return values
int|null —Language ID or null if not found
getSentenceForTerm()
Get sentence for a term.
public
getSentenceForTerm(int $textId, int $ord, string $termlc) : string
Parameters
- $textId : int
-
Text ID
- $ord : int
-
Word order
- $termlc : string
-
Lowercase term
Return values
string —Sentence with term marked
getSentenceIdAtPosition()
Get sentence ID at a text position.
public
getSentenceIdAtPosition(int $textId, int $ord) : int|null
Parameters
- $textId : int
-
Text ID
- $ord : int
-
Position in text
Return values
int|null —Sentence ID or null if not found
getSentenceTextAtPosition()
Get sentence text at a text position.
public
getSentenceTextAtPosition(int $textId, int $ord) : string|null
Parameters
- $textId : int
-
Text ID
- $ord : int
-
Position in text
Return values
string|null —Sentence text or null if not found
shouldShowRomanization()
Check if romanization should be shown for a text's language.
public
shouldShowRomanization(int $textId) : bool
Parameters
- $textId : int
-
Text ID
Return values
bool —Whether to show romanization
textToClassName()
Convert text to hex class name for CSS.
public
textToClassName(string $text) : string
Parameters
- $text : string
-
Text to convert
Return values
string —Hex class name