@Override // if there is no session then still pick a language public WOActionResults performActionNamed(String actionName) { if (!context().hasSession()) { ERXLocalizer localizer = ERXLocalizer.localizerForLanguages(context().request().browserLanguages()); ERXLocalizer.setCurrentLocalizer(localizer); } return super.performActionNamed(actionName); }
/** * Will dump all created keys of the current localizer via log4j and returns an empty response. * * @return empty response */ public WOActionResults dumpCreatedKeysAction() { if (ERXApplication.isDevelopmentModeSafe()) { session(); ERXLocalizer.currentLocalizer().dumpCreatedKeys(); return new ERXResponse(); } return null; }
public ERXKeyValuePair<String, String> selectedElement() { String value = anOperator(); String choice = (String) ERXLocalizer.currentLocalizer().valueForKey(value); if (choice == null) { choice = value; } return new ERXKeyValuePair<>(value, choice); }
/** * Calculates a localized display name for a given entity and key using the supplied localizer * * @param ecd class description the key belongs to * @param key to localize * @param localizer to use for localizing the content * @return the localized display name */ public static String localizedDisplayNameForKey( EOClassDescription ecd, String key, ERXLocalizer localizer) { String displayName; if (localizer != null) { if (ecd != null) { displayName = localizer.localizedDisplayNameForKey(ecd.entityName(), key); } else { displayName = localizer.localizedStringForKeyWithDefault(key); } } else { if (ecd != null) { displayName = ecd.displayNameForKey(key); } else { displayName = ERXStringUtilities.displayNameForKey(key); } } return displayName; }
/** * Formats the given entity name based on the rules of this format. * * @param entityName the entity name to format * @param pluralizeIfNecessary if pluralRouteNames() is true, return the plural form * @return the formatted entity name */ public String formatEntityNamed(String entityName, boolean pluralizeIfNecessary) { String singularEntityName = caseifyEntityNamed(entityName); if ((entityName == null) || (entityName.length() == 0)) { return singularEntityName; } String controllerPath; if (pluralizeIfNecessary && pluralRouteName()) { controllerPath = ERXLocalizer.englishLocalizer().plurifiedString(singularEntityName, 2); } else { controllerPath = singularEntityName; } return controllerPath; }
public NSArray<ERXKeyValuePair<String, String>> allQualifierOperators() { NSArray<String> operators = qualifierOperatorsOverrideFromRules() != null ? qualifierOperatorsOverrideFromRules() : _allQualifierOperators; int count = operators.count(); NSMutableArray<ERXKeyValuePair<String, String>> result = new NSMutableArray<ERXKeyValuePair<String, String>>(count); for (int i = 0; i < count; i++) { String currentOperatorString = operators.objectAtIndex(i); String value = (String) ERXLocalizer.currentLocalizer().valueForKey(currentOperatorString); if (value == null) { value = currentOperatorString; } result.addObject(new ERXKeyValuePair<>(currentOperatorString, value)); } return result; }
/** * Returns the default route controller class for the given entity name. * * @param entityName the name of the entity * @return the corresponding route controller */ public Class<? extends ERXRouteController> routeControllerClassForEntityNamed(String entityName) { String controllerName = entityName + "Controller"; Class<?> controllerClass = _NSUtilities.classWithName(controllerName); if (controllerClass == null) { String pluralControllerName = ERXLocalizer.englishLocalizer().plurifiedString(entityName, 2) + "Controller"; controllerClass = _NSUtilities.classWithName(pluralControllerName); if (controllerClass == null) { throw new IllegalArgumentException( "There is no controller named '" + controllerName + "' or '" + pluralControllerName + "'."); } } return controllerClass.asSubclass(ERXRouteController.class); }
public String currentDisplayString() { return (String) ERXLocalizer.currentLocalizer().valueForKeyPath("ERD2WQueryOperator." + currentOperator); }