Exemple #1
0
/**
 * Translates strings into other languages
 */
function t($s)
{
    if (!$s) {
        throw new \Exception('huh');
    }
    $locale = \cd\LocaleHandler::getInstance();
    switch ($locale->get()) {
        case 'ger':
            return $s;
            // German (Deutsch)   - XXX not translated
        // German (Deutsch)   - XXX not translated
        case 'eng':
            return $s;
            // English (System default)
        // English (System default)
        case 'swe':
            $t = \cd\t_swe($s);
            break;
            // Swedish (Svenska)
        // Swedish (Svenska)
        default:
            die('Unhandled language: ' . $locale->get());
    }
    if (!$t) {
        dp('Untranslated string: ' . $s);
        return '__(' . $s . ')__';
    }
    return $t;
}
Exemple #2
0
function countryFlag($s)
{
    if (is_numeric($s)) {
        $s = getCountryCode($s);
    } else {
        if (!is_alphanumeric($s)) {
            throw new \Exception('hey');
        }
        if (strlen($s) == 2) {
            $s = country_2_to_3_letters($s);
        }
        $s = strtoupper($s);
    }
    $locale = \cd\LocaleHandler::getInstance();
    $title = getCountryName($s);
    if (!$title) {
        throw new \Exception('unhandled country flag code ' . $s);
    }
    return '<img src="' . relurl('core_dev/gfx/flags/' . $s . '.png') . '" alt="' . $title . '" title="' . $title . '"/>';
}