[icinga-checkins] icinga.org: icinga-web/master: * Added language switch support on TranslationManager level

git at icinga.org git at icinga.org
Tue May 25 13:28:18 CEST 2010


Module: icinga-web
Branch: master
Commit: 5e820b02684ba840ada253eef20a83e8f447822a
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=5e820b02684ba840ada253eef20a83e8f447822a

Author: jmosshammer <jmosshammer at ws-jmosshammer.(none)>
Date:   Fri May 21 16:25:33 2010 +0200

* Added language switch support on TranslationManager level

---

 app/config/factories.xml                           |    2 +-
 app/modules/AppKit/config.php                      |    3 +-
 app/modules/AppKit/config/autoload.xml             |    1 +
 .../AppKit/lib/auth/AppKitSecurityUser.class.php   |    2 +
 .../translator/AppKitGettextTranslator.class.php   |    1 +
 .../translator/AppKitTranslationManager.class.php  |   31 ++++++++++++++++++++
 etc/make/files.mk                                  |    5 +--
 7 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/app/config/factories.xml b/app/config/factories.xml
index 6743aa6..24baa2b 100755
--- a/app/config/factories.xml
+++ b/app/config/factories.xml
@@ -32,7 +32,7 @@
 			<ae:parameter name="gzip_level">6</ae:parameter>
 		</storage>
 		
-		<translation_manager class="AgaviTranslationManager" />
+		<translation_manager class="AppKitTranslationManager" />
 		
 		<user class="AppKitSecurityUser" />
 		
diff --git a/app/modules/AppKit/config.php b/app/modules/AppKit/config.php
index a380f36..c65cd09 100755
--- a/app/modules/AppKit/config.php
+++ b/app/modules/AppKit/config.php
@@ -1,3 +1,4 @@
 <?php 
 	// Just a placeholder
-?>
+
+	?>
diff --git a/app/modules/AppKit/config/autoload.xml b/app/modules/AppKit/config/autoload.xml
index e7faaf9..c92afe2 100755
--- a/app/modules/AppKit/config/autoload.xml
+++ b/app/modules/AppKit/config/autoload.xml
@@ -68,6 +68,7 @@
 		<autoload name="AppKitNavItem">%core.module_dir%/AppKit/lib/menu/AppKitNavItem.class.php</autoload>
 		<autoload name="AppKitDoctrineSessionStorage">%core.module_dir%/AppKit/lib/storage/AppKitDoctrineSessionStorage.class.php</autoload>
 		<autoload name="AppKitGettextTranslator">%core.module_dir%/AppKit/lib/translator/AppKitGettextTranslator.class.php</autoload>
+		<autoload name="AppKitTranslationManager">%core.module_dir%/AppKit/lib/translator/AppKitTranslationManager.class.php</autoload>
 		<autoload name="AppKitArrayUtil">%core.module_dir%/AppKit/lib/util/AppKitArrayUtil.class.php</autoload>
 		<autoload name="AppKitClassUtil">%core.module_dir%/AppKit/lib/util/AppKitClassUtil.class.php</autoload>
 		<autoload name="AppKitColorUtil">%core.module_dir%/AppKit/lib/util/AppKitColorUtil.class.php</autoload>
diff --git a/app/modules/AppKit/lib/auth/AppKitSecurityUser.class.php b/app/modules/AppKit/lib/auth/AppKitSecurityUser.class.php
index 258bdf6..c9179b3 100755
--- a/app/modules/AppKit/lib/auth/AppKitSecurityUser.class.php
+++ b/app/modules/AppKit/lib/auth/AppKitSecurityUser.class.php
@@ -186,6 +186,8 @@ class AppKitSecurityUser extends AgaviRbacSecurityUser {
 			parent::loadDefinitions();
 		
 	}
+
+	
 }
 
 class AppKitSecurityUserException extends AppKitException {}
diff --git a/app/modules/AppKit/lib/translator/AppKitGettextTranslator.class.php b/app/modules/AppKit/lib/translator/AppKitGettextTranslator.class.php
index 327ed2e..df27ff7 100755
--- a/app/modules/AppKit/lib/translator/AppKitGettextTranslator.class.php
+++ b/app/modules/AppKit/lib/translator/AppKitGettextTranslator.class.php
@@ -1,6 +1,7 @@
 <?php
 
 class AppKitGettextTranslator extends AgaviGettextTranslator {
+
 	
 	public function getDomainPaths() {
 		return $this->domainPaths;
diff --git a/app/modules/AppKit/lib/translator/AppKitTranslationManager.class.php b/app/modules/AppKit/lib/translator/AppKitTranslationManager.class.php
new file mode 100644
index 0000000..800553a
--- /dev/null
+++ b/app/modules/AppKit/lib/translator/AppKitTranslationManager.class.php
@@ -0,0 +1,31 @@
+<?php
+
+
+class AppKitTranslationManager extends AgaviTranslationManager {
+	private $__localeLoaded = false;
+	
+	public function loadCurrentLocale() {
+		if($this->__localeLoaded) {
+			return parent::loadCurrentLocale();
+		}
+		$user = $this->getContext()->getUser();
+		if(!$user || !($user instanceof AppKitSecurityUser))
+			return null;
+		try { 
+
+				$dbUser = $user->getNsmUser(true);
+
+				$translation = $this->getContext()->getTranslationManager();
+				if($dbUser instanceof NsmUser) {
+					$langDomain = $dbUser->getPrefVal("de.icinga.appkit.locale");
+					if($langDomain)
+						$translation->setLocale($langDomain);
+				}
+			
+		} catch(Exception $e) {
+			// ignore
+		}
+		$this->__localeLoaded = true;
+		parent::loadCurrentLocale();
+	}
+}
\ No newline at end of file
diff --git a/etc/make/files.mk b/etc/make/files.mk
index eb5d591..0538582 100755
--- a/etc/make/files.mk
+++ b/etc/make/files.mk
@@ -16,8 +16,6 @@ inc-install-files:
 	$(INSTALL) -m 644 $(INSTALL_OPTS) app/config/logging.xml $(DESTDIR)$(prefix)/app/config/logging.xml
 	$(INSTALL) -m 644 $(INSTALL_OPTS) app/config/output_types.xml $(DESTDIR)$(prefix)/app/config/output_types.xml
 	$(INSTALL) -m 644 $(INSTALL_OPTS) app/config.php $(DESTDIR)$(prefix)/app/config.php
-	$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(prefix)/app/config/plugins
-	$(INSTALL) -m 644 $(INSTALL_OPTS) app/config/plugins/Heatmap.xml $(DESTDIR)$(prefix)/app/config/plugins/Heatmap.xml
 	$(INSTALL) -m 644 $(INSTALL_OPTS) app/config/rbac_definitions.xml $(DESTDIR)$(prefix)/app/config/rbac_definitions.xml
 	$(INSTALL) -m 644 $(INSTALL_OPTS) app/config/routing.xml $(DESTDIR)$(prefix)/app/config/routing.xml
 	$(INSTALL) -m 644 $(INSTALL_OPTS) app/config/schedules.xml $(DESTDIR)$(prefix)/app/config/schedules.xml
@@ -202,6 +200,7 @@ inc-install-files:
 	$(INSTALL) -m 644 $(INSTALL_OPTS) app/modules/AppKit/lib/storage/AppKitDoctrineSessionStorage.class.php $(DESTDIR)$(prefix)/app/modules/AppKit/lib/storage/AppKitDoctrineSessionStorage.class.php
 	$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(prefix)/app/modules/AppKit/lib/translator
 	$(INSTALL) -m 644 $(INSTALL_OPTS) app/modules/AppKit/lib/translator/AppKitGettextTranslator.class.php $(DESTDIR)$(prefix)/app/modules/AppKit/lib/translator/AppKitGettextTranslator.class.php
+	$(INSTALL) -m 644 $(INSTALL_OPTS) app/modules/AppKit/lib/translator/AppKitTranslationManager.class.php $(DESTDIR)$(prefix)/app/modules/AppKit/lib/translator/AppKitTranslationManager.class.php
 	$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(prefix)/app/modules/AppKit/lib/util
 	$(INSTALL) -m 644 $(INSTALL_OPTS) app/modules/AppKit/lib/util/AppKitArrayUtil.class.php $(DESTDIR)$(prefix)/app/modules/AppKit/lib/util/AppKitArrayUtil.class.php
 	$(INSTALL) -m 644 $(INSTALL_OPTS) app/modules/AppKit/lib/util/AppKitClassUtil.class.php $(DESTDIR)$(prefix)/app/modules/AppKit/lib/util/AppKitClassUtil.class.php
@@ -7640,5 +7639,5 @@ inc-install-files:
 	$(INSTALL) -m 644 $(INSTALL_OPTS) pub/styles/WireFrameStructural.css $(DESTDIR)$(prefix)/pub/styles/WireFrameStructural.css
 	$(INSTALL) -m 644 $(INSTALL_OPTS) pub/styles/WireFrameYUI.css $(DESTDIR)$(prefix)/pub/styles/WireFrameYUI.css
 INC_FILES=6718
-INC_DIRS=920
+INC_DIRS=919
 # INSTALL_FILES_END





More information about the icinga-checkins mailing list