<?php /* Config */ require_once 'demoBase.php'; /* Demonstration */ // 1) Init $I18N $I18N = new TsIntuition('general'); // 2) Get message echo $I18N->msg('welcome'); /* View source */ closeDemo(__FILE__);
<?php /* Config */ require_once 'demoBase.php'; /* Demonstration */ // 1) Init TsIntuition $options = array('domain' => 'tsintuition', 'suppressbrackets' => true); $I18N = new TsIntuition($options); // 2) Request an undefined message // Because 'suppressbrackets' is true, // this will display "R4nd0mstr1n9" instead of [r4nd0mstr1n9] echo $I18N->msg('r4nd0mstr1n9'); /* View source */ closeDemo(__FILE__);
<?php // BaseTool & Localization require_once __DIR__ . '/lib/basetool/InitTool.php'; require_once KR_TSINT_START_INC; // Class for this tool require_once __DIR__ . '/class.php'; $kgTool = new KrSnapshots(); // Local settings require_once __DIR__ . '/local.php'; $I18N = new TsIntuition('mwsnapshots'); $toolConfig = array('displayTitle' => $I18N->msg('title-overview'), 'remoteBasePath' => dirname($kgConf->getRemoteBase()) . '/', 'revisionId' => '0.2.0', 'styles' => array('main.css'), 'scripts' => array('main.js'), 'I18N' => $I18N); $kgBaseTool = BaseTool::newFromArray($toolConfig); $kgBaseTool->setSourceInfoGithub('Krinkle', 'mw-tool-snapshots', __DIR__);
<?php /* Config */ require_once 'demoBase.php'; /* Demonstration */ // 1) Init $I18N $I18N = new TsIntuition('general'); // 2) Register some interesting messages $I18N->setMsgs(array('welcomeback' => 'Welcome back, $1! Would you like some $2?', 'basket' => 'The basket contains $1 {{PLURAL:$1|apple|apples}}.')); // 2) Use rendering and formatting // - Raw echo echo $I18N->msg('apple-stats'); echo '<br/>'; // - Pass variables echo '<br/>' . $I18N->msg('welcomeback', array('variables' => array('John', 'coffee'))); // - Pass variables echo '<br/>' . $I18N->msg('welcomeback', array('variables' => array('George', 'tea'))); echo '<br/>'; // - Trigger parser magic, setting $1 to '1' echo '<br/>' . $I18N->msg('basket', array('variables' => array('1'), 'parsemag' => true)); // - Trigger parser magic, setting $1 to '7' echo '<br/>' . $I18N->msg('basket', array('variables' => array('7'), 'parsemag' => true)); /* View source */ closeDemo(__FILE__);
* @package TsIntuition */ /** * Setup * ------------------------------------------------- */ // Load BaseTool $initPath = '../../ts-krinkle-basetool'; if (!is_readable($initPath)) { $initPath = dirname(__DIR__) . '/includes/libs/ts-krinkle-basetool'; } require_once $initPath . '/InitTool.php'; // Load Intuition require_once dirname(__DIR__) . '/ToolStart.php'; // Initialize Intuition $I18N = new TsIntuition(array('domain' => 'TsIntuition', 'mode' => 'dashboard')); // Load all domains so we can get some statistics later on and // make sure "getAvailableLangs" is complete foreach ($I18N->getAllRegisteredDomains() as $domainKey => $domainInfo) { $I18N->loadTextdomain($domainKey); } // Initialize BaseTool $Tool = BaseTool::newFromArray(array('displayTitle' => $I18N->msg('fullname'), 'krinklePrefix' => false, 'remoteBasePath' => $I18N->dashboardHome, 'localBasePath' => $I18N->localBaseDir, 'revisionId' => $I18N->version, 'styles' => array('main.css'))); $Tool->setSourceInfoGithub('Krinkle', 'TsIntuition', dirname(__DIR__)); /* Load Scripts & Styles */ // jQuery UI $jqueryui = $kgConf->getJQueryUI(); $Tool->addScripts($jqueryui['scripts']); $Tool->addStyles($jqueryui['styles']); /* Add initial stuff to <head> and <body> */ $Tool->doHtmlHead();
<?php if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'http') { $redirect = "https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; header("Location: {$redirect}"); exit; } require '../TsIntuition/ToolStart.php'; // for testing //require('/home/project/intuition/src/Intuition/ToolStart.php'); require 'common.php'; // Localization using TsIntuition // https://github.com/Krinkle/TsIntuition/wiki/Documentation $I18N = new TsIntuition(array('domain' => 'croptool')); ?> <!doctype html> <html ng-app="croptool"> <head> <title><?php echo $I18N->msg('title'); ?> </title> <meta http-equiv="Content-type" content="text/html;charset=UTF-8"> <script> // if (window.location.protocol != "https:") // window.location.href = "https:" + window.location.href.substring(window.location.protocol.length); </script>
<?php /* Config */ require_once 'demoBase.php'; /* Demonstration */ // 1) Init $I18N $I18N = new TsIntuition('general'); // 2) Use language names // - Current language name echo $I18N->getLangName(); // - Specific language name echo '<br/>' . $I18N->getLangName('fr'); /* View source */ closeDemo(__FILE__);
<?php /* Config */ require_once 'demoBase.php'; $I18N = new TsIntuition('general'); /* Demonstration */ echo $I18N->dashboardBacklink(); echo $I18N->getPromoBox(); echo $I18N->getFooterLine(); // defaults to TSINT_HELP_CURRENT echo $I18N->getFooterLine('orphantalk2'); echo $I18N->getFooterLine(TSINT_HELP_NONE); echo $I18N->getFooterLine(TSINT_HELP_ALL); /* View source */ closeDemo(__FILE__);
<?php /* Config */ require_once 'demoBase.php'; /* Demonstration */ // 1) Init $I18N $I18N = new TsIntuition('general'); // 2) Do it // Simple parentheses echo $I18N->parentheses('hello'); // Variables echo '<br/>' . $I18N->msg('toolversionstamp', array('variables' => array('1.0', $I18N->dateFormatted('2001-01-15')))); // msgExists echo '<br/>msgExists: '; var_dump($I18N->msgExists('welcome')); var_dump($I18N->msgExists('foobar')); // nonEmptyStr echo '<br/>nonEmptyStr: '; var_dump(TsIntuitionUtil::nonEmptyStr('one')); // nonEmptyStrs echo '<br/>nonEmptyStrs: '; var_dump(TsIntuitionUtil::nonEmptyStrs('one', '', 'three')); var_dump(TsIntuitionUtil::nonEmptyStrs('one', 'three')); // GetAcceptableLanguages echo "<br/>getAcceptableLanguages: (default: \$_SERVER['HTTP_ACCEPT_LANGUAGE']: " . htmlspecialchars($_SERVER['HTTP_ACCEPT_LANGUAGE']) . "):<br/>"; var_dump(TsIntuitionUtil::getAcceptableLanguages($_SERVER['HTTP_ACCEPT_LANGUAGE'])); $acceptLang = 'nl-be,nl;q=0.7,en-us,en;q=0.3'; echo "<br/>getAcceptableLanguages: ( '{$acceptLang}' ):<br/>"; var_dump(TsIntuitionUtil::getAcceptableLanguages($acceptLang)); /* View source */ closeDemo(__FILE__);
public function testOptionShowNotices() { $i18n = new TsIntuition(array('suppressnotice' => false)); $this->assertEquals('[r4nd0mstr1n9]', $i18n->msg('r4nd0mstr1n9'), 'Unknown key falls back to bracket-wrapped key'); $this->expectOutputString('Notice: [TsIntuition::msg] Message "r4nd0mstr1n9" in domain "general" not found.'); }
* @package TsIntuition */ /** * Set up * ------------------------------------------------- */ // Load BaseTool $initPath = '../../ts-krinkle-basetool'; if (!is_readable($initPath)) { $initPath = dirname(__DIR__) . '/includes/libs/ts-krinkle-basetool'; } require_once $initPath . '/InitTool.php'; // Load Intuition require_once dirname(__DIR__) . '/ToolStart.php'; // Initialize Intuition $I18N = new TsIntuition(array('domain' => 'TsIntuition', 'mode' => 'dashboard')); /** * Request * ------------------------------------------------- */ function i18nApiResp($data) { global $kgReq; $callback = $kgReq->getVal('callback'); // Serve as JSON or JSON-P if ($callback === null) { header('content-type: application/json; charset=utf-8', true); echo json_encode($data); } else { header('content-type: text/javascript; charset=utf-8', true); // Sanatize callback