Exemplo n.º 1
0
$domains = $kgReq->getVal('domains', false);
$lang = $kgReq->getVal('lang', $I18N->getLang());
/**
 * Response
 * -------------------------------------------------
 */
$resp = array();
if (!$domains) {
    // HTTP 400 Bad Request
    http_response_code(400);
    $resp['error'] = 'Parameter "domains" is required';
    i18nApiResp($resp);
}
$domains = explode('|', $domains);
$resp['messages'] = array();
foreach ($domains as $domain) {
    $normalisedDomain = $I18N->loadTextdomain($domain);
    if (!$normalisedDomain) {
        // Doesn't exist
        $resp['messages'][$domain] = false;
        continue;
    }
    if ($normalisedDomain !== $domain) {
        $resp['normalised']['domains'][$domain] = $normalisedDomain;
    }
    $keys = $I18N->listMsgs($normalisedDomain);
    foreach ($keys as $msgKey) {
        $resp['messages'][$domain][$msgKey] = $rawMsg = $I18N->rawMsg($normalisedDomain, $lang, $msgKey);
    }
}
i18nApiResp($resp);
Exemplo n.º 2
0
        echo $callback . '(' . json_encode($data) . ');';
    }
    exit;
}
$domains = $kgReq->getVal('domains', false);
$lang = $kgReq->getVal('lang', $I18N->getLang());
/**
 * Response
 * -------------------------------------------------
 */
$resp = array();
if (!$domains) {
    // HTTP 400 Bad Request
    http_response_code(400);
    $resp['error'] = 'Parameter "domains" is required';
    i18nApiResp($resp);
}
$domains = explode('|', $domains);
$resp['messages'] = array();
foreach ($domains as $domain) {
    $exists = $I18N->getDomainInfo($domain);
    if (!$exists) {
        $resp['messages'][$domain] = false;
        continue;
    }
    $keys = $I18N->listMsgs($domain);
    foreach ($keys as $key) {
        $resp['messages'][$domain][$key] = $I18N->rawMsg($domain, $lang, $key);
    }
}
i18nApiResp($resp);