本文整理汇总了PHP中Language::getLocalisationCache方法的典型用法代码示例。如果您正苦于以下问题:PHP Language::getLocalisationCache方法的具体用法?PHP Language::getLocalisationCache怎么用?PHP Language::getLocalisationCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Language
的用法示例。
在下文中一共展示了Language::getLocalisationCache方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPuralRulesFallback
public function testPuralRulesFallback()
{
$cache = Language::getLocalisationCache();
$this->assertEquals($cache->getItem('ru', 'pluralRules'), $cache->getItem('os', 'pluralRules'), 'os plural rules (undefined) fallback to ru (defined)');
$this->assertEquals($cache->getItem('ru', 'compiledPluralRules'), $cache->getItem('os', 'compiledPluralRules'), 'os compiled plural rules (undefined) fallback to ru (defined)');
$this->assertNotEquals($cache->getItem('ksh', 'pluralRules'), $cache->getItem('de', 'pluralRules'), 'ksh plural rules (defined) dont fallback to de (defined)');
$this->assertNotEquals($cache->getItem('ksh', 'compiledPluralRules'), $cache->getItem('de', 'compiledPluralRules'), 'ksh compiled plural rules (defined) dont fallback to de (defined)');
}
示例2: updateMessageCache
static function updateMessageCache()
{
if (MwFunctions::isAsyncLoadRequest()) {
return false;
}
// skip subsequent calls to load stuff
global $wgLang;
$langCode = $wgLang->getCode();
wfDebugLog('MultiAuthPlugin', __METHOD__ . ': ' . "Detected lang: {$langCode}");
Language::getLocalisationCache()->recache($langCode);
// hack for post 1.18.0
return true;
}
示例3: execute
public function execute()
{
// Prevent the script from timing out
set_time_limit(0);
ini_set("max_execution_time", 0);
ini_set('memory_limit', -1);
global $wgExtensionMessagesFiles, $IP;
global $wgLocalisationUpdateRepositories;
global $wgLocalisationUpdateRepository;
$dir = LocalisationUpdate::getDirectory();
if (!$dir) {
$this->error("No cache directory configured", true);
return;
}
$lc = Language::getLocalisationCache();
if (is_callable(array($lc, 'getMessagesDirs'))) {
// Introduced in 1.25
$messagesDirs = $lc->getMessagesDirs();
} else {
global $wgMessagesDirs;
$messagesDirs = $wgMessagesDirs;
}
$finder = new LU_Finder($wgExtensionMessagesFiles, $messagesDirs, $IP);
$readerFactory = new LU_ReaderFactory();
$fetcherFactory = new LU_FetcherFactory();
$repoid = $this->getOption('repoid', $wgLocalisationUpdateRepository);
if (!isset($wgLocalisationUpdateRepositories[$repoid])) {
$known = implode(', ', array_keys($wgLocalisationUpdateRepositories));
$this->error("Unknown repoid {$repoid}; known: {$known}", true);
return;
}
$repos = $wgLocalisationUpdateRepositories[$repoid];
// Do it ;)
$updater = new LU_Updater();
$updatedMessages = $updater->execute($finder, $readerFactory, $fetcherFactory, $repos);
// Store it ;)
$count = array_sum(array_map('count', $updatedMessages));
if (!$count) {
$this->output("Found no new translations\n");
return;
}
foreach ($updatedMessages as $language => $messages) {
$filename = "{$dir}/" . LocalisationUpdate::getFilename($language);
file_put_contents($filename, FormatJson::encode($messages, true));
}
$this->output("Saved {$count} new translations\n");
}
示例4: fetchMessageInfo
/**
* @param string|bool $langCode See --lang-code option.
* @param array &$messageInfo
*/
protected function fetchMessageInfo($langCode, array &$messageInfo)
{
global $wgContLang;
if ($langCode) {
$this->output("\n... fetching message info for language: {$langCode}");
$nonContLang = true;
} else {
$this->output("\n... fetching message info for content language");
$langCode = $wgContLang->getCode();
$nonContLang = false;
}
/* Based on SpecialAllmessages::reallyDoQuery #filter=modified */
$l10nCache = Language::getLocalisationCache();
$messageNames = $l10nCache->getSubitemList('en', 'messages');
// Normalise message names for NS_MEDIAWIKI page_title
$messageNames = array_map(array($wgContLang, 'ucfirst'), $messageNames);
$statuses = AllMessagesTablePager::getCustomisedStatuses($messageNames, $langCode, $nonContLang);
// getCustomisedStatuses is stripping the sub page from the page titles, add it back
$titleSuffix = $nonContLang ? "/{$langCode}" : '';
foreach ($messageNames as $key) {
$customised = isset($statuses['pages'][$key]);
if ($customised) {
$actual = wfMessage($key)->inLanguage($langCode)->plain();
$default = wfMessage($key)->inLanguage($langCode)->useDatabase(false)->plain();
$messageInfo['relevantPages']++;
if ($default !== '' && $default !== '-' && $actual === $default) {
$hasTalk = isset($statuses['talks'][$key]);
$messageInfo['results'][] = array('title' => $key . $titleSuffix, 'hasTalk' => $hasTalk);
$messageInfo['equalPages']++;
if ($hasTalk) {
$messageInfo['equalPagesTalks']++;
}
}
}
}
}
示例5: __construct
/**
* Constructor, always call this from child classes.
*/
public function __construct()
{
global $wgExtensionMessagesFiles, $wgUser;
// Disable the i18n cache and LoadBalancer
Language::getLocalisationCache()->disableBackend();
LBFactory::disableBackend();
// Load the installer's i18n file.
$wgExtensionMessagesFiles['MediawikiInstaller'] = dirname(__FILE__) . '/Installer.i18n.php';
// Having a user with id = 0 safeguards us from DB access via User::loadOptions().
$wgUser = User::newFromId(0);
$this->settings = $this->internalDefaults;
foreach ($this->defaultVarNames as $var) {
$this->settings[$var] = $GLOBALS[$var];
}
$compiledDBs = array();
foreach (self::getDBTypes() as $type) {
$installer = $this->getDBInstaller($type);
if (!$installer->isCompiled()) {
continue;
}
$compiledDBs[] = $type;
$defaults = $installer->getGlobalDefaults();
foreach ($installer->getGlobalNames() as $var) {
if (isset($defaults[$var])) {
$this->settings[$var] = $defaults[$var];
} else {
$this->settings[$var] = $GLOBALS[$var];
}
}
}
$this->setVar('_CompiledDBs', $compiledDBs);
$this->parserTitle = Title::newFromText('Installer');
$this->parserOptions = new ParserOptions();
// language will be wrong :(
$this->parserOptions->setEditSection(false);
}
示例6: elseif
// For MSSQL
$wgDBprefix = $conf->DBprefix2;
} elseif ($conf->DBprefix_ora != '') {
// For Oracle
$wgDBprefix = $conf->DBprefix_ora;
}
## DB2 specific:
$wgDBcataloged = $conf->DBcataloged;
$wgCommandLineMode = true;
if (!defined('STDERR')) {
define('STDERR', fopen("php://stderr", "wb"));
}
$wgUseDatabaseMessages = false;
/* FIXME: For database failure */
require_once "{$IP}/includes/Setup.php";
Language::getLocalisationCache()->disableBackend();
chdir("config");
$wgTitle = Title::newFromText("Installation script");
error_reporting(E_ALL | E_STRICT);
print "<li>Loading class: " . htmlspecialchars($dbclass) . "</li>\n";
if ($conf->DBtype != 'sqlite') {
$dbc = new $dbclass();
}
if ($conf->DBtype == 'mysql') {
$mysqlOldClient = version_compare(mysql_get_client_info(), "4.1.0", "lt");
if ($mysqlOldClient) {
print "<li><b>PHP is linked with old MySQL client libraries. If you are\n\t\t\t\t\tusing a MySQL 4.1 server and have problems connecting to the database,\n\t\t\t\t\tsee <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'\n\t\t\t \t\t>http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n";
}
$ok = true;
# Let's be optimistic
# Decide if we're going to use the superuser or the regular database user
示例7: tearDown
protected function tearDown()
{
parent::tearDown();
global $wgLang;
Language::getLocalisationCache()->recache($wgLang->getCode());
}
示例8: getAllMessages
function getAllMessages($descending)
{
wfProfileIn(__METHOD__);
$messageNames = Language::getLocalisationCache()->getSubitemList('en', 'messages');
if ($descending) {
rsort($messageNames);
} else {
asort($messageNames);
}
// Normalise message names so they look like page titles
$messageNames = array_map(array($this->lang, 'ucfirst'), $messageNames);
wfProfileOut(__METHOD__);
return $messageNames;
}
示例9: addDBData
function addDBData()
{
$this->tablesUsed[] = 'site_stats';
$this->tablesUsed[] = 'interwiki';
# disabled for performance
#$this->tablesUsed[] = 'image';
# Hack: insert a few Wikipedia in-project interwiki prefixes,
# for testing inter-language links
$this->db->insert('interwiki', array(array('iw_prefix' => 'wikipedia', 'iw_url' => 'http://en.wikipedia.org/wiki/$1', 'iw_api' => '', 'iw_wikiid' => '', 'iw_local' => 0), array('iw_prefix' => 'meatball', 'iw_url' => 'http://www.usemod.com/cgi-bin/mb.pl?$1', 'iw_api' => '', 'iw_wikiid' => '', 'iw_local' => 0), array('iw_prefix' => 'zh', 'iw_url' => 'http://zh.wikipedia.org/wiki/$1', 'iw_api' => '', 'iw_wikiid' => '', 'iw_local' => 1), array('iw_prefix' => 'es', 'iw_url' => 'http://es.wikipedia.org/wiki/$1', 'iw_api' => '', 'iw_wikiid' => '', 'iw_local' => 1), array('iw_prefix' => 'fr', 'iw_url' => 'http://fr.wikipedia.org/wiki/$1', 'iw_api' => '', 'iw_wikiid' => '', 'iw_local' => 1), array('iw_prefix' => 'ru', 'iw_url' => 'http://ru.wikipedia.org/wiki/$1', 'iw_api' => '', 'iw_wikiid' => '', 'iw_local' => 1)), __METHOD__, array('IGNORE'));
# Update certain things in site_stats
$this->db->insert('site_stats', array('ss_row_id' => 1, 'ss_images' => 2, 'ss_good_articles' => 1), __METHOD__);
# Reinitialise the LocalisationCache to match the database state
Language::getLocalisationCache()->unloadAll();
# Clear the message cache
MessageCache::singleton()->clear();
$user = User::newFromId(0);
LinkCache::singleton()->clear();
# Avoids the odd failure at creating the nullRevision
# Upload DB table entries for files.
# We will upload the actual files later. Note that if anything causes LocalFile::load()
# to be triggered before then, it will break via maybeUpgrade() setting the fileExists
# member to false and storing it in cache.
$image = wfLocalFile(Title::makeTitle(NS_FILE, 'Foobar.jpg'));
if (!$this->db->selectField('image', '1', array('img_name' => $image->getName()))) {
$image->recordUpload2('', 'Upload of some lame file', 'Some lame file', array('size' => 12345, 'width' => 1941, 'height' => 220, 'bits' => 24, 'media_type' => MEDIATYPE_BITMAP, 'mime' => 'image/jpeg', 'metadata' => serialize(array()), 'sha1' => wfBaseConvert('', 16, 36, 31), 'fileExists' => true), $this->db->timestamp('20010115123500'), $user);
}
# This image will be blacklisted in [[MediaWiki:Bad image list]]
$image = wfLocalFile(Title::makeTitle(NS_FILE, 'Bad.jpg'));
if (!$this->db->selectField('image', '1', array('img_name' => $image->getName()))) {
$image->recordUpload2('', 'zomgnotcensored', 'Borderline image', array('size' => 12345, 'width' => 320, 'height' => 240, 'bits' => 24, 'media_type' => MEDIATYPE_BITMAP, 'mime' => 'image/jpeg', 'metadata' => serialize(array()), 'sha1' => wfBaseConvert('', 16, 36, 31), 'fileExists' => true), $this->db->timestamp('20010115123500'), $user);
}
}
示例10: getAllMessages
function getAllMessages($descending)
{
$messageNames = Language::getLocalisationCache()->getSubitemList('en', 'messages');
// Normalise message names so they look like page titles and sort correctly - T86139
$messageNames = array_map(array($this->lang, 'ucfirst'), $messageNames);
if ($descending) {
rsort($messageNames);
} else {
asort($messageNames);
}
return $messageNames;
}
示例11: addMessagesByLang
/**
* Add a 2-D array of messages by lang. Useful for extensions.
* @deprecated Use $wgExtensionMessagesFiles
*
* @param array $messages The array to be added
*/
function addMessagesByLang($messages)
{
wfDeprecated(__METHOD__);
$lc = Language::getLocalisationCache();
$lc->addLegacyMessages($messages);
}
示例12: __construct
/**
* Constructor, always call this from child classes.
*/
public function __construct()
{
global $wgMemc, $wgUser, $wgObjectCaches;
$defaultConfig = new GlobalVarConfig();
// all the stuff from DefaultSettings.php
$installerConfig = self::getInstallerConfig($defaultConfig);
// Reset all services and inject config overrides
MediaWiki\MediaWikiServices::resetGlobalInstance($installerConfig);
// Don't attempt to load user language options (T126177)
// This will be overridden in the web installer with the user-specified language
RequestContext::getMain()->setLanguage('en');
// Disable the i18n cache
// TODO: manage LocalisationCache singleton in MediaWikiServices
Language::getLocalisationCache()->disableBackend();
// Disable all global services, since we don't have any configuration yet!
MediaWiki\MediaWikiServices::disableStorageBackend();
// Disable object cache (otherwise CACHE_ANYTHING will try CACHE_DB and
// SqlBagOStuff will then throw since we just disabled wfGetDB)
$wgObjectCaches = MediaWikiServices::getInstance()->getMainConfig()->get('ObjectCaches');
$wgMemc = ObjectCache::getInstance(CACHE_NONE);
// Having a user with id = 0 safeguards us from DB access via User::loadOptions().
$wgUser = User::newFromId(0);
RequestContext::getMain()->setUser($wgUser);
$this->settings = $this->internalDefaults;
foreach ($this->defaultVarNames as $var) {
$this->settings[$var] = $GLOBALS[$var];
}
$this->doEnvironmentPreps();
$this->compiledDBs = [];
foreach (self::getDBTypes() as $type) {
$installer = $this->getDBInstaller($type);
if (!$installer->isCompiled()) {
continue;
}
$this->compiledDBs[] = $type;
}
$this->parserTitle = Title::newFromText('Installer');
$this->parserOptions = new ParserOptions($wgUser);
// language will be wrong :(
$this->parserOptions->setEditSection(false);
}
示例13: __construct
/**
* Constructor, always call this from child classes.
*/
public function __construct()
{
global $wgMessagesDirs, $wgUser;
// Disable the i18n cache
Language::getLocalisationCache()->disableBackend();
// Disable LoadBalancer and wfGetDB etc.
LBFactory::disableBackend();
// Disable object cache (otherwise CACHE_ANYTHING will try CACHE_DB and
// SqlBagOStuff will then throw since we just disabled wfGetDB)
$GLOBALS['wgMemc'] = new EmptyBagOStuff();
ObjectCache::clear();
$emptyCache = array('class' => 'EmptyBagOStuff');
$GLOBALS['wgObjectCaches'] = array(CACHE_NONE => $emptyCache, CACHE_DB => $emptyCache, CACHE_ANYTHING => $emptyCache, CACHE_MEMCACHED => $emptyCache);
// Load the installer's i18n.
$wgMessagesDirs['MediawikiInstaller'] = __DIR__ . '/i18n';
// Having a user with id = 0 safeguards us from DB access via User::loadOptions().
$wgUser = User::newFromId(0);
$this->settings = $this->internalDefaults;
foreach ($this->defaultVarNames as $var) {
$this->settings[$var] = $GLOBALS[$var];
}
$this->doEnvironmentPreps();
$this->compiledDBs = array();
foreach (self::getDBTypes() as $type) {
$installer = $this->getDBInstaller($type);
if (!$installer->isCompiled()) {
continue;
}
$this->compiledDBs[] = $type;
}
$this->parserTitle = Title::newFromText('Installer');
$this->parserOptions = new ParserOptions();
// language will be wrong :(
$this->parserOptions->setEditSection(false);
}
示例14: addDBData
function addDBData()
{
# Hack: insert a few Wikipedia in-project interwiki prefixes,
# for testing inter-language links
$this->db->insert('interwiki', array(array('iw_prefix' => 'wikipedia', 'iw_url' => 'http://en.wikipedia.org/wiki/$1', 'iw_api' => '', 'iw_wikiid' => '', 'iw_local' => 0), array('iw_prefix' => 'meatball', 'iw_url' => 'http://www.usemod.com/cgi-bin/mb.pl?$1', 'iw_api' => '', 'iw_wikiid' => '', 'iw_local' => 0), array('iw_prefix' => 'zh', 'iw_url' => 'http://zh.wikipedia.org/wiki/$1', 'iw_api' => '', 'iw_wikiid' => '', 'iw_local' => 1), array('iw_prefix' => 'es', 'iw_url' => 'http://es.wikipedia.org/wiki/$1', 'iw_api' => '', 'iw_wikiid' => '', 'iw_local' => 1), array('iw_prefix' => 'fr', 'iw_url' => 'http://fr.wikipedia.org/wiki/$1', 'iw_api' => '', 'iw_wikiid' => '', 'iw_local' => 1), array('iw_prefix' => 'ru', 'iw_url' => 'http://ru.wikipedia.org/wiki/$1', 'iw_api' => '', 'iw_wikiid' => '', 'iw_local' => 1)), __METHOD__, array('IGNORE'));
# Update certain things in site_stats
$this->db->insert('site_stats', array('ss_row_id' => 1, 'ss_images' => 2, 'ss_good_articles' => 1), __METHOD__, array('IGNORE'));
# Reinitialise the LocalisationCache to match the database state
Language::getLocalisationCache()->unloadAll();
# Clear the message cache
MessageCache::singleton()->clear();
$this->uploadDir = $this->setupUploadDir();
$user = User::newFromId(0);
LinkCache::singleton()->clear();
# Avoids the odd failure at creating the nullRevision
$image = wfLocalFile(Title::makeTitle(NS_FILE, 'Foobar.jpg'));
$image->recordUpload2('', 'Upload of some lame file', 'Some lame file', array('size' => 12345, 'width' => 1941, 'height' => 220, 'bits' => 24, 'media_type' => MEDIATYPE_BITMAP, 'mime' => 'image/jpeg', 'metadata' => serialize(array()), 'sha1' => wfBaseConvert('', 16, 36, 31), 'fileExists' => true), $this->db->timestamp('20010115123500'), $user);
# This image will be blacklisted in [[MediaWiki:Bad image list]]
$image = wfLocalFile(Title::makeTitle(NS_FILE, 'Bad.jpg'));
$image->recordUpload2('', 'zomgnotcensored', 'Borderline image', array('size' => 12345, 'width' => 320, 'height' => 240, 'bits' => 24, 'media_type' => MEDIATYPE_BITMAP, 'mime' => 'image/jpeg', 'metadata' => serialize(array()), 'sha1' => wfBaseConvert('', 16, 36, 31), 'fileExists' => true), $this->db->timestamp('20010115123500'), $user);
}
示例15: execute
public function execute() {
if ( $this->getVar( '_SkipOptional' ) == 'skip' ) {
return 'skip';
}
if ( $this->parent->request->wasPosted() ) {
if ( $this->submit() ) {
return 'continue';
}
}
$emailwrapperStyle = $this->getVar( 'wgEnableEmail' ) ? '' : 'display: none';
$this->startForm();
$this->addHTML(
# User Rights
// getRadioSet() builds a set of labeled radio buttons.
// For grep: The following messages are used as the item labels:
// config-profile-wiki, config-profile-no-anon, config-profile-fishbowl, config-profile-private
$this->parent->getRadioSet( array(
'var' => '_RightsProfile',
'label' => 'config-profile',
'itemLabelPrefix' => 'config-profile-',
'values' => array_keys( $this->parent->rightsProfiles ),
) ) .
$this->parent->getInfoBox( wfMessage( 'config-profile-help' )->plain() ) .
# Licensing
// getRadioSet() builds a set of labeled radio buttons.
// For grep: The following messages are used as the item labels:
// config-license-cc-by, config-license-cc-by-sa, config-license-cc-by-nc-sa,
// config-license-cc-0, config-license-pd, config-license-gfdl,
// config-license-none, config-license-cc-choose
$this->parent->getRadioSet( array(
'var' => '_LicenseCode',
'label' => 'config-license',
'itemLabelPrefix' => 'config-license-',
'values' => array_keys( $this->parent->licenses ),
'commonAttribs' => array( 'class' => 'licenseRadio' ),
) ) .
$this->getCCChooser() .
$this->parent->getHelpBox( 'config-license-help' ) .
# E-mail
$this->getFieldSetStart( 'config-email-settings' ) .
$this->parent->getCheckBox( array(
'var' => 'wgEnableEmail',
'label' => 'config-enable-email',
'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'emailwrapper' ),
) ) .
$this->parent->getHelpBox( 'config-enable-email-help' ) .
"<div id=\"emailwrapper\" style=\"$emailwrapperStyle\">" .
$this->parent->getTextBox( array(
'var' => 'wgPasswordSender',
'label' => 'config-email-sender'
) ) .
$this->parent->getHelpBox( 'config-email-sender-help' ) .
$this->parent->getCheckBox( array(
'var' => 'wgEnableUserEmail',
'label' => 'config-email-user',
) ) .
$this->parent->getHelpBox( 'config-email-user-help' ) .
$this->parent->getCheckBox( array(
'var' => 'wgEnotifUserTalk',
'label' => 'config-email-usertalk',
) ) .
$this->parent->getHelpBox( 'config-email-usertalk-help' ) .
$this->parent->getCheckBox( array(
'var' => 'wgEnotifWatchlist',
'label' => 'config-email-watchlist',
) ) .
$this->parent->getHelpBox( 'config-email-watchlist-help' ) .
$this->parent->getCheckBox( array(
'var' => 'wgEmailAuthentication',
'label' => 'config-email-auth',
) ) .
$this->parent->getHelpBox( 'config-email-auth-help' ) .
"</div>" .
$this->getFieldSetEnd()
);
$extensions = $this->parent->findExtensions();
if ( $extensions ) {
$extHtml = $this->getFieldSetStart( 'config-extensions' );
/* Force a recache, so we load extensions descriptions */
global $wgLang;
$lc = Language::getLocalisationCache();
$lc->setInitialisedLanguages( array() );
$lc->getItem( $wgLang->mCode, '' );
LinkCache::singleton()->useDatabase( false );
foreach ( $extensions as $ext ) {
if ( isset( $ext['descriptionmsg'] ) ) {
$desc = wfMessage( $ext['descriptionmsg'] )->useDatabase( false )->parse();
} else {
$desc = '';
}
$extHtml .= $this->parent->getCheckBox( array(
'var' => "ext-{$ext['name']}",
'rawtext' => "<b>{$ext['name']}</b>: " .
//.........这里部分代码省略.........