wCMF  3.6
 All Classes Namespaces Files Functions Variables Groups Pages
Message Class Reference

Public Member Functions

 get ($message, $parameters=null, $domain='', $lang='')
 
 getAll ($lang='')
 

Detailed Description

Use the Message class to output messages. You need not instantiate a Message object because the methods may be called like static class methods e.g. $translated = Message::get('text to translate')

Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 34 of file class.Message.php.

Member Function Documentation

Message::get (   $message,
  $parameters = null,
  $domain = '',
  $lang = '' 
)

The get() method is used to get a localized string. This method uses the GNU gettext (see PHP manual), the localization directory must be given in the global variable $MESSAGE_LOCALE_DIR (configuration value 'localeDir' in section 'cms')

Note
The language is determined in one of 3 ways (in this order):
  1. use the value of the global variable $MESSAGE_LANGUAGE (configuration value 'language' in section 'cms')
  2. use the value of the global variable $_SERVER['HTTP_ACCEPT_LANGUAGE']
  3. use the value of the given lang parameter
Parameters
messageThe message to translate (%0%, %1%, ... will be replaced by given parameters).
parametersAn array of values for parameter substitution in the message.
domainThe domain to get the text from, optional, default: 'main'.
langThe language, optional, default: ''.
Returns
The localized string
Note
It is not recommended to use this method with concatenated strings because this restricts the positions of words in translations. E.g. 'She was born in %1% on %2' translates to the german sentance 'Sie wurde am %2% in %1% geboren' with the variables flipped.
since gettext sometimes is not reliable (caching problem), it is possible to use custom php arrays created from .po files. use wcmf/tools/po2array.php to create the appropriate messages_$lang.php files in the locale directories. the usage of these arrays is configurable by the ini file option 'usegettext' in section 'cms' if this option is set to 0 the method tries to search for the appropriate array definition.

Definition at line 59 of file class.Message.php.

References $lang, and InifileParser\getInstance().

Referenced by UserManager\addUserToRole(), PersistenceMapper\authorizationFailedError(), UserManager\changePassword(), SaveController\checkFile(), ObjectQuery\checkMapper(), SearchIndexController\collect(), CopyController\copyNodes(), FileUtil\copyRec(), UserManager\createRole(), UserManager\createUser(), PersistentObject\delete(), Controller\execute(), DeleteController\executeKernel(), UserController\executeKernel(), SaveController\executeKernel(), InsertController\executeKernel(), AssociateController\executeKernel(), DisplayController\executeKernel(), LoginController\executeKernel(), ConfigController\executeKernel(), XMLExportController\exportNodes(), FileUtil\getDirectories(), BatchController\getDisplayText(), FileUtil\getFiles(), FormUtil\getListMap(), LockManager\getLockMessage(), NMUserRoleBase\getObjectDescription(), UserRDBBase\getObjectDescription(), RoleRDBBase\getObjectDescription(), AdodbseqBase\getObjectDescription(), LocktableBase\getObjectDescription(), PersistentObject\getObjectDescription(), NMUserRoleBase\getObjectDisplayName(), UserRDBBase\getObjectDisplayName(), AdodbseqBase\getObjectDisplayName(), RoleRDBBase\getObjectDisplayName(), LocktableBase\getObjectDisplayName(), PersistentObject\getObjectDisplayName(), UserManager\getPrincipal(), AdodbseqBase\getValueDescription(), NMUserRoleBase\getValueDescription(), RoleRDBBase\getValueDescription(), LocktableBase\getValueDescription(), UserRDBBase\getValueDescription(), PersistentObject\getValueDescription(), LocktableBase\getValueDisplayName(), NMUserRoleBase\getValueDisplayName(), RoleRDBBase\getValueDisplayName(), AdodbseqBase\getValueDisplayName(), UserRDBBase\getValueDisplayName(), PersistentObject\getValueDisplayName(), SearchIndexController\getWorkPackage(), XMLExportController\getWorkPackage(), BatchDisplayController\getWorkPackage(), CopyController\getWorkPackage(), SearchIndexController\index(), XMLExportController\initExport(), GraphicsUtil\isValidImageHeight(), GraphicsUtil\isValidImageWidth(), UserManager\listRoleMembers(), UserManager\listUserRoles(), BatchDisplayController\loadNodes(), ObjectQuery\makeGroup(), ActionMapper\processAction(), UserManager\removePrincipal(), UserManager\removeRole(), UserManager\removeUser(), UserManager\removeUserFromRole(), UserManager\resetPassword(), BackupController\restoreFiles(), PersistentObject\save(), SaveController\saveUploadFile(), UserManager\setRoleProperty(), UserManager\setUserProperty(), smarty_function_translate(), BatchDisplayController\startProcess(), CopyController\startProcess(), StringQuery\toString(), FileUtil\uploadFile(), CopyController\validate(), and PersistentObject\validateValueAgainstRestrictions().

+ Here is the call graph for this function:

Message::getAll (   $lang = '')

The getAll() method is used to get a localized list of all defined strings. See Message::get() for more information. This function only returns results if the ini file option 'usegettext' in section 'cms' is set to 0.

Parameters
langThe language, optional, default: ''.
Returns
An array of localized string

Definition at line 141 of file class.Message.php.

References $lang, and InifileParser\getInstance().

+ Here is the call graph for this function:


The documentation for this class was generated from the following file: