Skip to content

Commit

Permalink
Ensure aria-labels are translated; don't use t in core
Browse files Browse the repository at this point in the history
Co-authored-by: Dennis Kigen <[email protected]>
  • Loading branch information
brandones and denniskigen committed Apr 20, 2024
1 parent cd9d412 commit f9fb219
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ const Workspace: React.FC<WorkspaceProps> = ({ workspaceInstance }) => {
/>
</div>
) : (
<Header className={styles.tabletOverlayHeader} aria-label="Workspace header">
<Header
className={styles.tabletOverlayHeader}
aria-label={getCoreTranslation('workspaceHeader', 'Workspace header')}
>
<Button
onClick={workspaceInstance.closeWorkspace}
kind="ghost"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
/** @module @category Workspace */
import React, { useContext, useMemo } from 'react';
import classNames from 'classnames';
import { ExtensionSlot, useBodyScrollLock, useLayoutType, isDesktop, translateFrom } from '@openmrs/esm-framework';
import {
ExtensionSlot,
useBodyScrollLock,
useLayoutType,
isDesktop,
translateFrom,
getCoreTranslation,
} from '@openmrs/esm-framework';
import { type OpenWorkspace, useWorkspaces, updateWorkspaceWindowState } from '../workspaces';
import { Header, HeaderGlobalBar, HeaderName, HeaderMenuButton, HeaderGlobalAction } from '@carbon/react';
import { ArrowLeft, ArrowRight, Close, DownToBottom, Maximize, Minimize } from '@carbon/react/icons';
Expand Down Expand Up @@ -64,7 +71,6 @@ interface WorkspaceProps {
}

function Workspace({ workspaceInstance, additionalWorkspaceProps }: WorkspaceProps) {
const { t } = useTranslation();
const layout = useLayoutType();
const { workspaceWindowState } = useWorkspaces();
const maximized = workspaceWindowState === 'maximized';
Expand Down Expand Up @@ -101,7 +107,7 @@ function Workspace({ workspaceInstance, additionalWorkspaceProps }: WorkspacePro
})}
>
<Header
aria-label="Workspace Title"
aria-label={getCoreTranslation('workspaceHeader', 'Workspace Header')}
className={classNames(styles.header, maximized ? styles.fullWidth : styles.dynamicWidth)}
>
{layout === 'tablet' && !canHide && (
Expand All @@ -115,7 +121,9 @@ function Workspace({ workspaceInstance, additionalWorkspaceProps }: WorkspacePro
{(canMaximize || maximized) && (
<HeaderGlobalAction
align="bottom"
label={maximized ? t('minimize', 'Minimize') : t('maximize', 'Maximize')}
label={
maximized ? getCoreTranslation('minimize', 'Minimize') : getCoreTranslation('maximize', 'Maximize')
}
onClick={toggleWindowState}
size="lg"
>
Expand All @@ -125,7 +133,7 @@ function Workspace({ workspaceInstance, additionalWorkspaceProps }: WorkspacePro
{canHide ? (
<HeaderGlobalAction
align="bottom-right"
label={t('hide', 'Hide')}
label={getCoreTranslation('hide', 'Hide')}
onClick={() => updateWorkspaceWindowState('hidden')}
size="lg"
>
Expand All @@ -134,7 +142,7 @@ function Workspace({ workspaceInstance, additionalWorkspaceProps }: WorkspacePro
) : (
<HeaderGlobalAction
align="bottom-right"
label={t('close', 'Close')}
label={getCoreTranslation('close', 'Close')}
onClick={() => closeWorkspace?.()}
size="lg"
>
Expand All @@ -144,7 +152,11 @@ function Workspace({ workspaceInstance, additionalWorkspaceProps }: WorkspacePro
</>
)}
{layout === 'tablet' && canHide && (
<HeaderGlobalAction align="bottom-right" label={t('close', 'Close')} onClick={() => closeWorkspace?.()}>
<HeaderGlobalAction
align="bottom-right"
label={getCoreTranslation('close', 'Close')}
onClick={() => closeWorkspace?.()}
>
<DownToBottom />
</HeaderGlobalAction>
)}
Expand Down
4 changes: 4 additions & 0 deletions packages/framework/esm-translations/src/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ const workspaceTranslations = {
'There are unsaved changes in the following workspaces. Do you want to discard changes in the following workspaces? {{workspaceNames}}',
closingAllWorkspacesPromptTitle: 'You have unsaved changes',
discard: 'Discard',
hide: 'Hide',
maximize: 'Maximize',
minimize: 'Minimize',
openAnyway: 'Open Anyway',
unsavedChangesInOpenedWorkspace: `You have unsaved changes in the opened workspace. Do you want to discard these changes?`,
unsavedChangesInWorkspace:
'There are unsaved changes in {{workspaceName}}. Please save them before opening another workspace.',
unsavedChangesTitleText: 'Unsaved Changes',
workspaceHeader: 'Workspace Header',
};

export const coreTranslations = {
Expand Down
6 changes: 5 additions & 1 deletion packages/framework/esm-translations/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
"error": "Error",
"errorCopy": "Sorry, there was a problem displaying this information. You can try to reload this page, or contact the site administrator and quote the error code above.",
"female": "Female",
"hide": "Hide",
"hideDetails": "Hide details",
"loading": "Loading",
"male": "Male",
"maximize": "Maximize",
"minimize": "Minimize",
"openAnyway": "Open Anyway",
"other": "Other",
"patientLists": "Patient Lists",
Expand All @@ -33,5 +36,6 @@
"stateProvince": "State",
"unknown": "Unknown",
"unsavedChangesInWorkspace": "There are unsaved changes in {{workspaceName}}. Please save them before opening another workspace.",
"unsavedChangesTitleText": "Unsaved Changes"
"unsavedChangesTitleText": "Unsaved Changes",
"workspaceHeader": "Workspace Header"
}

0 comments on commit f9fb219

Please sign in to comment.