diff --git a/awx/ui_next/CONTRIBUTING.md b/awx/ui_next/CONTRIBUTING.md
index f6207abd26..05ce336063 100644
--- a/awx/ui_next/CONTRIBUTING.md
+++ b/awx/ui_next/CONTRIBUTING.md
@@ -336,16 +336,14 @@ Internationalization leans on the [lingui](https://github.com/lingui/js-lingui)
The lingui library provides various React helpers for dealing with both marking strings for translation, and replacing strings that have been translated. For consistency and ease of use, we have consolidated on one pattern for the codebase. To set strings to be translated in the UI:
-- import the withI18n function and wrap the export of your component in it (i.e. `export default withI18n()(Foo)`)
-- doing the above gives you access to the i18n object on props. Make sure to put it in the scope of the function that contains strings needed to be translated (i.e. `const { i18n } = this.props;`)
- import the t template tag function from the @lingui/macro package.
-- wrap your string using the following format: `` i18n._(t`String to be translated`) ``
+- wrap your string using the following format: `` t`String to be translated` ``
-**Note:** Variables that are put inside the t-marked template tag will not be translated. If you have a variable string with text that needs translating, you must wrap it in ` i18n._(t``) ` where it is defined.
+**Note:** If you have a variable string with text that needs translating, you must wrap it in `` t`${variable} string` `` where it is defined. Then you must run `npm run extract-strings` to generate new `.po` files and submit those files along with your pull request.
-**Note:** We try to avoid the `I18n` consumer, `i18nMark` function, or `
{speechBubble}
@@ -63,4 +62,4 @@ About.defaultProps = {
version: null,
};
-export default withI18n()(About);
+export default About;
diff --git a/awx/ui_next/src/components/AdHocCommands/AdHocCommands.jsx b/awx/ui_next/src/components/AdHocCommands/AdHocCommands.jsx
index fb8ed89f84..f85120f8f7 100644
--- a/awx/ui_next/src/components/AdHocCommands/AdHocCommands.jsx
+++ b/awx/ui_next/src/components/AdHocCommands/AdHocCommands.jsx
@@ -1,6 +1,6 @@
import React, { useCallback, useEffect, useState, useContext } from 'react';
import { useHistory, useParams } from 'react-router-dom';
-import { withI18n } from '@lingui/react';
+
import { t } from '@lingui/macro';
import PropTypes from 'prop-types';
import { Button, DropdownItem } from '@patternfly/react-core';
@@ -14,7 +14,7 @@ import AdHocCommandsWizard from './AdHocCommandsWizard';
import { KebabifiedContext } from '../../contexts/Kebabified';
import ContentError from '../ContentError';
-function AdHocCommands({ adHocItems, i18n, hasListItems, onLaunchLoading }) {
+function AdHocCommands({ adHocItems, hasListItems, onLaunchLoading }) {
const history = useHistory();
const { id } = useParams();
@@ -22,11 +22,11 @@ function AdHocCommands({ adHocItems, i18n, hasListItems, onLaunchLoading }) {
const { isKebabified, onKebabModalChange } = useContext(KebabifiedContext);
const verbosityOptions = [
- { value: '0', key: '0', label: i18n._(t`0 (Normal)`) },
- { value: '1', key: '1', label: i18n._(t`1 (Verbose)`) },
- { value: '2', key: '2', label: i18n._(t`2 (More Verbose)`) },
- { value: '3', key: '3', label: i18n._(t`3 (Debug)`) },
- { value: '4', key: '4', label: i18n._(t`4 (Connection Debug)`) },
+ { value: '0', key: '0', label: t`0 (Normal)` },
+ { value: '1', key: '1', label: t`1 (Verbose)` },
+ { value: '2', key: '2', label: t`2 (More Verbose)` },
+ { value: '3', key: '3', label: t`3 (Debug)` },
+ { value: '4', key: '4', label: t`4 (Connection Debug)` },
];
useEffect(() => {
if (isKebabified) {
@@ -102,7 +102,7 @@ function AdHocCommands({ adHocItems, i18n, hasListItems, onLaunchLoading }) {
- {i18n._(
- t`Pass extra command line changes. There are two ansible command line parameters: `
- )}
+ {t`Pass extra command line changes. There are two ansible command line parameters: `}
-e, --extra-vars
- {i18n._(t`Provide key/value pairs using either
- YAML or JSON.`)}
+ {t`Provide key/value pairs using either
+ YAML or JSON.`}
{i18n._(t`Click to view job details`)}
+{t`Click to view job details`}
)} > ); @@ -175,4 +175,4 @@ WorkflowNodeHelp.propTypes = { node: shape().isRequired, }; -export default withI18n()(WorkflowNodeHelp); +export default WorkflowNodeHelp; diff --git a/awx/ui_next/src/components/Workflow/WorkflowStartNode.jsx b/awx/ui_next/src/components/Workflow/WorkflowStartNode.jsx index 23dbc06481..8f4c17d79c 100644 --- a/awx/ui_next/src/components/Workflow/WorkflowStartNode.jsx +++ b/awx/ui_next/src/components/Workflow/WorkflowStartNode.jsx @@ -1,6 +1,5 @@ import React, { useContext, useRef, useState } from 'react'; import styled from 'styled-components'; -import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; import { bool, func } from 'prop-types'; import { PlusIcon } from '@patternfly/react-icons'; @@ -31,7 +30,7 @@ const StartDiv = styled.div` padding: 0px 10px; `; -function WorkflowStartNode({ i18n, onUpdateHelpText, showActionTooltip }) { +function WorkflowStartNode({ onUpdateHelpText, showActionTooltip }) { const ref = useRef(null); const startNodeRef = useRef(null); const [hovering, setHovering] = useState(false); @@ -58,7 +57,7 @@ function WorkflowStartNode({ i18n, onUpdateHelpText, showActionTooltip }) { y="10" style={{ overflow: 'visible' }} > -{i18n._(t`Notification sent successfully`)}
+{t`Notification sent successfully`}
)} {notification.status === 'failed' && notification?.error === 'timed out' && ( -{i18n._(t`Notification timed out`)}
+{t`Notification timed out`}
)} {notification.status === 'failed' && notification?.error !== 'timed out' && ( @@ -265,4 +263,4 @@ function NotificationTemplatesList({ i18n }) { ); } -export default withI18n()(NotificationTemplatesList); +export default NotificationTemplatesList; diff --git a/awx/ui_next/src/screens/NotificationTemplate/NotificationTemplateList/NotificationTemplateListItem.jsx b/awx/ui_next/src/screens/NotificationTemplate/NotificationTemplateList/NotificationTemplateListItem.jsx index 025e4b7465..c2f783b583 100644 --- a/awx/ui_next/src/screens/NotificationTemplate/NotificationTemplateList/NotificationTemplateListItem.jsx +++ b/awx/ui_next/src/screens/NotificationTemplate/NotificationTemplateList/NotificationTemplateListItem.jsx @@ -1,6 +1,6 @@ import 'styled-components/macro'; import React, { useState, useEffect, useCallback } from 'react'; -import { withI18n } from '@lingui/react'; + import { t } from '@lingui/macro'; import { Link } from 'react-router-dom'; import { Button } from '@patternfly/react-core'; @@ -27,7 +27,6 @@ function NotificationTemplateListItem({ isSelected, onSelect, rowIndex, - i18n, }) { const recentNotifications = template.summary_fields?.recent_notifications; const latestStatus = recentNotifications @@ -102,25 +101,25 @@ function NotificationTemplateListItem({ isSelected, onSelect, }} - dataLabel={i18n._(t`Selected`)} + dataLabel={t`Selected`} /> -
{'{{'} job_friendly_name {'}}'}
@@ -87,8 +87,8 @@ function CustomMessagesSubForm({ defaultMessages, type, i18n }) {
{'{{'} job.status {'}}'}
.{' '}
- {i18n._(t`You may apply a number of possible variables in the
- message. For more information, refer to the`)}{' '}
+ {t`You may apply a number of possible variables in the
+ message. For more information, refer to the`}{' '}
- {i18n._(t`Documentation.`)}
+ {t`Ansible Tower Documentation.`}
@@ -105,7 +105,7 @@ function CustomMessagesSubForm({ defaultMessages, type, i18n }) {
- {i18n._(t`If you do not have a subscription, you can visit - Red Hat to obtain a trial subscription.`)} + {t`If you do not have a subscription, you can visit + Red Hat to obtain a trial subscription.`}
- {i18n._( - t`Select your Ansible Automation Platform subscription to use.` - )} -
+{t`Select your Ansible Automation Platform subscription to use.`}
- {i18n._(t`Provide your Red Hat or Red Hat Satellite credentials + {t`Provide your Red Hat or Red Hat Satellite credentials below and you can choose from a list of your available subscriptions. The credentials you use will be stored for future use in - retrieving renewal or expanded subscriptions.`)} + retrieving renewal or expanded subscriptions.`}
- {i18n._( - t`Are you sure you want to remove all the nodes in this workflow?` - )} + {t`Are you sure you want to remove all the nodes in this workflow?`}
{i18n._(t`Are you sure you want to remove this link?`)}
+{t`Are you sure you want to remove this link?`}
{!linkToDelete.isConvergenceLink && (- {i18n._( - t`Removing this link will orphan the rest of the branch and cause it to be executed immediately on launch.` - )} + {t`Removing this link will orphan the rest of the branch and cause it to be executed immediately on launch.`}
{i18n._(t`Are you sure you want to remove the node below:`)}
+{t`Are you sure you want to remove the node below:`}
{i18n._(t`Are you sure you want to remove this node?`)}
+{t`Are you sure you want to remove this node?`}
)}