Imagine I have the following predicate, which states that the ID loc1
designates a location.
isLocation('loc1', 'Location 1').
I want to provide translations for the second text (Location 1
), i. e. key-value pairs such as en='Location 1', de='Ort 1', ru='Местоположение 1'
.
What is the correct way to encode such data in Prolog, especially TuProlog (and ideally - standardized Prolog) ?
Would the notation below work outside SWI Prolog?
isLocation('loc1', ['en'-'Location 1', 'de'-'Ort 1', 'ru'-'Местоположение 1']]).
the easiest way, working in any Prolog, uses member/2 to retrieve key-value pairs. For instance
l10n(MessageId, Country, Translated) :-
isLocation(MessageId, Localized),
member(Country-Translated, Localized).
Such basic construct would need of course several improvements, depending on requirements.