LRP-614 practice question 19 of 25

Language hooks cannot be used to add new language keys.

Full set: 144 questions
Answer options
A: True
B: False
Correct Answer:
FALSE
Explanation

The statement is false. While a primary use of language hooks is to override existing language keys in the Liferay portal, they can also be used to introduce entirely new language keys. When a language hook is deployed, its resource bundle files (e.g., Languageen.properties) are aggregated with the portal's default resource bundles. If a key defined in the hook's properties file does not exist in the portal's original files, it is effectively added to the set of available language keys. These new keys can then be referenced by custom portlets, themes, or other customizations.

Why Incorrect

The statement "True" is incorrect because it misrepresents the functionality of language hooks. The mechanism does not differentiate between overriding an existing key and adding a new one; it simply loads the key-value pairs from the hook's resource bundle, making them available to the portal's localization utility. This inherently allows for the addition of new keys.

References

1. Liferay Developer's Guide (for Liferay Portal 6.2): In the section on customizing language keys, the documentation explains the process of creating a language hook. It states, "Your new properties are added to the aggregate of all language properties." This confirms that new properties (keys) are added, not just used for overriding.

Source: Liferay, Inc. "Customizing Language Keys". Liferay Portal 6.2 Developer's Guide. Section: Customizing JSPs by Extending the Original.

Reference: This concept is detailed in the official Liferay training materials for LRP-614 and the developer documentation for Liferay 6.1 and 6.2. The core mechanism is that the hook's resource bundle is loaded and layered on top of the base bundle.

2. Official Liferay Documentation - Overriding Global Language Keys: This tutorial, while focused on overriding, describes the mechanism that also enables adding keys. It explains that you create a Language.properties file within your hook. The portal's LanguageUtil class will then consult the hook's bundle. If a key is requested that only exists in the hook's bundle, LanguageUtil will resolve it from there, demonstrating that new keys are supported.

Source: Liferay Learn. "Overriding Global Language Keys".

Reference: The tutorial demonstrates creating a hook with docroot/WEB-INF/src/content/Languageen.properties. Any key placed in this file, whether it matches an existing portal key or is entirely new, becomes part of the portal's available language resources upon deployment of the hook.

Scroll to Top