Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #35708 - Fix various bad translations #9498

Merged
merged 7 commits into from Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/models/setting.rb
Expand Up @@ -161,7 +161,8 @@ def parse_string_value(val)

end
if errors.present?
raise Foreman::SettingValueException.new(N_("Error parsing value for setting '%s': %s"), name, errors.full_messages.join(", "))
raise Foreman::SettingValueException.new(N_("Error parsing value for setting '%(name)s': %(error)s"),
{ 'name' => name, 'error' => errors.full_messages.join(", ") })
end
true
end
Expand Down
4 changes: 2 additions & 2 deletions webpack/assets/javascripts/foreman_editor.js
Expand Up @@ -2,7 +2,7 @@ import { API } from './react_app/redux/API';
import store from './react_app/redux';

import * as editorActions from './react_app/components/Editor/EditorActions';
import { translate as __ } from './react_app/common/I18n';
import { sprintf, translate as __ } from './react_app/common/I18n';
import { openConfirmModal } from './foreman_tools';

export const revertTemplate = ({ dataset: { version, url } }) => {
Expand All @@ -15,7 +15,7 @@ export const revertTemplate = ({ dataset: { version, url } }) => {
document.getElementById('primary_tab').click();
store.dispatch(editorActions.changeEditorValue(response.data));
} catch (err) {
alert(__(`Revert Failed, ${err}`));
alert(sprintf(__('Revert Failed, %s'), err));
}
},
});
Expand Down
11 changes: 5 additions & 6 deletions webpack/assets/javascripts/foreman_tools.js
Expand Up @@ -39,12 +39,11 @@ export function activateDatatables() {
const language = {
searchPlaceholder: __('Filter...'),
emptyTable: __('No data available in table'),
info: sprintf(
__('Showing %s to %s of %s entries'),
'_START_',
'_END_',
'_TOTAL_'
),
info: sprintf(__('Showing %(start)s to %(end)s of %(total)s entries'), {
start: '_START_',
end: '_END_',
total: '_TOTAL_',
}),
infoEmpty: __('Showing 0 to 0 of 0 entries'),
infoFiltered: sprintf(__('(filtered from %s total entries)'), '_MAX_'),
lengthMenu: sprintf(__('Show %s entries'), '_MENU_'),
Expand Down
@@ -1,6 +1,6 @@
import { debounce, toString } from 'lodash';
import { API } from '../../redux/API';
import { translate as __ } from '../../common/I18n';
import { sprintf, translate as __ } from '../../common/I18n';

import {
EDITOR_CHANGE_DIFF_VIEW,
Expand Down Expand Up @@ -183,7 +183,7 @@ const createHostAPIRequest = async (query, array, url, dispatch, getState) => {
type: EDITOR_SHOW_ERROR,
payload: {
showError: true,
errorText: __(`Host Fetch ${response}`),
errorText: sprintf(__('Host Fetch %s'), response),
previewResult: __('Error during rendering, Return to Editor tab.'),
},
});
Expand Down
Expand Up @@ -19,7 +19,7 @@ import {
} from '@patternfly/react-icons';
import { openConfirmModal } from '../../../ConfirmModal';
import { APIActions } from '../../../../redux/API';
import { translate as __ } from '../../../../common/I18n';
import { sprintf, translate as __ } from '../../../../common/I18n';
import RelativeDateTime from '../../../common/dates/RelativeDateTime';

const statusMapper = {
Expand Down Expand Up @@ -92,7 +92,10 @@ export const ActionFormatter = ({ id, can_delete }, fetchReports) => {
key: `report-${id}-DELETE`,
successToast: success => __('Report was successfully deleted'),
errorToast: error =>
__(`There was some issue deleting the report: ${error}`),
sprintf(
__('There was some issue deleting the report: %s'),
error
),
handleSuccess: fetchReports,
})
),
Expand Down
Expand Up @@ -217,7 +217,10 @@ const HostDetails = ({
<Text ouiaId="date-text" component={TextVariants.span}>
<RelativeDateTime date={response.created_at} defaultValue="N/A">
{date =>
sprintf(__('Created %s by %s'), date, response.owner_name)
sprintf(__('Created %(date)s by %(owner)s'), {
date,
owner: response.owner_name,
})
}
</RelativeDateTime>{' '}
<RelativeDateTime date={response.updated_at} defaultValue="N/A">
Expand Down
Expand Up @@ -18,7 +18,7 @@ const ModalProgressBar = ({ show, container, title, progress }) => (
<ProgressBar
active
now={progress}
label={sprintf(__(`${progress}%% Complete`))}
label={sprintf(__('%s%% Complete'), progress)}
/>
</Modal.Body>
</Modal>
Expand Down
4 changes: 2 additions & 2 deletions webpack/stories/docs/creating-a-form.stories.mdx
Expand Up @@ -68,8 +68,8 @@ You can override the default `successToast` or `errorToast` functions if needed:
onSubmit={(values, actions) =>
submitForm({
...otherProps,
successToast: response => __(`a custom success message with ${response.data.item}`),
errorToast: error => __(`a custom error message with ${error.response.data.error.item}`),
successToast: response => sprintf(__('a custom success message with %s'), response.data.item),
errorToast: error => sprintf(__('a custom error message with %s'), error.response.data.error.item),
})
}
>
Expand Down