SourceMod SDK  1.7
SourceMod::IPhraseCollection Class Referenceabstract

#include <public/ITranslator.h>

Public Member Functions

virtual IPhraseFileAddPhraseFile (const char *filename)=0
 Adds a phrase file to the collection, using a cached one if already found. The return value is provided for informational purposes and does not need to be saved. The life time of the return pointer is equal to the life time of the collection. More...
 
virtual unsigned int GetFileCount ()=0
 Returns the number of contained phrase files. More...
 
virtual IPhraseFileGetFile (unsigned int file)=0
 Returns the pointer to a contained phrase file. More...
 
virtual void Destroy ()=0
 Destroys the phrase collection, freeing all internal resources and invalidating the object.
 
virtual TransError FindTranslation (const char *key, unsigned int langid, Translation *pTrans)=0
 Attempts a translation across a given language. All contained files are searched for an appropriate match; the first valid match is returned. More...
 
virtual bool FormatString (char *buffer, size_t maxlength, const char *format, 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...
 

Detailed Description

Represents a collection of phrase files.

Member Function Documentation

virtual IPhraseFile* SourceMod::IPhraseCollection::AddPhraseFile ( const char *  filename)
pure virtual

Adds a phrase file to the collection, using a cached one if already found. The return value is provided for informational purposes and does not need to be saved. The life time of the return pointer is equal to the life time of the collection.

This function will internally ignore dupliate additions but still return a valid pointer.

Parameters
filenameFile name, without the ".txt" extension, of the phrase file in the translations folder.
Returns
An IPhraseFile pointer, even if the file does not exist.
virtual TransError SourceMod::IPhraseCollection::FindTranslation ( const char *  key,
unsigned int  langid,
Translation pTrans 
)
pure virtual

Attempts a translation across a given language. All contained files are searched for an appropriate match; the first valid match is returned.

Parameters
keyString containing the phrase name.
langidLanguage ID to translate to.
pTransTranslation buffer.
Returns
Translation error code; on success, pTrans is valid. On failure, the contents of pTrans is undefined.
virtual bool SourceMod::IPhraseCollection::FormatString ( char *  buffer,
size_t  maxlength,
const char *  format,
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.

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.
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 IPhraseFile* SourceMod::IPhraseCollection::GetFile ( unsigned int  file)
pure virtual

Returns the pointer to a contained phrase file.

Parameters
fileFile index, from 0 to GetFileCount()-1.
Returns
IPhraseFile pointer, or NULL if out of range.
virtual unsigned int SourceMod::IPhraseCollection::GetFileCount ( )
pure virtual

Returns the number of contained phrase files.

Returns
Number of contained phrase files.

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