Skip to content
This repository
Browse code

MINOR Hardcoding correct module priorities in i18n.php

  • Loading branch information...
commit 3002598a5e47284d3e077bac4a8a7b04cf77185f 1 parent 9e95ba0
Ingo Schommer authored April 13, 2012

Showing 1 changed file with 14 additions and 1 deletion. Show diff stats Hide diff stats

  1. 15  i18n/i18n.php
15  i18n/i18n.php
@@ -1876,12 +1876,25 @@ static function include_by_locale($locale) {
1876 1876
 		// TODO Also include custom Zend_Translate routing languages
1877 1877
 		$selectedLocales = array_unique(array($lang, $locale));
1878 1878
 
  1879
+		// Sort modules by inclusion priority, then alphabetically
  1880
+		// TODO Should be handled by priority flags within modules
  1881
+		$prios = array('sapphire' => 10, 'framework' => 10, 'admin' => 11, 'cms' => 12, 'mysite' => 90);
  1882
+		$modules = SS_ClassLoader::instance()->getManifest()->getModules();
  1883
+		ksort($modules);
  1884
+		uksort(
  1885
+			$modules,
  1886
+			function($a, $b) use(&$prios) {
  1887
+				$prioA = (isset($prios[$a])) ? $prios[$a] : 50;
  1888
+				$prioB = (isset($prios[$b])) ? $prios[$b] : 50;
  1889
+				return ($prioA > $prioB);
  1890
+			}
  1891
+		);
  1892
+
1879 1893
 		// Loop in reverse order, meaning the translator with the highest priority goes first
1880 1894
 		$translators = array_reverse(self::get_translators(), true);
1881 1895
 		foreach($translators as $priority => $translators) {
1882 1896
 			foreach($translators as $name => $translator) {
1883 1897
 				$adapter = $translator->getAdapter();
1884  
-				$modules = SS_ClassLoader::instance()->getManifest()->getModules();
1885 1898
 
1886 1899
 				// Load translations from modules
1887 1900
 				foreach($modules as $module) {

0 notes on commit 3002598

Please sign in to comment.
Something went wrong with that request. Please try again.