2:- module(text, [ 3 text/2, 4 text_languages_found/2, 5 text_languages_details/2]). 6 7text_language(pt). 8 9text(TextKey, Text) :- 10 text_language(TextLanguage), 11 insert_text(TextKey, TextLanguage, Text). 12 13insert_text("saudation", pt, 14 "Ola, eu conheco diversas linguagens de programaƧao. Posso te ajudar a escolher a mais adequada para voce."). 15 16insert_text("area_interest", pt, "Qual area voce tem interesse?"). 17 18insert_text("paradigm", pt, "E qual paradigma de programaƧao voce prefere?"). 19 20insert_text("type-system", pt, "Como eh o sistema de tipos mais adequada?"). 21 22insert_text("languages_found", pt, "As linguagens encontradas foram: "). 23 24insert_text("choose_language", pt, "Qual delas voce quer saber mais? "). 25 26insert_text("not_found", pt, "Nao foi encontrado linguagens com essas propriedades."). 27 28insert_text("want_try_another", pt, "Posso te apresentar outra linguagem. Tem interesse?"). 29 30insert_text("bye", pt, "Ate logo!"). 31 32insert_text("source", pt, "Fonte: "). 33 34insert_text("homepage", pt, "Pagina oficial: "). 35 36text_languages_found([], ""). 37text_languages_found(Languages, TextFormated) :- 38 length(Languages, NumberOfLanguagesFound), 39 NumberOfLanguagesFound > 0, 40 convert_languages_to_string(Languages, LanguagesFormated), 41 text("languages_found", LanguagesFoundText), 42 text("choose_language", ChooseText), 43 atom_concat( 44 LanguagesFoundText, LanguagesFormated, LanguagesFoudFormated), 45 atom_concat(LanguagesFoudFormated, ChooseText, TextFormated). 46 47convert_languages_to_string([], "\n"). 48convert_languages_to_string(Languages, TextFormated) :- 49 [Language | Rest ] = Languages, 50 convert_languages_to_string(Rest, RestItens), 51 language(Name, _, _, _, _, _, _) = Language, 52 atom_concat("\n - ", Name, Item), 53 atom_concat(Item, RestItens, TextFormated). 54 55text_languages_details(Language, TextFormated) :- 56 language(_, Source, About, _, _, _, Site) = Language, 57 text_about(About, AboutFormated), 58 text_site(Site, SiteFormated), 59 text_source(Source, SourceFormated), 60 atom_concat(AboutFormated, SourceFormated, AboutAndSource), 61 atom_concat(AboutAndSource, SiteFormated, TextFormated). 62 63text_about('', ''). 64text_about(About, AboutFormated) :- 65 atom_concat(About, '\n', AboutFormated). 66 67text_site('', ''). 68text_site(Site, SiteFormated) :- 69 text("homepage", HomeText), 70 atom_concat(HomeText, Site, SiteText), 71 atom_concat(SiteText, '\n', SiteFormated). 72 73text_source('', ''). 74text_source(Source, SourceFormated) :- 75 text("source", SourceText), 76 atom_concat(SourceText, Source, SourceLinkText), 77 atom_concat(SourceLinkText, '\n', SourceFormated)