Module locale

A properties bundle consists of multiple properties files that vary in the file name by an injection of a locale code before the file extension. Our convention is that each bundle must contain a properties file without injection. This file acts as a root for the bundle and as a fall-back for locales that are not found:

Examples:
code.properties:    The root and fall-back.
code_de.properties: The German member of the bundle.

The predicates get_properties/[2,3] allow retrieving a locale properties file of a resource bundle. These predicates make use of the predicate absolute_resource_name/2 to resolve the root so that the same base name without an extension can be used for both Prolog text and resource bundles. The predicates get_property/[3,4] allow retrieving a property value.

Examples:
:- sys_load_resource('code').
test(Y) :- get_properties('code',X), get_property(X,'foo',Y).
?- test(X).
X = bar

The resource bundle of a properties file has to be loaded in advanced via the predicate sys_load_resource/1 and will then be cached for faster subsequent access. The predicates get_error_properties/[1,2] allow retrieving a union of those properties files, which were registered via sys_register_file/1 in advance.

The predicate atom_format/[3,4] allows formatting a list of arguments based on a template and a locale. The predicates message_make/[3,4] allows formatting a term based on properties file and a locale. The predicates get_descr_model/[2,3] and get_descr_platform/[2,3] respective capability defined properties files.

The following locale predicates are provided:
get_properties(S, P):
get_properties(S, L, P):
The predicate unifies P with the properties from the bundle S for the current default locale. The ternary version of the predicate allows specifying the locale L.The resource bundle S has to be loaded in advance via sys_load_resource/1.
get_error_properties(P):
get_error_properties(L, P):
The predicate unifies P with the error properties of the knowledge base. The binary predicate allows specifying a locale L. The error resource bundles have to be loaded in advance via sys_load_resource/1 and registered via sys_register_file/1.
get_property(P, K, V):
get_property(P, K, D, V):
The predicate unifies V with the value for the key K from the properties P. The quaternary version of the predicate allows specifying a default value D.
atom_format(F, A, S):
atom_format(L, F, A, S):
The predicate formats the arguments A from the format F and unifies the result with S. The quaternary predicate allows specifying a locale L.
message_make(P, M, S):
message_make(L, P, M, S):
The predicate formats the message term M from the properties P and unifies the result with S. The quaternary predicate allows specifying a locale L.
get_descr_model(C, P):
get_descr_model(L, C, P):
The predicate unifies P with the model description properties of the given capability C. The ternary predicate allows specifying a locale L.
get_descr_platform(C, P):
get_descr_platform(L, C, P):
The predicate unifies P with the platform description properties of the given capability C. The ternary predicate allows specifying a locale L.

The following locale Prolog flags are provided:

sys_locale:
Legal values are atoms as return by the Java method Locale.toString(). The flag indicates the current default locale. The value can be changed by the end-user.

Kommentare