From d306b4d52ad6d6d8b247c3ed2d5a831898d87908 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Roland=20H=C3=A4der?= <roland@mxchange.org>
Date: Thu, 12 Oct 2017 22:13:09 +0200
Subject: [PATCH] Please cherry-pick: - loading of both i18n (resource) bundles
 is now possible - departmentName has been transformed into departmentI18nKey
 to allow   localization of the department's name - also rewrote i18n key for
 entering department's i18n key - splitted header line and "enter bla" for
 department i18n key, was to long
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit

Signed-off-by: Roland Häder <roland@mxchange.org>
---
 .../jfinancials/beans/BaseFinancialsBean.java | 24 +++++++++----------
 ...nancialsAdminDepartmentWebRequestBean.java | 16 ++++++-------
 .../FinancialsWebRequestHelperBean.java       |  2 +-
 .../localization/bundle_de_DE.properties      |  8 ++++---
 .../localization/bundle_en_US.properties      |  6 ++---
 .../department/admin_form_department_data.tpl |  4 ++--
 .../department/admin_department_list.xhtml    |  4 ++--
 7 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/src/java/org/mxchange/jfinancials/beans/BaseFinancialsBean.java b/src/java/org/mxchange/jfinancials/beans/BaseFinancialsBean.java
index 97348929..e28f2bd5 100644
--- a/src/java/org/mxchange/jfinancials/beans/BaseFinancialsBean.java
+++ b/src/java/org/mxchange/jfinancials/beans/BaseFinancialsBean.java
@@ -27,11 +27,6 @@ import org.mxchange.jcoreee.bean.faces.BaseFacesBean;
  */
 public abstract class BaseFinancialsBean extends BaseFacesBean {
 
-	/**
-	 * Loaded resource bundle ("cached")
-	 */
-	private static ResourceBundle RESOURCE_BUNDLE;
-
 	/**
 	 * Serial number
 	 */
@@ -46,15 +41,18 @@ public abstract class BaseFinancialsBean extends BaseFacesBean {
 	}
 
 	@Override
-	protected ResourceBundle loadResourceBundle (final Locale locale) {
-		// Is the instance there?
-		if (null == RESOURCE_BUNDLE) {
-			// Load resource bundle, so it will be loaded from this JAR
-			RESOURCE_BUNDLE = ResourceBundle.getBundle("org.mxchange.localization.bundle", locale);
+	protected void loadResourceBundles (final Locale locale) {
+		// Is any locale loaded? (Will be 2)
+		if (BaseFacesBean.getBundles().isEmpty()) {
+			// Load resource bundles, so it will be loaded from this JAR"
+			// 1) Generic
+			ResourceBundle bundle = ResourceBundle.getBundle("org.mxchange.localization.bundle", locale);
+			BaseFacesBean.getBundles().add(bundle);
+
+			// 2) Project-specific
+			bundle = ResourceBundle.getBundle("org.mxchange.localization.project", locale);
+			BaseFacesBean.getBundles().add(bundle);
 		}
-
-		// Return cache instance
-		return RESOURCE_BUNDLE;
 	}
 
 }
diff --git a/src/java/org/mxchange/jfinancials/beans/business/department/FinancialsAdminDepartmentWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/business/department/FinancialsAdminDepartmentWebRequestBean.java
index a71d89b5..5d248a35 100644
--- a/src/java/org/mxchange/jfinancials/beans/business/department/FinancialsAdminDepartmentWebRequestBean.java
+++ b/src/java/org/mxchange/jfinancials/beans/business/department/FinancialsAdminDepartmentWebRequestBean.java
@@ -93,7 +93,7 @@ public class FinancialsAdminDepartmentWebRequestBean extends BaseFinancialsBean
 	/**
 	 * Department name
 	 */
-	private String departmentName;
+	private String departmentI18nKey;
 
 	/**
 	 * Owning user instance (which this department is assigned to)
@@ -134,7 +134,7 @@ public class FinancialsAdminDepartmentWebRequestBean extends BaseFinancialsBean
 			updatedDepartment = this.adminDepartmentBean.addDepartment(department);
 		} catch (final DepartmentAlreadyAddedException ex) {
 			// Output message
-			this.showFacesMessage("form-admin-add-department:departmentName", "ADMIN_DEPARTMENT_ALREADY_CREATED"); //NOI18N
+			this.showFacesMessage("form-admin-add-department:departmentI18nKey", "ADMIN_DEPARTMENT_ALREADY_CREATED"); //NOI18N
 			return ""; //NOI18N
 		}
 
@@ -222,17 +222,17 @@ public class FinancialsAdminDepartmentWebRequestBean extends BaseFinancialsBean
 	 * <p>
 	 * @return Department name
 	 */
-	public String getDepartmentName () {
-		return this.departmentName;
+	public String getDepartmentI18nKey () {
+		return this.departmentI18nKey;
 	}
 
 	/**
 	 * Setter for department name
 	 * <p>
-	 * @param departmentName Department name
+	 * @param departmentI18nKey Department name
 	 */
-	public void setDepartmentName (final String departmentName) {
-		this.departmentName = departmentName;
+	public void setDepartmentI18nKey (final String departmentI18nKey) {
+		this.departmentI18nKey = departmentI18nKey;
 	}
 
 	/**
@@ -262,7 +262,7 @@ public class FinancialsAdminDepartmentWebRequestBean extends BaseFinancialsBean
 	 */
 	private Department createDepartment () {
 		// Create new department instance
-		final Department department = new CompanyDepartment(this.getDepartmentCompany(), this.getDepartmentName());
+		final Department department = new CompanyDepartment(this.getDepartmentCompany(), this.getDepartmentI18nKey());
 
 		// Add all optional fields
 		department.setDepartmentHeadquarters(this.getDepartmentHeadquarters());
diff --git a/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelperBean.java b/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelperBean.java
index 912cb454..776b24a1 100644
--- a/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelperBean.java
+++ b/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelperBean.java
@@ -510,7 +510,7 @@ public class FinancialsWebRequestHelperBean extends BaseFinancialsBean implement
 		// Is a department set?
 		if (department instanceof Department) {
 			// Then create name
-			sb.append(department.getDepartmentName());
+			sb.append(this.getMessageFromBundle(department.getDepartmentI18nKey()));
 			sb.append(" ("); //NOI18N
 			sb.append(department.getDepartmentCompany().getCompanyName());
 			sb.append(")"); //NOI18N
diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties
index eeec7603..32313a5c 100644
--- a/src/java/org/mxchange/localization/bundle_de_DE.properties
+++ b/src/java/org/mxchange/localization/bundle_de_DE.properties
@@ -1026,21 +1026,23 @@ ADMIN_LINK_DELETE_DEPARTMENT_TITLE=Loescht die Abteilung
 #@TODO Please fix German umlauts!
 ADMIN_DEPARTMENT_ALREADY_CREATED=Die Abteilung existiert bereits im ausgewaehlten Unternehmen.
 ADMIN_LIST_DEPARTMENTS_HEADER=Alle Abteilungen auflisten
-ADMIN_DEPARTMENT_NAME=Abteilung:
+#@TODO Please fix German umlauts!
+ADMIN_DEPARTMENT_I18N_KEY=Sprachschluessel:
+ADMIN_ENTER_DEPARTMENT_I18N_KEY=Sprachschluessel fuer Abteilung:
 ADMIN_DEPARTMENT_LEAD_EMPLOYEE=Abteilungsleiter:
 ADMIN_ADD_DEPARTMENT_TITLE=Neue Abteilung hinzuf\u00fcgen
 ADMIN_DEPARTMENT_LEGEND=Daten der Abteilung eingeben:
 ADMIN_DEPARTMENT_LEGEND_TITLE=Geben Sie hier die Daten der Abteilung ein.
 #@TODO Please fix German umlauts!
 ADMIN_ADD_DEPARTMENT_MINIMUM_DATA=Bitte geben Sie mindestens den Namen der Abteilung (z.B. Verkauf) ein und waehlen Sie mindestens das Unternehmen aus. Wenn bekannt, waehlen Sie entweder eine Filiale oder eine Hauptniederlassung aus.
-ADMIN_ENTER_DEPARTMENT_NAME=Name der Abteilung eingeben:
 ADMIN_ASSIGN_DEPARTMENT_BRANCH_OFFICE=Filiale der Abteilung zuweisen:
 ADMIN_ASSIGN_DEPARTMENT_HEADQUARTERS=Hauptsitz der Abteilung zuweisen:
 ADMIN_ASSIGN_DEPARTMENT_COMPANY=Unternehmen der Abteilung zuweisen:
 ADMIN_ASSIGN_DEPARTMENT_LEAD_EMPLOYEE=Leitender Mitarbeiter der Abteilung zuweisen:
 ADMIN_ASSIGN_DEPARTMENT_USER_OWNER=Benutzer als Besitzer der Abteilung zuweisen:
 ADMIN_DEPARTMENT_COMPANY_REQUIRED=Bitte weisen Sie ein Unternehmen der Abteilung zu.
-ADMIN_DEPARTMENT_NAME_REQUIRED=Bitte geben Sie der Abteilung einen Namen. Zum Beispiel: Verkauf, Personalwesen
+#@TODO Please fix German umlauts!
+ADMIN_DEPARTMENT_I18N_KEY_REQUIRED=Bitte geben Sie den Sprachschluessel der Abteilung ein. Zum Beispiel: DEPARTMENT_NAME_SALES
 BUTTON_ADMIN_ADD_DEPARTMENT_DATA=Abteilung hinzuf\u00fcgen
 #@TODO Please fix German umlauts!
 PAGE_TITLE_ADMIN_LIST_OPENING_TIMES=Oeffnungszeiten auflisten
diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties
index ce3f66a4..b46c2c18 100644
--- a/src/java/org/mxchange/localization/bundle_en_US.properties
+++ b/src/java/org/mxchange/localization/bundle_en_US.properties
@@ -954,21 +954,21 @@ ADMIN_LINK_EDIT_DEPARTMENT_TITLE=Edit of a department
 ADMIN_LINK_DELETE_DEPARTMENT_TITLE=Deletes a department.
 ADMIN_DEPARTMENT_ALREADY_CREATED=The department already exists in selected company.
 ADMIN_LIST_DEPARTMENTS_HEADER=List all departments
-ADMIN_DEPARTMENT_NAME=Department:
+ADMIN_DEPARTMENT_I18N_KEY=I18n key:
+ADMIN_ENTER_DEPARTMENT_I18N_KEY=I18n key for department:
 ADMIN_DEPARTMENT_LEAD_EMPLOYEE=Department leader:
 ADMIN_ADD_DEPARTMENT_TITLE=Add new department
 ADMIN_DEPARTMENT_LEGEND=Enter data of department:
 ADMIN_DEPARTMENT_LEGEND_TITLE=Here you can enter data of the new department.
 #Bitte geben Sie mindestens den Namen der Abteilung (z.B. Verkauf) ein und waehlen Sie mindestens das Unternehmen aus. Wenn bekannt, waehlen Sie entweder eine Filiale oder eine Hauptniederlassung aus.
 ADMIN_ADD_DEPARTMENT_MINIMUM_DATA=Please enter at least name of department (e.g. Sales) and choose assigned company. If known, choose a branch office or headquarters.
-ADMIN_ENTER_DEPARTMENT_NAME=Enter name of department:
 ADMIN_ASSIGN_DEPARTMENT_BRANCH_OFFICE=Assign branch office to department:
 ADMIN_ASSIGN_DEPARTMENT_HEADQUARTERS=Assign headquarters to department:
 ADMIN_ASSIGN_DEPARTMENT_COMPANY=Assign company to department:
 ADMIN_ASSIGN_DEPARTMENT_LEAD_EMPLOYEE=Assign leading employee to department:
 ADMIN_ASSIGN_DEPARTMENT_USER_OWNER=Assign owning user to department:
 ADMIN_DEPARTMENT_COMPANY_REQUIRED=Please assign a company to this department.
-ADMIN_DEPARTMENT_NAME_REQUIRED=Please enter a name for the department. Examples: Sales, Human Resources
+ADMIN_DEPARTMENT_I18N_KEY_REQUIRED=Please enter an i18n key for the department. Example: DEPARTMENT_NAME_SALES
 BUTTON_ADMIN_ADD_DEPARTMENT_DATA=Add department
 PAGE_TITLE_ADMIN_LIST_OPENING_TIMES=List opening times
 CONTENT_TITLE_ADMIN_LIST_OPENING_TIMES=List opening times:
diff --git a/web/WEB-INF/templates/admin/department/admin_form_department_data.tpl b/web/WEB-INF/templates/admin/department/admin_form_department_data.tpl
index 838c2a91..e10b1957 100644
--- a/web/WEB-INF/templates/admin/department/admin_form_department_data.tpl
+++ b/web/WEB-INF/templates/admin/department/admin_form_department_data.tpl
@@ -12,8 +12,8 @@
 	-->
 	<p:fieldset legend="#{msg.ADMIN_DEPARTMENT_LEGEND}">
 		<p:panelGrid layout="grid" columns="2" columnClasses="ui-grid-col-4, ui-grid-col-8" styleClass="table table-full ui-noborder">
-			<p:outputLabel for="departmentName" value="#{msg.ADMIN_ENTER_DEPARTMENT_NAME}" />
-			<p:inputText styleClass="input" id="departmentName" size="2" maxlength="10" value="#{adminDepartmentController.departmentName}" required="true" requiredMessage="#{msg.ADMIN_DEPARTMENT_NAME_REQUIRED}" />
+			<p:outputLabel for="departmentI18nKey" value="#{msg.ADMIN_ENTER_DEPARTMENT_I18N_KEY}" />
+			<p:inputText styleClass="input" id="departmentI18nKey" size="2" maxlength="10" value="#{adminDepartmentController.departmentI18nKey}" required="true" requiredMessage="#{msg.ADMIN_DEPARTMENT_I18N_KEY_REQUIRED}" />
 
 			<p:outputLabel for="departmentCompany" value="#{msg.ADMIN_ASSIGN_DEPARTMENT_COMPANY}" />
 			<p:selectOneMenu
diff --git a/web/admin/department/admin_department_list.xhtml b/web/admin/department/admin_department_list.xhtml
index d131c45b..992a6acc 100644
--- a/web/admin/department/admin_department_list.xhtml
+++ b/web/admin/department/admin_department_list.xhtml
@@ -53,8 +53,8 @@
 					</p:link>
 				</p:column>
 
-				<p:column headerText="#{msg.ADMIN_DEPARTMENT_NAME}" sortBy="#{department.departmentName}" filterBy="#{department.departmentName}" filterMatchMode="contains">
-					<h:outputText value="#{department.departmentName}" />
+				<p:column headerText="#{msg.ADMIN_DEPARTMENT_I18N_KEY}" sortBy="#{department.departmentI18nKey}" filterBy="#{department.departmentI18nKey}" filterMatchMode="contains">
+					<h:outputText value="#{project[department.departmentI18nKey]}" />
 				</p:column>
 
 				<p:column headerText="#{msg.ADMIN_BASIC_COMPANY_DATA_COMPANY_NAME}" sortBy="#{department.departmentCompany}" filterBy="#{department.departmentCompany}" filterMatchMode="in">
-- 
2.39.5