DictionaryAdapter
in package
Adapter for external dictionary services.
Handles dictionary link generation and lookup functionality.
Tags
Table of Contents
Methods
- createDictLink() : string
- Create and verify a dictionary URL link.
- createDictLinksInEditWin() : string
- Create dictionary links HTML for edit window.
- createDictLinksInEditWin2() : string
- Returns dictionary links formatted as HTML (popup version).
- createDictLinksInEditWin3() : string
- Create dictionary links for edit window (version 3).
- getLanguageDictionaries() : array{dict1: string, dict2: string, translator: string, popup1: bool, popup2: bool, popup3: bool}
- Get dictionary URIs for a language.
- getLocalDictMode() : int
- Get the local dictionary mode for a language.
- lookupWithLocal() : array{local: array, online: array{dict1: string, dict2: string, translator: string}}
- Look up a term with local dictionary support.
- makeDictLinks() : string
- Make dictionary links HTML.
- makeOpenDictStr() : string
- Create a dictionary open URL HTML element.
- makeOpenDictStrDynSent() : string
- Create a dictionary open URL HTML element for dynamic sentence translation.
Methods
createDictLink()
Create and verify a dictionary URL link.
public
static createDictLink(string $url, string $term) : string
Case 1: url without lwt_term: append UTF-8-term Case 2: url with lwt_term: substitute UTF-8-term
Parameters
- $url : string
-
Dictionary URL. It may contain 'lwt_term' placeholder
- $term : string
-
Text that substitutes the 'lwt_term'
Return values
string —Dictionary link formatted
createDictLinksInEditWin()
Create dictionary links HTML for edit window.
public
createDictLinksInEditWin(int $langId, string $word, string $sentctlid, bool $openFirst) : string
Parameters
- $langId : int
-
Language ID
- $word : string
-
Word to look up
- $sentctlid : string
-
ID of the sentence textarea element
- $openFirst : bool
-
True if we should open right frames with translation first
Return values
string —HTML-formatted interface
createDictLinksInEditWin2()
Returns dictionary links formatted as HTML (popup version).
public
createDictLinksInEditWin2(int $langId, string $sentctlid, string $wordctlid) : string
Parameters
- $langId : int
-
Language ID
- $sentctlid : string
-
ID of the sentence textarea element
- $wordctlid : string
-
ID of the word input element
Return values
string —HTML formatted interface
createDictLinksInEditWin3()
Create dictionary links for edit window (version 3).
public
createDictLinksInEditWin3(int $langId, string $sentctlid, string $wordctlid) : string
Parameters
- $langId : int
-
Language ID
- $sentctlid : string
-
ID of the sentence textarea element
- $wordctlid : string
-
ID of the word input element
Return values
string —HTML formatted interface
getLanguageDictionaries()
Get dictionary URIs for a language.
public
getLanguageDictionaries(int $langId) : array{dict1: string, dict2: string, translator: string, popup1: bool, popup2: bool, popup3: bool}
Parameters
- $langId : int
-
Language ID
Return values
array{dict1: string, dict2: string, translator: string, popup1: bool, popup2: bool, popup3: bool}getLocalDictMode()
Get the local dictionary mode for a language.
public
getLocalDictMode(int $langId) : int
Parameters
- $langId : int
-
Language ID
Return values
int —Mode (0=online only, 1=local first, 2=local only, 3=combined)
lookupWithLocal()
Look up a term with local dictionary support.
public
lookupWithLocal(int $langId, string $term) : array{local: array, online: array{dict1: string, dict2: string, translator: string}}
Parameters
- $langId : int
-
Language ID
- $term : string
-
Term to look up
Return values
array{local: array, online: array{dict1: string, dict2: string, translator: string}}makeDictLinks()
Make dictionary links HTML.
public
makeDictLinks(int $langId, string $word) : string
Parameters
- $langId : int
-
Language ID
- $word : string
-
The word to translate
Return values
string —HTML formatted links
makeOpenDictStr()
Create a dictionary open URL HTML element.
public
makeOpenDictStr(string $url, string $txt[, bool $popup = false ]) : string
Parameters
- $url : string
-
The dictionary URL
- $txt : string
-
Clickable text to display
- $popup : bool = false
-
Whether to open in popup window
Return values
string —HTML-formatted string
makeOpenDictStrDynSent()
Create a dictionary open URL HTML element for dynamic sentence translation.
public
makeOpenDictStrDynSent(string $url, string $sentctlid, string $txt[, bool $popup = false ]) : string
Parameters
- $url : string
-
Translator URL
- $sentctlid : string
-
ID of the textarea element containing the sentence
- $txt : string
-
Clickable text to display
- $popup : bool = false
-
Whether to open in popup window
Return values
string —HTML-formatted string