Package io.jmix.aichat.component.chat
Class AiChatI18n
java.lang.Object
io.jmix.aichat.component.chat.AiChatI18n
- All Implemented Interfaces:
Serializable
Internationalization holder for
AiChat: the screen-reader
announcements the chat itself makes as a generation starts, completes, fails
or is stopped, plus the localization of the two components it composes.
Those two are the inner components' own holders, nested here rather than
restated: AiMessageInputI18n for the composer and
AiMessageListI18n (which in turn nests the code block's) for the
transcript. The chat's localization therefore mirrors the component tree it
builds, and a label added to an inner component reaches the chat without a
change here.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AiChatI18nfromMessages(Messages messages) Creates an instance with the chat's own announcements resolved from the message bundle (aiChat.i18n.*) and both nested holders from their own keys — the whole tree localized, which is whatAiChatapplies when it is created.@Nullable StringgetDone()@Nullable String@Nullable String@Nullable AiMessageInputI18n@Nullable AiMessageListI18n@Nullable StringSets the screen-reader (aria-live) announcement made when a response completes.Sets the screen-reader (aria-live) announcement made when generation fails.setGenerating(@Nullable String generating) Sets the screen-reader (aria-live) announcement made when generation starts.setMessageInput(@Nullable AiMessageInputI18n messageInput) Sets the localization of the composer.setMessageList(@Nullable AiMessageListI18n messageList) Sets the localization of the transcript, including — throughAiMessageListI18n.setCodeBlock(io.jmix.aichat.component.codeblock.AiCodeBlockI18n)— that of the code blocks rendered inside messages.setStopped(@Nullable String stopped) Sets the screen-reader (aria-live) announcement made when the user stops a generation.
-
Constructor Details
-
AiChatI18n
public AiChatI18n()
-
-
Method Details
-
fromMessages
Creates an instance with the chat's own announcements resolved from the message bundle (aiChat.i18n.*) and both nested holders from their own keys — the whole tree localized, which is whatAiChatapplies when it is created.- Parameters:
messages- the messages bean- Returns:
- a new localized instance
-
getGenerating
- Returns:
- the screen-reader announcement for the generating state, or
null
-
setGenerating
Sets the screen-reader (aria-live) announcement made when generation starts. Default whennull:"AI is processing the prompt".- Parameters:
generating- the announcement, ornullfor the default- Returns:
- this instance for chaining
-
getFailed
- Returns:
- the screen-reader announcement for the failed state, or
null
-
setFailed
Sets the screen-reader (aria-live) announcement made when generation fails. Default whennull:"Generation failed".- Parameters:
failed- the announcement, ornullfor the default- Returns:
- this instance for chaining
-
getDone
- Returns:
- the screen-reader announcement for the completed (idle) state, or
null
-
setDone
Sets the screen-reader (aria-live) announcement made when a response completes. Default whennull:"New message available".- Parameters:
done- the announcement, ornullfor the default- Returns:
- this instance for chaining
-
getStopped
- Returns:
- the screen-reader announcement for a cancelled generation, or
null
-
setStopped
Sets the screen-reader (aria-live) announcement made when the user stops a generation. Default whennull:"Generation stopped".- Parameters:
stopped- the announcement, ornullfor the default- Returns:
- this instance for chaining
-
getMessageInput
- Returns:
- the localization of the composer, or
null
-
setMessageInput
Sets the localization of the composer.AiChat.setI18n(AiChatI18n)hands it to the innerAiMessageInputas is, so anullfield there falls back to the client's hardcoded English rather than to the message bundle.- Parameters:
messageInput- the composer's localization, ornullto leave the composer alone- Returns:
- this instance for chaining
-
getMessageList
- Returns:
- the localization of the transcript, or
null
-
setMessageList
Sets the localization of the transcript, including — throughAiMessageListI18n.setCodeBlock(io.jmix.aichat.component.codeblock.AiCodeBlockI18n)— that of the code blocks rendered inside messages.AiChat.setI18n(AiChatI18n)hands it to the innerAiMessageListas is.- Parameters:
messageList- the transcript's localization, ornullto leave the list alone- Returns:
- this instance for chaining
-