Permalink
Browse files

Correctly search for overridden strings

Strings inside the module structure could not correctly be overridden before.

Now, the rules are as follows:

* CONTEXT_DIR/modules/*/*/lang/*.ini files are resolved as usual
* CONTEXT_DIR/lang/*.ini files are resolved as usual

Strings found via the first method always precede the latter.
The order of strings from different modules in the same CONTEXT_DIR is undefined (avoid conflicts at this level!).
The same same goes between different plugins.

E.g.: String resolving will thus be (top resolves first, bottom last):
/site/modules/page_type/journal/lang/en.ini
/plugins/journal/modules/page_type/journal/lang/en.ini
/base/modules/page_type/journal/lang/en.ini
/site/lang/en.ini
/plugins/journal/lang/en.ini
/base/lang/en.ini
  • Loading branch information...
sabberworm committed Oct 16, 2012
1 parent dc2e0ab commit 075f6c59077a6e3cb0494bedb0b2320b81fdc4f7
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/model/StringPeer.php
@@ -24,7 +24,7 @@ class StringPeer extends BaseStringPeer {
public static function getStaticStrings($sLanguageId) {
if(!isset(self::$STATIC_STRINGS[$sLanguageId])) {
$oCache = new Cache($sLanguageId, DIRNAME_LANG);
$aLanguageFiles = ResourceFinder::findAllResources(array(DIRNAME_LANG, "$sLanguageId.ini"), ResourceFinder::SEARCH_BASE_FIRST);
$aLanguageFiles = ResourceFinder::create()->addPath(DIRNAME_LANG, "$sLanguageId.ini")->all()->searchBaseFirst()->find();
if($oCache->cacheFileExists() && !$oCache->isOutdated($aLanguageFiles)) {
self::$STATIC_STRINGS[$sLanguageId] = $oCache->getContentsAsVariable();
} else {
@@ -36,7 +36,7 @@ public static function getStaticStrings($sLanguageId) {
}
//Get strings for modules
foreach(ResourceFinder::findResourcesByExpressions(array(DIRNAME_MODULES, ResourceFinder::ANY_NAME_OR_TYPE_PATTERN, ResourceFinder::ANY_NAME_OR_TYPE_PATTERN, DIRNAME_LANG, "$sLanguageId.ini"), ResourceFinder::SEARCH_SITE_FIRST) as $sLanguageFile) {
foreach(ResourceFinder::create()->addExpression(DIRNAME_MODULES, ResourceFinder::ANY_NAME_OR_TYPE_PATTERN, ResourceFinder::ANY_NAME_OR_TYPE_PATTERN, DIRNAME_LANG, "$sLanguageId.ini")->all()->searchBaseFirst()->find() as $sLanguageFile) {
self::$STATIC_STRINGS[$sLanguageId] = array_merge(self::$STATIC_STRINGS[$sLanguageId], parse_ini_file($sLanguageFile));
}

0 comments on commit 075f6c5

Please sign in to comment.