Package io.github.jbastgen.stemma.app.ai
Class MessageTranslator
java.lang.Object
io.github.jbastgen.stemma.app.ai.MessageTranslator
Translation of commit messages with the AI (feature 7): the prompt, and reading the answer back into one text per commit.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordOne message to translate. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic StringbuildPrompt(String template, String language, List<MessageTranslator.Message> messages) Fills the template:{language}and{messages}.static StringbuildPrompt(String template, String language, List<String> skip, List<MessageTranslator.Message> messages) As above, and{skip}is the list of languages whose messages are left alone.static StringdefaultSkipLanguages(String languageSetting) The languages that are not translated until the user chooses: English and the language of the interface (for the settinglanguage, which may be empty orsystemfor the language of the system).static StringenglishName(String code) The English name of the language of the interface (a code ofi18n/languages.tsv), as the prompt names languages.static Stringnumbered(List<MessageTranslator.Message> messages) The messages, each under a line### n, so that the answer can be split again.Splits the answer into one text per message.skipLanguages(String setting) The languages of the setting (names separated by commas, semicolons or line breaks), without blanks and duplicates.
-
Field Details
-
TEMPLATE_NAME
- See Also:
-
LANGUAGES
Languages Stemma knows, with the English name used in the prompt; any other name can be typed. -
UNCHANGED
What the AI writes instead of a translation for a message that is in one of the languages that are not translated.- See Also:
-
-
Method Details
-
numbered
The messages, each under a line### n, so that the answer can be split again. -
englishName
The English name of the language of the interface (a code ofi18n/languages.tsv), as the prompt names languages. -
defaultSkipLanguages
The languages that are not translated until the user chooses: English and the language of the interface (for the settinglanguage, which may be empty orsystemfor the language of the system). -
skipLanguages
The languages of the setting (names separated by commas, semicolons or line breaks), without blanks and duplicates. -
buildPrompt
public static String buildPrompt(String template, String language, List<MessageTranslator.Message> messages) Fills the template:{language}and{messages}. Only the messages are sent, nothing of the changes. -
buildPrompt
public static String buildPrompt(String template, String language, List<String> skip, List<MessageTranslator.Message> messages) As above, and{skip}is the list of languages whose messages are left alone. A template of the user without{skip}gets the instruction appended, so the setting works with it as well. -
parse
Splits the answer into one text per message. An answer without the###lines is taken as the translation of a single message; if there are several messages and the marks are missing, nothing can be told apart and the result is empty.
-