Skip to content

Commit

Permalink
Chat: Add localization
Browse files Browse the repository at this point in the history
  • Loading branch information
marker-dao authored Oct 2, 2024
1 parent 1ad04f0 commit 545925c
Show file tree
Hide file tree
Showing 32 changed files with 199 additions and 6 deletions.
3 changes: 2 additions & 1 deletion packages/devextreme/js/__internal/ui/chat/avatar.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { dxElementWrapper } from '@js/core/renderer';
import $ from '@js/core/renderer';
import { isDefined } from '@js/core/utils/type';
import messageLocalization from '@js/localization/message';
import type { WidgetOptions } from '@js/ui/widget/ui.widget';
import type { OptionChanged } from '@ts/core/widget/types';
import Widget from '@ts/core/widget/widget';
Expand Down Expand Up @@ -84,7 +85,7 @@ class Avatar extends Widget<Properties> {
const { name } = this.option();

// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
this._$content?.attr('alt', name || 'Avatar');
this._$content?.attr('alt', name || messageLocalization.format('dxAvatar-defaultImageAlt'));
}

_isValuableUrl(): boolean {
Expand Down
3 changes: 2 additions & 1 deletion packages/devextreme/js/__internal/ui/chat/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import $ from '@js/core/renderer';
import { isDefined } from '@js/core/utils/type';
import type { Options as DataSourceOptions } from '@js/data/data_source';
import DataHelperMixin from '@js/data_helper';
import messageLocalization from '@js/localization/message';
import type { Message, MessageSendEvent, Properties as ChatProperties } from '@js/ui/chat';
import type { OptionChanged } from '@ts/core/widget/types';
import Widget from '@ts/core/widget/widget';
Expand Down Expand Up @@ -136,7 +137,7 @@ class Chat extends Widget<Properties> {
_updateRootAria(): void {
const aria = {
role: 'group',
label: 'Chat',
label: messageLocalization.format('dxChat-elementAriaLabel'),
};

this.setAria(aria, this.$element());
Expand Down
5 changes: 3 additions & 2 deletions packages/devextreme/js/__internal/ui/chat/messagebox.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import $ from '@js/core/renderer';
import type { NativeEventInfo } from '@js/events';
import messageLocalization from '@js/localization/message';
import type { ClickEvent } from '@js/ui/button';
import Button from '@js/ui/button';
import type { Properties as DOMComponentProperties } from '@ts/core/widget/dom_component';
Expand Down Expand Up @@ -76,7 +77,7 @@ class MessageBox extends DOMComponent<MessageBox, Properties> {
focusStateEnabled,
hoverStateEnabled,
stylingMode: 'outlined',
placeholder: 'Type a message',
placeholder: messageLocalization.format('dxChat-textareaPlaceholder'),
autoResizeEnabled: true,
valueChangeEvent: 'input',
maxHeight: '8em',
Expand Down Expand Up @@ -118,7 +119,7 @@ class MessageBox extends DOMComponent<MessageBox, Properties> {
type: 'default',
stylingMode: 'text',
disabled: true,
elementAttr: { 'aria-label': 'Send' },
elementAttr: { 'aria-label': messageLocalization.format('dxChat-sendButtonAriaLabel') },
onClick: (e): void => {
this._sendHandler(e);
},
Expand Down
3 changes: 2 additions & 1 deletion packages/devextreme/js/__internal/ui/chat/messagegroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { dxElementWrapper } from '@js/core/renderer';
import $ from '@js/core/renderer';
import dateSerialization from '@js/core/utils/date_serialization';
import { isDefined } from '@js/core/utils/type';
import messageLocalization from '@js/localization/message';
import type { Message } from '@js/ui/chat';
import type { WidgetOptions } from '@js/ui/widget/ui.widget';
import type { OptionChanged } from '@ts/core/widget/types';
Expand Down Expand Up @@ -116,7 +117,7 @@ class MessageGroup extends Widget<Properties> {
const $information = $('<div>')
.addClass(CHAT_MESSAGEGROUP_INFORMATION_CLASS);

const authorName = author?.name ?? 'Unknown User';
const authorName = author?.name ?? messageLocalization.format('dxChat-defaultUserName');
const authorNameText = alignment === 'start' ? authorName : '';

$('<div>')
Expand Down
2 changes: 1 addition & 1 deletion packages/devextreme/js/__internal/ui/chat/messagelist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ class MessageList extends Widget<Properties> {
const aria = {
role: 'log',
atomic: 'false',
label: 'Message list',
label: messageLocalization.format('dxChat-messageListAriaLabel'),
live: 'polite',
relevant: 'additions',
};
Expand Down
7 changes: 7 additions & 0 deletions packages/devextreme/js/localization/messages/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@
"dxCalendar-selectedDateRangeCount": "There are {0} selected date ranges",
"dxCalendar-readOnlyLabel": "Read-only calendar",

"dxAvatar-defaultImageAlt": "Avatar",

"dxChat-elementAriaLabel": "Chat",
"dxChat-textareaPlaceholder": "Type a message",
"dxChat-sendButtonAriaLabel": "Send",
"dxChat-defaultUserName": "Unknown User",
"dxChat-messageListAriaLabel": "Message list",
"dxChat-emptyListMessage": "There are no messages in this chat",
"dxChat-emptyListPrompt": "Write your first message",

Expand Down
7 changes: 7 additions & 0 deletions packages/devextreme/js/localization/messages/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@
"dxCalendar-selectedDateRangeCount": "There are {0} selected date ranges",
"dxCalendar-readOnlyLabel": "Read-only calendar",

"dxAvatar-defaultImageAlt": "Avatar",

"dxChat-elementAriaLabel": "Chat",
"dxChat-textareaPlaceholder": "Type a message",
"dxChat-sendButtonAriaLabel": "Send",
"dxChat-defaultUserName": "Unknown User",
"dxChat-messageListAriaLabel": "Message list",
"dxChat-emptyListMessage": "There are no messages in this chat",
"dxChat-emptyListPrompt": "Write your first message",

Expand Down
7 changes: 7 additions & 0 deletions packages/devextreme/js/localization/messages/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@
"dxCalendar-selectedDateRangeCount": "There are {0} selected date ranges",
"dxCalendar-readOnlyLabel": "Read-only calendar",

"dxAvatar-defaultImageAlt": "Avatar",

"dxChat-elementAriaLabel": "Chat",
"dxChat-textareaPlaceholder": "Type a message",
"dxChat-sendButtonAriaLabel": "Send",
"dxChat-defaultUserName": "Unknown User",
"dxChat-messageListAriaLabel": "Message list",
"dxChat-emptyListMessage": "There are no messages in this chat",
"dxChat-emptyListPrompt": "Write your first message",

Expand Down
7 changes: 7 additions & 0 deletions packages/devextreme/js/localization/messages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@
"dxCalendar-selectedDateRangeCount": "There are {0} selected date ranges",
"dxCalendar-readOnlyLabel": "Read-only calendar",

"dxAvatar-defaultImageAlt": "Avatar",

"dxChat-elementAriaLabel": "Chat",
"dxChat-textareaPlaceholder": "Type a message",
"dxChat-sendButtonAriaLabel": "Send",
"dxChat-defaultUserName": "Unknown User",
"dxChat-messageListAriaLabel": "Message list",
"dxChat-emptyListMessage": "There are no messages in this chat",
"dxChat-emptyListPrompt": "Write your first message",

Expand Down
7 changes: 7 additions & 0 deletions packages/devextreme/js/localization/messages/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@
"dxCalendar-selectedDateRangeCount": "There are {0} selected date ranges",
"dxCalendar-readOnlyLabel": "Read-only calendar",

"dxAvatar-defaultImageAlt": "Avatar",

"dxChat-elementAriaLabel": "Chat",
"dxChat-textareaPlaceholder": "Type a message",
"dxChat-sendButtonAriaLabel": "Send",
"dxChat-defaultUserName": "Unknown User",
"dxChat-messageListAriaLabel": "Message list",
"dxChat-emptyListMessage": "There are no messages in this chat",
"dxChat-emptyListPrompt": "Write your first message",

Expand Down
7 changes: 7 additions & 0 deletions packages/devextreme/js/localization/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@
"dxCalendar-selectedDateRangeCount": "There are {0} selected date ranges",
"dxCalendar-readOnlyLabel": "Read-only calendar",

"dxAvatar-defaultImageAlt": "Avatar",

"dxChat-elementAriaLabel": "Chat",
"dxChat-textareaPlaceholder": "Type a message",
"dxChat-sendButtonAriaLabel": "Send",
"dxChat-defaultUserName": "Unknown User",
"dxChat-messageListAriaLabel": "Message list",
"dxChat-emptyListMessage": "There are no messages in this chat",
"dxChat-emptyListPrompt": "Write your first message",

Expand Down
7 changes: 7 additions & 0 deletions packages/devextreme/js/localization/messages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@
"dxCalendar-selectedDateRangeCount": "There are {0} selected date ranges",
"dxCalendar-readOnlyLabel": "Read-only calendar",

"dxAvatar-defaultImageAlt": "Avatar",

"dxChat-elementAriaLabel": "Chat",
"dxChat-textareaPlaceholder": "Type a message",
"dxChat-sendButtonAriaLabel": "Send",
"dxChat-defaultUserName": "Unknown User",
"dxChat-messageListAriaLabel": "Message list",
"dxChat-emptyListMessage": "There are no messages in this chat",
"dxChat-emptyListPrompt": "Write your first message",

Expand Down
7 changes: 7 additions & 0 deletions packages/devextreme/js/localization/messages/fa.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@
"dxCalendar-selectedDateRangeCount": "There are {0} selected date ranges",
"dxCalendar-readOnlyLabel": "Read-only calendar",

"dxAvatar-defaultImageAlt": "Avatar",

"dxChat-elementAriaLabel": "Chat",
"dxChat-textareaPlaceholder": "Type a message",
"dxChat-sendButtonAriaLabel": "Send",
"dxChat-defaultUserName": "Unknown User",
"dxChat-messageListAriaLabel": "Message list",
"dxChat-emptyListMessage": "There are no messages in this chat",
"dxChat-emptyListPrompt": "Write your first message",

Expand Down
7 changes: 7 additions & 0 deletions packages/devextreme/js/localization/messages/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@
"dxCalendar-selectedDateRangeCount": "There are {0} selected date ranges",
"dxCalendar-readOnlyLabel": "Read-only calendar",

"dxAvatar-defaultImageAlt": "Avatar",

"dxChat-elementAriaLabel": "Chat",
"dxChat-textareaPlaceholder": "Type a message",
"dxChat-sendButtonAriaLabel": "Send",
"dxChat-defaultUserName": "Unknown User",
"dxChat-messageListAriaLabel": "Message list",
"dxChat-emptyListMessage": "There are no messages in this chat",
"dxChat-emptyListPrompt": "Write your first message",

Expand Down
7 changes: 7 additions & 0 deletions packages/devextreme/js/localization/messages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@
"dxCalendar-selectedDateRangeCount": "There are {0} selected date ranges",
"dxCalendar-readOnlyLabel": "Read-only calendar",

"dxAvatar-defaultImageAlt": "Avatar",

"dxChat-elementAriaLabel": "Chat",
"dxChat-textareaPlaceholder": "Type a message",
"dxChat-sendButtonAriaLabel": "Send",
"dxChat-defaultUserName": "Unknown User",
"dxChat-messageListAriaLabel": "Message list",
"dxChat-emptyListMessage": "There are no messages in this chat",
"dxChat-emptyListPrompt": "Write your first message",

Expand Down
7 changes: 7 additions & 0 deletions packages/devextreme/js/localization/messages/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@
"dxCalendar-selectedDateRangeCount": "There are {0} selected date ranges",
"dxCalendar-readOnlyLabel": "Read-only calendar",

"dxAvatar-defaultImageAlt": "Avatar",

"dxChat-elementAriaLabel": "Chat",
"dxChat-textareaPlaceholder": "Type a message",
"dxChat-sendButtonAriaLabel": "Send",
"dxChat-defaultUserName": "Unknown User",
"dxChat-messageListAriaLabel": "Message list",
"dxChat-emptyListMessage": "There are no messages in this chat",
"dxChat-emptyListPrompt": "Write your first message",

Expand Down
7 changes: 7 additions & 0 deletions packages/devextreme/js/localization/messages/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@
"dxCalendar-selectedDateRangeCount": "There are {0} selected date ranges",
"dxCalendar-readOnlyLabel": "Read-only calendar",

"dxAvatar-defaultImageAlt": "Avatar",

"dxChat-elementAriaLabel": "Chat",
"dxChat-textareaPlaceholder": "Type a message",
"dxChat-sendButtonAriaLabel": "Send",
"dxChat-defaultUserName": "Unknown User",
"dxChat-messageListAriaLabel": "Message list",
"dxChat-emptyListMessage": "There are no messages in this chat",
"dxChat-emptyListPrompt": "Write your first message",

Expand Down
7 changes: 7 additions & 0 deletions packages/devextreme/js/localization/messages/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@
"dxCalendar-selectedDateRangeCount": "There are {0} selected date ranges",
"dxCalendar-readOnlyLabel": "Read-only calendar",

"dxAvatar-defaultImageAlt": "Avatar",

"dxChat-elementAriaLabel": "Chat",
"dxChat-textareaPlaceholder": "Type a message",
"dxChat-sendButtonAriaLabel": "Send",
"dxChat-defaultUserName": "Unknown User",
"dxChat-messageListAriaLabel": "Message list",
"dxChat-emptyListMessage": "There are no messages in this chat",
"dxChat-emptyListPrompt": "Write your first message",

Expand Down
7 changes: 7 additions & 0 deletions packages/devextreme/js/localization/messages/lt.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@
"dxCalendar-selectedDateRangeCount": "There are {0} selected date ranges",
"dxCalendar-readOnlyLabel": "Read-only calendar",

"dxAvatar-defaultImageAlt": "Avatar",

"dxChat-elementAriaLabel": "Chat",
"dxChat-textareaPlaceholder": "Type a message",
"dxChat-sendButtonAriaLabel": "Send",
"dxChat-defaultUserName": "Unknown User",
"dxChat-messageListAriaLabel": "Message list",
"dxChat-emptyListMessage": "There are no messages in this chat",
"dxChat-emptyListPrompt": "Write your first message",

Expand Down
7 changes: 7 additions & 0 deletions packages/devextreme/js/localization/messages/lv.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@
"dxCalendar-selectedDateRangeCount": "There are {0} selected date ranges",
"dxCalendar-readOnlyLabel": "Read-only calendar",

"dxAvatar-defaultImageAlt": "Avatar",

"dxChat-elementAriaLabel": "Chat",
"dxChat-textareaPlaceholder": "Type a message",
"dxChat-sendButtonAriaLabel": "Send",
"dxChat-defaultUserName": "Unknown User",
"dxChat-messageListAriaLabel": "Message list",
"dxChat-emptyListMessage": "There are no messages in this chat",
"dxChat-emptyListPrompt": "Write your first message",

Expand Down
7 changes: 7 additions & 0 deletions packages/devextreme/js/localization/messages/nb.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@
"dxCalendar-selectedDateRangeCount": "There are {0} selected date ranges",
"dxCalendar-readOnlyLabel": "Read-only calendar",

"dxAvatar-defaultImageAlt": "Avatar",

"dxChat-elementAriaLabel": "Chat",
"dxChat-textareaPlaceholder": "Type a message",
"dxChat-sendButtonAriaLabel": "Send",
"dxChat-defaultUserName": "Unknown User",
"dxChat-messageListAriaLabel": "Message list",
"dxChat-emptyListMessage": "There are no messages in this chat",
"dxChat-emptyListPrompt": "Write your first message",

Expand Down
7 changes: 7 additions & 0 deletions packages/devextreme/js/localization/messages/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@
"dxCalendar-selectedDateRangeCount": "There are {0} selected date ranges",
"dxCalendar-readOnlyLabel": "Read-only calendar",

"dxAvatar-defaultImageAlt": "Avatar",

"dxChat-elementAriaLabel": "Chat",
"dxChat-textareaPlaceholder": "Type a message",
"dxChat-sendButtonAriaLabel": "Send",
"dxChat-defaultUserName": "Unknown User",
"dxChat-messageListAriaLabel": "Message list",
"dxChat-emptyListMessage": "There are no messages in this chat",
"dxChat-emptyListPrompt": "Write your first message",

Expand Down
7 changes: 7 additions & 0 deletions packages/devextreme/js/localization/messages/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@
"dxCalendar-selectedDateRangeCount": "There are {0} selected date ranges",
"dxCalendar-readOnlyLabel": "Read-only calendar",

"dxAvatar-defaultImageAlt": "Avatar",

"dxChat-elementAriaLabel": "Chat",
"dxChat-textareaPlaceholder": "Type a message",
"dxChat-sendButtonAriaLabel": "Send",
"dxChat-defaultUserName": "Unknown User",
"dxChat-messageListAriaLabel": "Message list",
"dxChat-emptyListMessage": "There are no messages in this chat",
"dxChat-emptyListPrompt": "Write your first message",

Expand Down
7 changes: 7 additions & 0 deletions packages/devextreme/js/localization/messages/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@
"dxCalendar-selectedDateRangeCount": "There are {0} selected date ranges",
"dxCalendar-readOnlyLabel": "Read-only calendar",

"dxAvatar-defaultImageAlt": "Avatar",

"dxChat-elementAriaLabel": "Chat",
"dxChat-textareaPlaceholder": "Type a message",
"dxChat-sendButtonAriaLabel": "Send",
"dxChat-defaultUserName": "Unknown User",
"dxChat-messageListAriaLabel": "Message list",
"dxChat-emptyListMessage": "There are no messages in this chat",
"dxChat-emptyListPrompt": "Write your first message",

Expand Down
7 changes: 7 additions & 0 deletions packages/devextreme/js/localization/messages/ro.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@
"dxCalendar-selectedDateRangeCount": "There are {0} selected date ranges",
"dxCalendar-readOnlyLabel": "Read-only calendar",

"dxAvatar-defaultImageAlt": "Avatar",

"dxChat-elementAriaLabel": "Chat",
"dxChat-textareaPlaceholder": "Type a message",
"dxChat-sendButtonAriaLabel": "Send",
"dxChat-defaultUserName": "Unknown User",
"dxChat-messageListAriaLabel": "Message list",
"dxChat-emptyListMessage": "There are no messages in this chat",
"dxChat-emptyListPrompt": "Write your first message",

Expand Down
7 changes: 7 additions & 0 deletions packages/devextreme/js/localization/messages/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@
"dxCalendar-selectedDateRangeCount": "There are {0} selected date ranges",
"dxCalendar-readOnlyLabel": "Read-only calendar",

"dxAvatar-defaultImageAlt": "Avatar",

"dxChat-elementAriaLabel": "Chat",
"dxChat-textareaPlaceholder": "Type a message",
"dxChat-sendButtonAriaLabel": "Send",
"dxChat-defaultUserName": "Unknown User",
"dxChat-messageListAriaLabel": "Message list",
"dxChat-emptyListMessage": "There are no messages in this chat",
"dxChat-emptyListPrompt": "Write your first message",

Expand Down
7 changes: 7 additions & 0 deletions packages/devextreme/js/localization/messages/sl.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@
"dxCalendar-selectedDateRangeCount": "There are {0} selected date ranges",
"dxCalendar-readOnlyLabel": "Read-only calendar",

"dxAvatar-defaultImageAlt": "Avatar",

"dxChat-elementAriaLabel": "Chat",
"dxChat-textareaPlaceholder": "Type a message",
"dxChat-sendButtonAriaLabel": "Send",
"dxChat-defaultUserName": "Unknown User",
"dxChat-messageListAriaLabel": "Message list",
"dxChat-emptyListMessage": "There are no messages in this chat",
"dxChat-emptyListPrompt": "Write your first message",

Expand Down
Loading

0 comments on commit 545925c

Please sign in to comment.