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

Thiabo/us007/adjust internationalization #48

Merged
merged 5 commits into from
Sep 13, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion n18n.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,19 @@ const supportedLngs = ['en', 'pt'];
export const ni18nConfig = {
fallbackLng: supportedLngs,
supportedLngs,
ns: ['translation', 'home', 'about', 'sidebar', 'settings', 'releases', 'repositories', 'overview'],
ns: [
'translation',
'home',
'about',
'sidebar',
'settings',
'releases',
'repositories',
'overview',
'header',
'lates_value_table',
'graphic_chart'
],
react: {
useSuspense: false
}
Expand Down
4 changes: 4 additions & 0 deletions public/locales/en/graphic_chart.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"error": "An error occurred while trying to load the information",
"noData": "No data available to display"
}
10 changes: 10 additions & 0 deletions public/locales/en/header.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"repository": "Repository",
"edit_intervals": "Edit Intervals",
"cancel": "Cancel",
"save": "Save",
"warning_message": "Attention: This configuration will be applied to all product repositories.",
"error_message": "An error occurred while trying to load the information.",
"update_success": "Intervals updated successfully!",
"update_error": "Error updating intervals!"
}
6 changes: 6 additions & 0 deletions public/locales/en/latest_value_table.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"lastValue": "Latest value",
"lastMeasurement": "Latest measurement",
"error": "An error occurred while trying to load the information",
"noData": "No data available to display"
}
4 changes: 4 additions & 0 deletions public/locales/pt/graphic_chart.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"error": "Ocorreu um erro ao tentar carregar as informações",
"noData": "Não há dados para serem exibidos"
}
10 changes: 10 additions & 0 deletions public/locales/pt/header.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"repository": "Repositório",
"edit_intervals": "Editar Intervalos",
"cancel": "Cancelar",
"save": "Salvar",
"warning_message": "Atenção: Essa configuração será aplicada a todos os repositórios do produto.",
"error_message": "Ocorreu um erro ao tentar carregar as informações.",
"update_success": "Intervalos atualizados com sucesso!",
"update_error": "Erro ao atualizar intervalos!"
}
6 changes: 6 additions & 0 deletions public/locales/pt/latest_value_table.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"lastValue": "Último valor",
"lastMeasurement": "Última medição",
"error": "Ocorreu um erro ao tentar carregar as informações",
"noData": "Não há dados para serem exibidos"
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ exports[`<Releases /> Deve corresponder ao snapshot 1`] = `
aria-label="search-bar-label"
class="MuiFormControl-root MuiTextField-root text css-1u3bzj6-MuiFormControl-root-MuiTextField-root"
data-testid="input"
style="min-width: 250px;"
>
<div
class="MuiInputBase-root MuiOutlinedInput-root MuiInputBase-colorPrimary MuiInputBase-formControl MuiInputBase-sizeSmall MuiInputBase-adornedEnd css-o9k5xi-MuiInputBase-root-MuiOutlinedInput-root"
Expand All @@ -86,13 +87,8 @@ exports[`<Releases /> Deve corresponder ao snapshot 1`] = `
value=""
/>
<div
class="MuiInputAdornment-root MuiInputAdornment-positionStart MuiInputAdornment-outlined MuiInputAdornment-sizeSmall css-ittuaa-MuiInputAdornment-root"
class="MuiInputAdornment-root MuiInputAdornment-positionEnd MuiInputAdornment-outlined MuiInputAdornment-sizeSmall css-1laqsz7-MuiInputAdornment-root"
>
<span
class="notranslate"
>
</span>
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-i4bv87-MuiSvgIcon-root"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import ReactEcharts from 'echarts-for-react';
import { ProductFormData } from '@services/product';
import { toNumber } from 'lodash';
import { useProductQuery } from '@pages/products/hooks/useProductQuery';
import { useTranslation } from 'react-i18next';
import GaugeSlider from '../GaugeSlider';
import CopyBadgeModal from '../CopyBadgeModal';

Expand All @@ -29,6 +30,8 @@ function Header() {

const { query } = useRouter();

const { t } = useTranslation('header');

useEffect(() => {
if (initialValues && !values) {
setValues(initialValues);
Expand Down Expand Up @@ -89,12 +92,11 @@ function Header() {

const result = await updateProduct(productId, productData);
if (result.type === 'success') {
toast.success('Intervalos atualizados com sucesso!');
toast.success(t("update_success"));
setCurrentProduct(result.value);
} else {
toast.success('Erro ao atualizar intervalos!');
toast.success(t("update_error"));
}

setOpenModal(false);
}
};
Expand All @@ -104,7 +106,7 @@ function Header() {
<Box display="flex" flexDirection="column">
<Box display="flex">
<Typography variant="h4" marginRight="10px">
Repositório
{t("repository")}
</Typography>
<Typography variant="h4" fontWeight="500" color="#33568E">
{currentRepository?.name}
Expand Down Expand Up @@ -176,16 +178,16 @@ function Header() {
variant='contained'
onClick={onSubmit}
>
Salvar
{t("save")}
</Button>
</Box>
<Alert icon={<WarningIcon />} sx={{ display: "flex", justifyContent: "center", textAlign: 'center' }} severity="warning">
Atenção: Essa configuração será aplicada a todos os repositórios do produto.
{t("warning_message")}
</Alert>
</>
:
<Alert sx={{ display: "flex", justifyContent: "center", textAlign: 'center' }} severity="error">
Ocorreu um erro ao tentar carregar as informações.
{t("error_message")}
</Alert>
}
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ exports[`Header should render correctly 1`] = `
<h4
class="MuiTypography-root MuiTypography-h4 css-obdthj-MuiTypography-root"
>
Repositório
repository
</h4>
<h4
class="MuiTypography-root MuiTypography-h4 css-r2wbd1-MuiTypography-root"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ exports[`<TreeViewFilter /> should render correctly 1`] = `
aria-label="search"
class="MuiFormControl-root MuiTextField-root text css-1u3bzj6-MuiFormControl-root-MuiTextField-root"
data-testid="input"
style="min-width: 250px;"
>
<label
class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-sizeSmall MuiInputLabel-outlined MuiFormLabel-colorPrimary MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-sizeSmall MuiInputLabel-outlined css-1pysi21-MuiFormLabel-root-MuiInputLabel-root"
Expand All @@ -68,13 +69,8 @@ exports[`<TreeViewFilter /> should render correctly 1`] = `
value=""
/>
<div
class="MuiInputAdornment-root MuiInputAdornment-positionStart MuiInputAdornment-outlined MuiInputAdornment-sizeSmall css-ittuaa-MuiInputAdornment-root"
class="MuiInputAdornment-root MuiInputAdornment-positionEnd MuiInputAdornment-outlined MuiInputAdornment-sizeSmall css-1laqsz7-MuiInputAdornment-root"
>
<span
class="notranslate"
>
</span>
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-i4bv87-MuiSvgIcon-root"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ exports[`<Repository /> Should render correctly 1`] = `
<h4
class="MuiTypography-root MuiTypography-h4 css-obdthj-MuiTypography-root"
>
Repositório
repository
</h4>
<h4
class="MuiTypography-root MuiTypography-h4 css-r2wbd1-MuiTypography-root"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Object {
aria-label="input-placeholder"
class="MuiFormControl-root MuiTextField-root text css-1u3bzj6-MuiFormControl-root-MuiTextField-root"
data-testid="input"
style="min-width: 250px;"
>
<label
class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-sizeSmall MuiInputLabel-outlined MuiFormLabel-colorPrimary MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-sizeSmall MuiInputLabel-outlined css-1pysi21-MuiFormLabel-root-MuiInputLabel-root"
Expand All @@ -97,13 +98,8 @@ Object {
value=""
/>
<div
class="MuiInputAdornment-root MuiInputAdornment-positionStart MuiInputAdornment-outlined MuiInputAdornment-sizeSmall css-ittuaa-MuiInputAdornment-root"
class="MuiInputAdornment-root MuiInputAdornment-positionEnd MuiInputAdornment-outlined MuiInputAdornment-sizeSmall css-1laqsz7-MuiInputAdornment-root"
>
<span
class="notranslate"
>
</span>
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-i4bv87-MuiSvgIcon-root"
Expand Down Expand Up @@ -220,6 +216,7 @@ Object {
aria-label="input-placeholder"
class="MuiFormControl-root MuiTextField-root text css-1u3bzj6-MuiFormControl-root-MuiTextField-root"
data-testid="input"
style="min-width: 250px;"
>
<label
class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-sizeSmall MuiInputLabel-outlined MuiFormLabel-colorPrimary MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-sizeSmall MuiInputLabel-outlined css-1pysi21-MuiFormLabel-root-MuiInputLabel-root"
Expand All @@ -241,13 +238,8 @@ Object {
value=""
/>
<div
class="MuiInputAdornment-root MuiInputAdornment-positionStart MuiInputAdornment-outlined MuiInputAdornment-sizeSmall css-ittuaa-MuiInputAdornment-root"
class="MuiInputAdornment-root MuiInputAdornment-positionEnd MuiInputAdornment-outlined MuiInputAdornment-sizeSmall css-1laqsz7-MuiInputAdornment-root"
>
<span
class="notranslate"
>
</span>
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-i4bv87-MuiSvgIcon-root"
Expand Down
16 changes: 8 additions & 8 deletions src/shared/components/GraphicChart/GraphicChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import KeyboardDoubleArrowDownIcon from '@mui/icons-material/KeyboardDoubleArrow
import KeyboardDoubleArrowUpIcon from '@mui/icons-material/KeyboardDoubleArrowUp';
import { useProductContext } from '@contexts/ProductProvider';
import { HistoryDateRange } from '@customTypes/product';
import { useTranslation } from 'react-i18next';

interface Prop {
title: string;
Expand Down Expand Up @@ -57,6 +58,7 @@ const GraphicChart = ({
const [showCharts, setShowCharts] = useState(false);
const { currentProduct } = useProductContext();

const { t } = useTranslation('graphic_chart');

const sliceHistorical = (rowIdx: number): Historical[] => {
if (!autoGrid) return historical;
Expand Down Expand Up @@ -124,12 +126,10 @@ const GraphicChart = ({
>
{(type !== 'gauge') || (type === 'gauge' && showCharts) && (typeof window !== 'undefined') ?
(typeof window !== 'undefined') && chartsOption.map((option) => (
<>
< ReactEcharts
ref={echartsRef}
onEvents={option?.onEvents}
key={option.key} notMerge lazyUpdate style={chartStyle} option={option} />
</>
< ReactEcharts
ref={echartsRef}
onEvents={option?.onEvents}
key={option.key} notMerge lazyUpdate style={chartStyle} option={option} />
))
:
(typeof window !== 'undefined') && filteredChartsOptions.map((option) => (
Expand All @@ -154,13 +154,13 @@ const GraphicChart = ({
</Fade>
{error && (
<Fade in timeout={1000}>
<Alert severity="error">Ocorreu um erro ao tentar carregar as informações</Alert>
<Alert severity="error">{t('error')}</Alert>
</Fade>
)}
{isEmpty && (
<Fade in timeout={1000}>
<Alert variant="standard" severity="warning">
Não há dados para serem exibidos
{t('noData')}
</Alert>
</Fade>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ exports[`<GraphicChart /> should render correctly with empty data 1`] = `
<div
class="MuiAlert-message css-1pxa9xg-MuiAlert-message"
>
Não há dados para serem exibidos
noData
</div>
</div>
</div>
Expand Down Expand Up @@ -154,7 +154,7 @@ exports[`<GraphicChart /> should render correctly with error 1`] = `
<div
class="MuiAlert-message css-1pxa9xg-MuiAlert-message"
>
Ocorreu um erro ao tentar carregar as informações
error
</div>
</div>
</div>
Expand Down
11 changes: 7 additions & 4 deletions src/shared/components/LatestValueTable/LatestValueTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ import {

import _ from 'lodash';
import { useRequestValues } from '@hooks/useRequestValues';
import { useTranslation } from 'react-i18next';

interface Prop {
title: string;
value: 'characteristics' | 'subcharacteristics' | 'measures' | 'metrics';
}

function LatestValueTable({ title, value }: Prop) {
const { t } = useTranslation('lates_value_table');

const { data, error, isLoading, isEmpty } = useRequestValues({ type: 'latest-values', value });
const tableRows: { name: string; latestValue: number; latestData: string }[] = [];

Expand All @@ -48,8 +51,8 @@ function LatestValueTable({ title, value }: Prop) {
<TableHead>
<TableRow>
<TableCell>{title}</TableCell>
<TableCell align="right">Último valor</TableCell>
<TableCell align="right">Última medição</TableCell>
<TableCell align="right">{t('lastValue')}</TableCell>
<TableCell align="right">{t('lastMeasurement')}</TableCell>
</TableRow>
</TableHead>
<TableBody>
Expand All @@ -71,14 +74,14 @@ function LatestValueTable({ title, value }: Prop) {
{error && (
<Fade in>
<Alert variant="standard" severity="error">
Ocorreu um erro ao tentar carregar as informações
{t('error')}
</Alert>
</Fade>
)}
{isEmpty && (
<Fade in>
<Alert variant="standard" severity="warning">
Não há dados para serem exibidos
{t('noData')}
</Alert>
</Fade>
)}
Expand Down
Loading
Loading