Jet\Translator_Backend
This abstract class is the backend of the translator, the class that actually retrieves and stores dictionaries. In normal use of the translator, you won't encounter this class, because the entire translator is used via the facade - the Jet\Translator (Jet\Tr) class. However, you need to know the class if you want to get into the compiler properly and, for example, create your own backend.
Overview of methods
Method | Meaning of |
---|---|
abstract public loadDictionary( string $dictionary, Locale $locale, ?string $file_path = null ): Translator_Dictionary |
Loads the given dictionary for the given location. To implement various tools it is possible to directly specify the file from which the dictionary should be loaded (parameter $file_path). However, in normal use, the backend will determine the file path itself (using the SysConf_Path::getDictionaries() setting) |
abstract public saveDictionary( Translator_Dictionary $dictionary, ?string $file_path = null ): void |
Saves the given dictionary. The dictionary name and location are already properties of the dictionary - so it is not necessary to specify these data as parameters . For the implementation of various tools it is possible to directly specify the file to which the dictionary should be saved (parameter $file_path). However, in normal use, the backend determines the file path itself (using the SysConf_Path::getDictionaries() setting) |
public updateTranslation( string $translation, array $data ) : string |
It adds any data to the translated phrase. It is possible to implement additional operations with the already translated phrase if you develop your own backend. |
public generateHash( string $phrase ): string |
For internal purposes, it generates a hash from the phrases that serves as a key in the phrase field of each dictionary. Why does something like this exist? If the phrases are short, it's not a problem to use the phrase itself as the key of the array. However, long phrases are counterproductive as an array key. That's why a hash is generated for long phrases. Since this mechanism is part of the backend, it can be changed if the backend itself is implemented. |
abstract public installApplicationModuleDictionaries( Application_Module_Manifest $module ): void |
This method installs the dictionaries that the application module carries in its installation directory. |
abstract public collectApplicationModuleDictionaries( Application_Module_Manifest $module ): void |
This method collect the current dictionaries belonging to the application module from the system and copies them to its installation directory. |
abstract public uninstallApplicationModuleDictionaries( Application_Module_Manifest $module ): void |
This method uninstalls (deletes) dictionaries belonging to application module from the system. |
abstract public getKnownLocales( ): Locale[] |
Returns a list of all localizations known to the translation system at that moment. |
abstract public getKnownDictionaries( Locale $locale ): string[] |
Returns a list of the names of all vocabularies of a given localization that the translation system knows at the moment. |