SourceMod SDK  1.7
SourceMod::ITranslator Class Referenceabstract

Provides functions for translation. More...

#include <public/ITranslator.h>

Inheritance diagram for SourceMod::ITranslator:
SourceMod::SMInterface

Public Member Functions

virtual const char * GetInterfaceName ()=0
 Must return a string defining the interface's unique name.
 
virtual unsigned int GetInterfaceVersion ()=0
 Must return an integer defining the interface's version.
 
virtual IPhraseCollectionCreatePhraseCollection ()=0
 Creates a new phrase collection object. More...
 
virtual unsigned int GetServerLanguage ()=0
 Returns the server language. More...
 
virtual unsigned int GetClientLanguage (int client)=0
 Returns a client's language. More...
 
virtual int SetGlobalTarget (int index)=0
 Sets the global client SourceMod will use for assisted translations (that is, t). More...
 
virtual int GetGlobalTarget () const =0
 Returns the global client SourceMod is currently using for assisted translations (that is, t). More...
 
virtual bool FormatString (char *buffer, size_t maxlength, const char *format, IPhraseCollection *pPhrases, void **params, unsigned int numparams, size_t *pOutLength, const char **pFailPhrase)=0
 Formats a phrase given a parameter stack. The parameter stack size must exactly match the expected parameter count. If this count is too small or too large, the format fails. More...
 
virtual unsigned int GetLanguageCount ()=0
 Get number of languages. More...
 
virtual bool GetLanguageByName (const char *name, unsigned int *index)=0
 Find a language number by name. More...
 
virtual bool GetLanguageInfo (unsigned int number, const char **code, const char **name)=0
 Retrieves info about a given language number. More...
 
virtual void RebuildLanguageDatabase ()=0
 Reparses all loaded translations files.
 
- Public Member Functions inherited from SourceMod::SMInterface
virtual bool IsVersionCompatible (unsigned int version)
 Must return whether the requested version number is backwards compatible. Note: This can be overridden for breaking changes or custom versioning. More...
 

Detailed Description

Provides functions for translation.

Member Function Documentation

virtual IPhraseCollection* SourceMod::ITranslator::CreatePhraseCollection ( )
pure virtual

Creates a new phrase collection object.

Returns
A new phrase collection object, which must be destroyed via IPhraseCollection::Destroy() when no longer needed.
virtual bool SourceMod::ITranslator::FormatString ( char *  buffer,
size_t  maxlength,
const char *  format,
IPhraseCollection pPhrases,
void **  params,
unsigned int  numparams,
size_t *  pOutLength,
const char **  pFailPhrase 
)
pure virtual

Formats a phrase given a parameter stack. The parameter stack size must exactly match the expected parameter count. If this count is too small or too large, the format fails.

Note: This is the same as IPhraseCollection::FormatString(), except that the IPhraseCollection parameter is explicit instead of implicit.

Parameters
bufferBuffer to store formatted text.
maxlengthMaximum length of the buffer.
formatString containing format information. This is equivalent to SourceMod's Format() native, and sub-translations are acceptable.
pPhrasesOptional phrase collection pointer to search for phrases.
paramsAn array of pointers to each parameter. Integer parameters must have a pointer to the integer. Float parameters must have a pointer to a float. String parameters must be a string pointer. Char parameters must be a pointer to a char. Translation parameters fill multiple indexes in the array. For T translations, the expected stack is: [phrase string pointer] [int target id pointer] [...] Where [...] is the required parameters for the translation, in the order expected by the phrase, not the phrase's translation. For example, say the format is: "%d %T" and the phrase's format is {1:s,2:f}, then the parameter stack should be: int *, const char *, int *, const char *, float * The t modifier is the same except the target id pointer would be removed: int *, const char *, const char *, float *
numparamsNumber of parameters in the params array.
pOutLengthOptional pointer filled with output length on success.
pFailPhraseOptional pointer; on failure, is filled with NULL if the failure was not due to a failed translation phrase. Otherwise, it is filled with the given phrase name pointer from the parameter stack. Undefined on success.
Returns
True on success. False if the parameter stack was not exactly the right length, or if a translation phrase could not be found.
virtual unsigned int SourceMod::ITranslator::GetClientLanguage ( int  client)
pure virtual

Returns a client's language.

Parameters
clientClient index.
Returns
Client language index, or server's if client's is not known.
virtual int SourceMod::ITranslator::GetGlobalTarget ( ) const
pure virtual

Returns the global client SourceMod is currently using for assisted translations (that is, t).

Returns
Global client index (0 for server).
virtual bool SourceMod::ITranslator::GetLanguageByName ( const char *  name,
unsigned int *  index 
)
pure virtual

Find a language number by name.

Parameters
nameLanguage name.
indexOptional pointer to store language index.
Returns
True if found, false otherwise.
virtual unsigned int SourceMod::ITranslator::GetLanguageCount ( )
pure virtual

Get number of languages.

Returns
Number of languages.
virtual bool SourceMod::ITranslator::GetLanguageInfo ( unsigned int  number,
const char **  code,
const char **  name 
)
pure virtual

Retrieves info about a given language number.

Parameters
numberLanguage number.
codePointer to store the language code.
namePointer to store language name.
Returns
True if language number is valid, false otherwise.
virtual unsigned int SourceMod::ITranslator::GetServerLanguage ( )
pure virtual

Returns the server language.

Returns
Server language index.
virtual int SourceMod::ITranslator::SetGlobalTarget ( int  index)
pure virtual

Sets the global client SourceMod will use for assisted translations (that is, t).

Parameters
indexClient index (0 for server).
Returns
Old global client value.

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