本文整理匯總了PHP中ModuleInstaller::rebuild_languages方法的典型用法代碼示例。如果您正苦於以下問題:PHP ModuleInstaller::rebuild_languages方法的具體用法?PHP ModuleInstaller::rebuild_languages怎麽用?PHP ModuleInstaller::rebuild_languages使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ModuleInstaller
的用法示例。
在下文中一共展示了ModuleInstaller::rebuild_languages方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: run
/**
* Workflow: Check module builder modules for "moduleList" and "moduleListSingular"
* labels and translations. Create or append fixed content to package
* language file to make it compatible with Studio or ModuleBuilder for future changes
*/
public function run()
{
if (empty($this->upgrader->state['MBModules'])) {
// No MB modules - nothing to do
return;
}
$app_list_strings = return_app_list_strings_language("en_us");
$changes = array();
$packages = $this->getPackages();
foreach ($this->upgrader->state['MBModules'] as $MBModule) {
// All custom modules will have package key in module name
$keys = explode('_', $MBModule);
$packageKey = $keys[0];
if (!isset($packages[$packageKey])) {
$this->upgrader->log('FixSingularList: can\'t find package for module: key - ' . $packageKey . '. Script will use current key as package name');
$packages[$packageKey] = $packageKey;
}
$changes[$packageKey] = isset($changes[$packageKey]) ? $changes[$packageKey] : array();
// Try to add custom module to moduleList
if (!isset($app_list_strings['moduleList'][$MBModule])) {
$langFile = $this->getLanguageFilePath($MBModule);
if (file_exists($langFile)) {
$mod_strings = array();
require $langFile;
$moduleName = isset($mod_strings['LBL_MODULE_NAME']) ? $mod_strings['LBL_MODULE_NAME'] : false;
if ($moduleName) {
$app_list_strings['moduleList'][$MBModule] = $moduleName;
$changes[$packageKey]['moduleList'][$MBModule] = $moduleName;
} else {
$this->upgrader->log('FixSingularList: warning - module ' . $MBModule . ' do not have module name translation');
}
}
}
if (!isset($app_list_strings['moduleListSingular'][$MBModule]) && !empty($app_list_strings['moduleList'][$MBModule])) {
$changes[$packageKey]['moduleListSingular'][$MBModule] = $app_list_strings['moduleList'][$MBModule];
}
}
$rebuildLang = false;
foreach ($changes as $packageKey => $content) {
// if no changes - continue
if (empty($content)) {
continue;
}
$packageName = $packages[$packageKey];
$fileName = $this->getPackageLangFile($packageName);
$values = $this->mergeCustomTranslations($fileName, $content);
$header = file_get_contents('modules/ModuleBuilder/MB/header.php');
$file = $header;
foreach ($values as $key => $array) {
$file .= override_value_to_string_recursive2('app_list_strings', $key, $array);
}
$this->upgrader->putFile($fileName, $file);
$rebuildLang = true;
}
if ($rebuildLang) {
$mi = new ModuleInstaller();
$mi->silent = true;
$mi->rebuild_languages(array('en_us' => 'en_us'));
}
}
示例2: rebuildLanguages
/**
* Rebuild changes languages for module
*
* @param $languages
* @param $module
*/
protected function rebuildLanguages($languages, $module)
{
if (!$this->mi) {
$this->mi = new ModuleInstaller();
$this->mi->silent = true;
}
$this->mi->rebuild_languages($languages, array($module));
}
示例3: rebuildLanguageExtensions
/**
* Rebuilds extensions and language files for this language and module
*
* @param string $language The language to rebuild extensions for
* @param string $moduleName The name of the module whose extensions are being rebuilt
*/
protected static function rebuildLanguageExtensions($language, $moduleName)
{
if (empty(self::$moduleInstaller)) {
self::$moduleInstaller = new ModuleInstaller();
self::$moduleInstaller->silent = true;
}
self::$moduleInstaller->rebuild_extensions(array($moduleName), array('languages'));
// While this *is* called from rebuild_extensions, it doesn't do anything
// there because there is no language or module provided to it. This fixes
// that.
self::$moduleInstaller->rebuild_languages(array($language => $language), array($moduleName));
}
示例4: finalize
/**
* Clears the js cache and rebuilds the language files
*
* @param string $lang - language to be rebuilt, and cache cleared
*/
public function finalize($lang)
{
$mi = new ModuleInstaller();
$mi->silent = true;
$mi->rebuild_languages(array($lang => $lang));
sugar_cache_reset();
sugar_cache_reset_full();
clearAllJsAndJsLangFilesWithoutOutput();
// Clear out the api metadata languages cache for selected language
MetaDataManager::refreshLanguagesCache($lang);
}