public class Dictionary

class.lang.php #44

The Dictionary class contains a dictionary of all strings of the active system language. It allows strings to be added, removed, found or translated. It also offers a function to merge different dictionaries which is used to combine core and extension translations. The Dictionary class should only be used internally: for string translations and languages activation please use the translation function and make use of the Lang class provided in this file.

Methods

void __construct(array $strings)

The constructor for Dictionary.

Parameters
  • $strings arrayAssociative array mapping English strings and their translations, defaults to an empty array

void add(string $source, string $translation)

Given a source string an its translation, add both to the current dictionary.

Parameters
  • $source stringEnglish string

  • $translation stringTranslation

string|boolean find(string $string)

Given a string, return its translation.

Parameters
  • $string stringThe string to look for

Returns

Returns either the translation of the string or false if it could not be found

void merge(mixed $strings, array $string)

Given an associative array of strings, merge it with the current dictionary.

Parameters
  • $string arrayAssociative array containing English strings and their translations

void remove(string $string)

Given an English string, remove it from the current dictionary.

Parameters
  • $string stringString to be removed from the dictionary.

string translate(string $string, array $inserts)

The translation function accepts an English string and returns its translation to the active system language. If the given string is not available in the current dictionary the original English string will be returned. Given an optional array of inserts the function will also replace translation placeholders using vsprintf().

Note: If you like to translate strings, please use __() which is the common alias for this function.

Parameters
  • $string stringThe string that should be translated

  • $inserts arrayOptional array used to replace translation placeholders, defaults to NULL

Returns

Returns the translated string

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details