lofwyr14 commented on code in PR #7754:
URL: https://github.com/apache/myfaces-tobago/pull/7754#discussion_r4391496807
##########
tobago-core/src/main/java/org/apache/myfaces/tobago/util/ResourceUtils.java:
##########
@@ -21,39 +21,47 @@
import jakarta.faces.application.Application;
import jakarta.faces.context.FacesContext;
-
+import java.util.Locale;
import java.util.ResourceBundle;
public class ResourceUtils {
public static final String TOBAGO_RESOURCE_BUNDLE = "tobagoResourceBundle";
+ private static final String TOBAGO_RESOURCE_BUNDLE_BASE_NAME =
+ "org.apache.myfaces.tobago.context.TobagoResourceBundle";
public static String getString(final String key) {
- final FacesContext facesContext = FacesContext.getCurrentInstance();
- final Application application = facesContext.getApplication();
- final ResourceBundle resourceBundle =
application.getResourceBundle(facesContext, TOBAGO_RESOURCE_BUNDLE);
- return resourceBundle.getString(key);
+ return getString(TOBAGO_RESOURCE_BUNDLE, key);
}
public static String getString(final FacesContext facesContext, final String
key) {
- return facesContext.getApplication().getResourceBundle(facesContext,
TOBAGO_RESOURCE_BUNDLE).getString(key);
+ return getString(facesContext, TOBAGO_RESOURCE_BUNDLE, key);
}
public static String getString(final FacesContext facesContext, final
Application application, final String key) {
- return application.getResourceBundle(facesContext,
TOBAGO_RESOURCE_BUNDLE).getString(key);
+ return getString(facesContext, application, TOBAGO_RESOURCE_BUNDLE, key);
}
public static String getString(final String bundle, final String key) {
final FacesContext facesContext = FacesContext.getCurrentInstance();
- return facesContext.getApplication().getResourceBundle(facesContext,
bundle).getString(key);
+ return getString(facesContext, bundle, key);
}
public static String getString(final FacesContext facesContext, final String
bundle, final String key) {
- return facesContext.getApplication().getResourceBundle(facesContext,
bundle).getString(key);
+ return getString(facesContext, facesContext.getApplication(), bundle, key);
}
public static String getString(
final FacesContext facesContext, final Application application, final
String bundle, final String key) {
- return application.getResourceBundle(facesContext, bundle).getString(key);
+ final ResourceBundle resourceBundle =
application.getResourceBundle(facesContext, bundle);
+
+ if (TOBAGO_RESOURCE_BUNDLE.equals(bundle) &&
!resourceBundle.containsKey(key)) {
Review Comment:
Kleine stilistische Anmerkung:
ich würde hier den Ablauf der Logik andersherum sehen:
Wenn ich das gefunden habe, dann nimm den wert, andernfalls auch im default.
Jetzt wenn ich es nicht finde, nimm den default (und kommt das naheliegende
erst relativ spät.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]