From 5a8d274c7144864249be73955294bda19fb7532a Mon Sep 17 00:00:00 2001 From: Bruno Tavares Date: Fri, 29 Oct 2021 11:58:49 +0100 Subject: [PATCH] Implemented translation mechanism so that the translation works properly. Also made a portuguese translation file. --- admin/src/components/DropFileZone/index.js | 9 ++- admin/src/components/ImportForm/index.js | 7 ++- admin/src/components/Layout/index.js | 10 ++- admin/src/components/OptionsExport/index.js | 10 ++- admin/src/components/RawInputForm/index.js | 9 ++- admin/src/components/UploadFileForm/index.js | 14 +++-- admin/src/constants/options.js | 12 ++-- admin/src/containers/App/index.js | 28 +++++---- admin/src/containers/DataMapper/index.js | 29 +++++---- admin/src/containers/ExportPage/index.js | 43 ++++++++----- admin/src/containers/ImportPage/index.js | 30 +++++---- admin/src/translations/en.json | 65 ++++++++++++++++---- admin/src/translations/pt.json | 56 ++++++++++++++++- admin/src/utils/exportUtils.js | 12 ++-- controllers/import-export-content.js | 6 +- services/exporter/exportUtils.js | 3 +- 16 files changed, 246 insertions(+), 97 deletions(-) diff --git a/admin/src/components/DropFileZone/index.js b/admin/src/components/DropFileZone/index.js index 00440c2..d3b6888 100644 --- a/admin/src/components/DropFileZone/index.js +++ b/admin/src/components/DropFileZone/index.js @@ -4,12 +4,17 @@ import PropTypes from "prop-types"; import DragAndDropIcon from "./DragAndDropIcon"; import { Label, P } from "./styles"; +import { useGlobalContext } from "strapi-helper-plugin"; +import getTrad from '../../utils/getTrad'; + function DropFileZone({ acceptMimeTypes, acceptFilesTypes, onUploadFile, onUploadError, }) { + const { formatMessage } = useGlobalContext(); + const validateFile = (file) => { if (acceptMimeTypes.includes(file.type)) { onUploadFile(file); @@ -42,8 +47,8 @@ function DropFileZone({

- Drag & drop your file into this area or{" "} - browse for a file to upload + {formatMessage({ id: getTrad('import.dragAndDrop.firstPart')})}{" "} + {formatMessage({ id: getTrad('import.dragAndDrop.browse')})} {formatMessage({ id: getTrad('import.dragAndDrop.secondPart')})}

{isDragging && ( diff --git a/admin/src/components/ImportForm/index.js b/admin/src/components/ImportForm/index.js index b05f061..2e9ddbc 100644 --- a/admin/src/components/ImportForm/index.js +++ b/admin/src/components/ImportForm/index.js @@ -1,6 +1,9 @@ import React, { useState } from "react"; +import { useGlobalContext } from "strapi-helper-plugin"; function ImportForm() { + const { formatMessage } = useGlobalContext(); + const contentTypes = []; const [contentTypeSelected, setContentType] = useState(""); @@ -10,10 +13,10 @@ function ImportForm() { return (
- + ({ label: name, value: mimeType, })); function RawInputForm({ onSubmit }) { + const { formatMessage } = useGlobalContext(); + const [rawText, setRawText] = useState(""); const [rawFormat, setRawFormat] = useState(FORMATS[0].mimeType || ""); @@ -30,7 +35,7 @@ function RawInputForm({ onSubmit }) { return (
-
- +
- +