Skip to content

Commit

Permalink
feat(js): Revise localization keys DX (#6380)
Browse files Browse the repository at this point in the history
  • Loading branch information
desiprisg authored Aug 28, 2024
1 parent 69e4ae9 commit e4cc00e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useInboxContext, useLocalization } from '../../../context';
import { cn, useStyle } from '../../../helpers';
import { ArrowDropDown } from '../../../icons';
import { Button, buttonVariants, Dropdown } from '../../primitives';
import { inboxStatusLocalizationKeys } from './constants';
import { inboxFilterLocalizationKeys } from './constants';
import { StatusOptions } from './InboxStatusOptions';

export const StatusDropdown = () => {
Expand All @@ -20,10 +20,10 @@ export const StatusDropdown = () => {
asChild={(triggerProps) => (
<Button variant="unstyled" size="none" {...triggerProps}>
<span
data-localization={inboxStatusLocalizationKeys[status()]}
data-localization={inboxFilterLocalizationKeys[status()]}
class={style('inboxStatus__title', 'nt-text-xl nt-font-semibold')}
>
{t(inboxStatusLocalizationKeys[status()])}
{t(inboxFilterLocalizationKeys[status()])}
</span>
<span class={style('inboxStatus__dropdownItemRight__icon', 'nt-text-foreground-alpha-600')}>
<ArrowDropDown />
Expand Down
14 changes: 7 additions & 7 deletions packages/js/src/ui/components/elements/InboxStatus/constants.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { LocalizationKey, NotificationStatus } from '../../../types';

export const notificationStatusOptionsLocalizationKeys = {
unreadRead: 'inbox.status.options.unreadRead',
unread: 'inbox.status.options.unread',
archived: 'inbox.status.options.archived',
unreadRead: 'inbox.filters.dropdownOptions.default',
unread: 'inbox.filters.dropdownOptions.unread',
archived: 'inbox.filters.dropdownOptions.archived',
} as const satisfies Record<NotificationStatus, LocalizationKey>;

export const inboxStatusLocalizationKeys = {
unreadRead: 'inbox.status.unreadRead',
unread: 'inbox.status.unread',
archived: 'inbox.status.archived',
export const inboxFilterLocalizationKeys = {
unreadRead: 'inbox.filters.labels.default',
unread: 'inbox.filters.labels.unread',
archived: 'inbox.filters.labels.archived',
} as const satisfies Record<NotificationStatus, LocalizationKey>;
12 changes: 6 additions & 6 deletions packages/js/src/ui/config/defaultLocalization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { createSignal } from 'solid-js';

export const defaultLocalization = {
locale: 'en-US',
'inbox.status.options.unread': 'Unread only',
'inbox.status.options.unreadRead': 'Unread & read',
'inbox.status.options.archived': 'Archived',
'inbox.status.unread': 'Unread',
'inbox.status.unreadRead': 'Inbox',
'inbox.status.archived': 'Archived',
'inbox.filters.dropdownOptions.unread': 'Unread only',
'inbox.filters.dropdownOptions.default': 'Unread & read',
'inbox.filters.dropdownOptions.archived': 'Archived',
'inbox.filters.labels.unread': 'Unread',
'inbox.filters.labels.default': 'Inbox',
'inbox.filters.labels.archived': 'Archived',
'notifications.emptyNotice': 'No notifications',
'notifications.actions.readAll': 'Mark all as read',
'notifications.actions.archiveAll': 'Archive all',
Expand Down

0 comments on commit e4cc00e

Please sign in to comment.