/**
     * Show a drop down box which enables language selection in MongoUI
     * 
     * @param boolean $return If true it returns the HTML.
     */
    public function showLanguageChooser($return = false)
    {
        $translate = \MongoUI\Core\Translate::getInstance();
        $languages = $translate->getAvailableLanguages();
        $options = '';
        foreach ($languages as $language) {
            $options .= sprintf('<option value="%s">%s</option>\\n', $language[0], $language[1]);
        }
        $html = <<<EOF
<div id="languageChooser">
<form method="get">
    <select name="lang" onchange="this.form.submit()">
        {$options}
    </select>
</form>
</div>
EOF;
        if (!$return) {
            echo $html;
        } else {
            return $html;
        }
    }
Пример #2
0
 /**
  * 
  * Translate a string inside a template
  * 
  * @access public
  * 
  * @param string|array $href A string URL for the resulting tag.  May
  * also be an array with any combination of the keys 'scheme',
  * 'host', 'path', 'query', and 'fragment' (c.f. PHP's native
  * parse_url() function).
  * 
  * @param string $string The string to be translated.
  * @param array $args Optional arguments.
  * 
  * @return string The translated string.
  * 
  */
 public function translate($string, $args = array())
 {
     $translate = \MongoUI\Core\Translate::getInstance();
     return $translate->getTranslation($string, $args);
 }
Пример #3
0
function Translate($string, $args = array())
{
    return \MongoUI\Core\Translate::getInstance()->getTranslation($string, $args);
}