Skip to content

Commit

Permalink
fix(ffe-context-message-react): translations of aria labels
Browse files Browse the repository at this point in the history
  • Loading branch information
pethel committed Mar 5, 2024
1 parent b0527f9 commit 532f90c
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 26 deletions.
9 changes: 5 additions & 4 deletions packages/ffe-context-message-react/src/ContextErrorMessage.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React from 'react';
import { number, node, string, bool, oneOf, func, object } from 'prop-types';
import acceptedLocales from './locale/accepted-locales';
import texts from './locale/texts';
import ContextMessage from './ContextMessage';
import { ContextMessageIcon } from './ContextMessageIcon';

const ContextErrorMessage = props => {
const { alert, ...rest } = props;
const { alert, locale, ...rest } = props;

const priorityHighIconSmall =
'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjAiIHZpZXdCb3g9IjAgLTk2MCA5NjAgOTYwIiB3aWR0aD0iMjAiPjxwYXRoIGQ9Ik00NzkuNzg4LTE4Ny4wOHEtMjEuNTM3IDAtMzYuNjYyLTE1LjMzN3QtMTUuMTI1LTM2Ljg3NHEwLTIxLjUzNyAxNS4zMzctMzYuNjYyIDE1LjMzNy0xNS4xMjQgMzYuODc0LTE1LjEyNCAyMS41MzcgMCAzNi42NjIgMTUuMzM3dDE1LjEyNSAzNi44NzRxMCAyMS41MzctMTUuMzM3IDM2LjY2MS0xNS4zMzcgMTUuMTI1LTM2Ljg3NCAxNS4xMjVabS0uMDYyLTE5Ni4xNTFxLTE5LjM0MSAwLTMyLjg0LTEzLjcwOS0xMy41LTEzLjcwOS0xMy41LTMyLjk2di0zMTYuNjg1cTAtMTkuMjUxIDEzLjc3NC0zMi43OTQgMTMuNzczLTEzLjU0MiAzMy4xMTQtMTMuNTQyIDE5LjM0MSAwIDMyLjg0IDEzLjcwOSAxMy41IDEzLjcwOSAxMy41IDMyLjk2djMxNi42ODVxMCAxOS4yNTEtMTMuNzc0IDMyLjc5NC0xMy43NzMgMTMuNTQyLTMzLjExNCAxMy41NDJaIi8+PC9zdmc+';
Expand All @@ -16,14 +17,14 @@ const ContextErrorMessage = props => {
return (
<ContextMessage
{...rest}
locale={locale}
messageType="error"
aria-label="Feilmelding"
role={alert ? 'alert' : 'group'}
icon={
<ContextMessageIcon
smallIconUrl={priorityHighIconSmall}
largeIconUrl={priorityHighIconLarge}
ariaLabel="Utropstegn"
ariaLabel={texts[locale].icon.error}
/>
}
/>
Expand All @@ -43,7 +44,7 @@ ContextErrorMessage.propTypes = {
header: string,
/** ID for the header container */
headerElementId: string,
/** Decides the language of the aria-label for the close icon */
/** Decides the language */
locale: oneOf(acceptedLocales),
/** Callback for when the context message has been closed (after the animation) */
onClose: func,
Expand Down
20 changes: 16 additions & 4 deletions packages/ffe-context-message-react/src/ContextInfoMessage.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import React from 'react';
import ContextMessage from './ContextMessage';
import { ContextMessageIcon } from './ContextMessageIcon';
import texts from './locale/texts';
import { oneOf } from 'prop-types';
import acceptedLocales from './locale/accepted-locales';

const ContextInfoMessage = props => {
const ContextInfoMessage = ({ locale, ...rest }) => {
const infoIconSmall =
'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjAiIHZpZXdCb3g9IjAgLTk2MCA5NjAgOTYwIiB3aWR0aD0iMjAiPjxwYXRoIGQ9Ik00NzkuNzg4LTY3MnEtMjUuOTQyIDAtNDMuODY0LTE4LjEzNS0xNy45MjMtMTguMTM2LTE3LjkyMy00NC4wNzd0MTguMTM1LTQzLjg2NHExOC4xMzUtMTcuOTIzIDQ0LjA3Ni0xNy45MjMgMjUuOTQyIDAgNDMuODY0IDE4LjEzNiAxNy45MjMgMTguMTM1IDE3LjkyMyA0NC4wNzZ0LTE4LjEzNSA0My44NjRRNTA1LjcyOS02NzIgNDc5Ljc4OC02NzJabS4yNTcgNTA3Ljk5OXEtMjAuODE0IDAtMzUuNDI5LTE0LjU4NC0xNC42MTUtMTQuNTgzLTE0LjYxNS0zNS40MTZ2LTI5Ni42MTRxMC0yMC44MzMgMTQuNTctMzUuNDE2IDE0LjU3LTE0LjU4MyAzNS4zODQtMTQuNTgzdDM1LjQyOSAxNC41ODNxMTQuNjE1IDE0LjU4MyAxNC42MTUgMzUuNDE2djI5Ni42MTRxMCAyMC44MzMtMTQuNTcgMzUuNDE2LTE0LjU3IDE0LjU4NC0zNS4zODQgMTQuNTg0WiIvPjwvc3ZnPg==';

Expand All @@ -11,19 +14,28 @@ const ContextInfoMessage = props => {

return (
<ContextMessage
{...props}
{...rest}
locale={locale}
messageType="info"
aria-label="Infomelding"
role="group"
icon={
<ContextMessageIcon
smallIconUrl={infoIconSmall}
largeIconUrl={infoIconLarge}
ariaLabel="Infotegn"
ariaLabel={texts[locale].icon.info}
/>
}
/>
);
};

ContextInfoMessage.defaultProps = {
locale: 'nb',
};

ContextInfoMessage.propTypes = {
/** Decides the language */
locale: oneOf(acceptedLocales),
};

export default ContextInfoMessage;
4 changes: 1 addition & 3 deletions packages/ffe-context-message-react/src/ContextMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ const ContextMessage = ({
</div>
{showCloseButton && (
<button
aria-label={`${
texts[locale].FFE_CONTEXT_MESSAGE_CLOSE
} ${headerText || ''}`}
aria-label={`${texts[locale].close} ${headerText || ''}`}
className="ffe-context-message-content__close-button"
onClick={handleClose}
type="button"
Expand Down
20 changes: 16 additions & 4 deletions packages/ffe-context-message-react/src/ContextSuccessMessage.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import React from 'react';
import texts from './locale/texts';
import ContextMessage from './ContextMessage';
import { ContextMessageIcon } from './ContextMessageIcon';
import { oneOf } from 'prop-types';
import acceptedLocales from './locale/accepted-locales';

const ContextSuccessMessage = props => {
const ContextSuccessMessage = ({ locale, ...rest }) => {
const checkIconSmall =
'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjAiIHZpZXdCb3g9IjAgLTk2MCA5NjAgOTYwIiB3aWR0aD0iMjAiPjxwYXRoIGQ9Im0zOTUtMzcyLjM4NCAyNzAuNTM5LTI2OS41MzhxNy45MjMtNy45MjMgMTcuNjkyLTcuNjE2IDkuNzY5LjMwOCAxOC4wNzYgOC42MTYgOC4zMDggOC4zMDcgOC4zMDggMTcuODg0IDAgOS41NzYtOC4zMDggMTcuODg0bC0yODMgMjgyLjk5OXEtOS44NDYgOS44NDYtMjIuODA3IDkuODQ2LTEyLjk2MSAwLTIyLjgwNy05Ljg0NmwtMTE0LTExMy45OTlxLTcuOTIzLTcuOTIzLTguMzA4LTE3LjY5Mi0uMzg0LTkuNzY5IDcuOTIzLTE4LjA3NiA4LjMwOC04LjMwOCAxNy44ODQtOC4zMDggOS41NzcgMCAxNy44ODQgOC4zMDhMMzk1LTM3Mi4zODRaIi8+PC9zdmc+';

Expand All @@ -11,19 +14,28 @@ const ContextSuccessMessage = props => {

return (
<ContextMessage
{...props}
{...rest}
locale={locale}
messageType="success"
aria-label="Suksessmelding"
role="group"
icon={
<ContextMessageIcon
smallIconUrl={checkIconSmall}
largeIconUrl={checkIconLarge}
ariaLabel="hake"
ariaLabel={texts[locale].icon.success}
/>
}
/>
);
};

ContextSuccessMessage.defaultProps = {
locale: 'nb',
};

ContextSuccessMessage.propTypes = {
/** Decides the language */
locale: oneOf(acceptedLocales),
};

export default ContextSuccessMessage;
20 changes: 16 additions & 4 deletions packages/ffe-context-message-react/src/ContextTipsMessage.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import React from 'react';
import ContextMessage from './ContextMessage';
import { ContextMessageIcon } from './ContextMessageIcon';
import texts from './locale/texts';
import { oneOf } from 'prop-types';
import acceptedLocales from './locale/accepted-locales';

const ContextTipsMessage = props => {
const ContextTipsMessage = ({ locale, ...rest }) => {
const lightbulbIconSmall =
'data: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SA3NVptMTM2IDBaIi8+PC9zdmc+';

Expand All @@ -11,19 +14,28 @@ const ContextTipsMessage = props => {

return (
<ContextMessage
{...props}
{...rest}
locale={locale}
messageType="tips"
aria-label="Tipsmelding"
role="group"
icon={
<ContextMessageIcon
smallIconUrl={lightbulbIconSmall}
largeIconUrl={lightbulbIconLarge}
ariaLabel="Lyspære"
ariaLabel={texts[locale].icon.tip}
/>
}
/>
);
};

ContextTipsMessage.defaultProps = {
locale: 'nb',
};

ContextTipsMessage.propTypes = {
/** Decides the language */
locale: oneOf(acceptedLocales),
};

export default ContextTipsMessage;
34 changes: 27 additions & 7 deletions packages/ffe-context-message-react/src/locale/texts.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
const nb = {};
const nn = {};
const en = {};

nb.FFE_CONTEXT_MESSAGE_CLOSE = 'Lukk';
nn.FFE_CONTEXT_MESSAGE_CLOSE = 'Lukk';
en.FFE_CONTEXT_MESSAGE_CLOSE = 'Close';
const nb = {
close: 'Lukk',
icon: {
error: 'Utropstegn',
info: 'Infotegn',
success: 'Hake',
tip: 'Lyspære',
},
};
const nn = {
close: 'Lukk',
icon: {
error: 'Utropsteikn',
info: 'Infoteikn',
success: 'Hake',
tip: 'Lyspære',
},
};
const en = {
close: 'Close',
icon: {
error: 'Exclamation mark',
info: 'Info sign',
success: 'Check mark',
tip: 'Light bulb',
},
};

export default { nb, nn, en };

0 comments on commit 532f90c

Please sign in to comment.