Skip to content

Commit

Permalink
Add translation namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
farhanlatheef committed Oct 30, 2023
1 parent eaebcef commit a4b63ec
Show file tree
Hide file tree
Showing 27 changed files with 260 additions and 241 deletions.
14 changes: 9 additions & 5 deletions src/components/Attachments/Attachment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,13 @@ const Attachment = ({
<Input
autoFocus
data-cy="neeto-editor-preview-rename-input"
error={isEmpty(newFilename) ? t("attachments.nameEmpty") : ""}
size="small"
value={newFilename}
error={
isEmpty(newFilename)
? t("neetoEditor.attachments.nameEmpty")
: ""
}
onChange={withEventTargetValue(setNewFilename)}
onKeyDown={event =>
handleKeyDown({
Expand Down Expand Up @@ -159,7 +163,7 @@ const Attachment = ({
</Tooltip>
</div>
<Tooltip
content={t("attachments.actionsBlocked")}
content={t("neetoEditor.attachments.actionsBlocked")}
disabled={!disabled}
position="top"
>
Expand Down Expand Up @@ -188,11 +192,11 @@ const Attachment = ({
<Alert
isOpen={isDeleteAlertOpen}
isSubmitting={isDeleting}
submitButtonLabel={t("menu.delete")}
title={t("attachments.deleteTitle")}
submitButtonLabel={t("neetoEditor.menu.delete")}
title={t("neetoEditor.attachments.deleteTitle")}
message={
<Trans
i18nKey="attachments.deleteConfirmation"
i18nKey="neetoEditor.attachments.deleteConfirmation"
values={{ entity: newFilename }}
/>
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Attachments/Preview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const Preview = ({
return (
<Typography>
<Trans
i18nKey="attachments.noPreview"
i18nKey="neetoEditor.attachments.noPreview"
components={{
span: (
<span
Expand Down Expand Up @@ -102,7 +102,7 @@ const Preview = ({
<Button
icon={Download}
iconPosition="right"
label={t("common.download")}
label={t("neetoEditor.common.download")}
ref={downloadRef}
onClick={handleDownload}
/>
Expand Down
8 changes: 4 additions & 4 deletions src/components/Attachments/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ const Attachments = (
data: file,
});
} catch (error) {
if (error.message !== t("error.onBeforeFileAddedReturn")) {
Toastr.error(t("error.cannotAddFiles"));
if (error.message !== t("neetoEditor.error.onBeforeFileAddedReturn")) {
Toastr.error(t("neetoEditor.error.cannotAddFiles"));
}
}
});
Expand Down Expand Up @@ -173,7 +173,7 @@ const Attachments = (
<Button
data-cy="neeto-editor-attachments-upload-button"
disabled={isUploading}
label={t("attachments.add")}
label={t("neetoEditor.attachments.add")}
loading={isUploading}
size="medium"
style="link"
Expand All @@ -189,7 +189,7 @@ const Attachments = (
onClick={event => {
if (!isEmpty(attachments) && config.maxNumberOfFiles === 1) {
event.preventDefault();
Toastr.warning(t("attachments.oneAttachmentAllowed"));
Toastr.warning(t("neetoEditor.attachments.oneAttachmentAllowed"));
}
}}
/>
Expand Down
12 changes: 9 additions & 3 deletions src/components/Attachments/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export const selectFiles = ({ previousAttachmentsCount, config, files }) => {

if (remainingAttachments <= 0) {
Toastr.warning(
t("attachments.maxNumberOfFiles", { entity: maxNumberOfFiles })
t("neetoEditor.attachments.maxNumberOfFiles", {
entity: maxNumberOfFiles,
})
);

return [];
Expand All @@ -29,7 +31,9 @@ export const selectFiles = ({ previousAttachmentsCount, config, files }) => {

if (selectedFiles.length < files.length) {
Toastr.warning(
t("attachments.maxNumberOfFiles", { entity: maxNumberOfFiles })
t("neetoEditor.attachments.maxNumberOfFiles", {
entity: maxNumberOfFiles,
})
);
}

Expand All @@ -48,7 +52,9 @@ export const handleDrop = ({ uppy, config, previousAttachmentsCount }) => {

if (totalAttachments > maxNumberOfFiles) {
Toastr.warning(
t("attachments.maxNumberOfFiles", { entity: maxNumberOfFiles })
t("neetoEditor.attachments.maxNumberOfFiles", {
entity: maxNumberOfFiles,
})
);
uppy.reset();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ const CodeBlockComponent = ({ node, editor, updateAttributes }) => {
buttonSize="small"
buttonStyle="secondary"
icon={Down}
label={node.attrs?.language || t("common.auto")}
label={node.attrs?.language || t("neetoEditor.common.auto")}
strategy="fixed"
>
<Input
autoFocus
className="neeto-editor-codeblock-options__input"
placeholder={t("placeholders.searchLanguages")}
placeholder={t("neetoEditor.placeholders.searchLanguages")}
size="small"
value={keyword}
onChange={e => setKeyword(e.target.value)}
Expand All @@ -61,7 +61,7 @@ const CodeBlockComponent = ({ node, editor, updateAttributes }) => {
key={language}
onClick={() => handleLanguageSelect(language)}
>
{language || t("common.auto")}
{language || t("neetoEditor.common.auto")}
</MenuItem.Button>
))}
</Menu>
Expand Down
4 changes: 2 additions & 2 deletions src/components/Editor/CustomExtensions/Embeds/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const EmbedOption = ({ isEmbedModalOpen, setIsEmbedModalOpen, editor }) => {
<Input
data-cy="neeto-editor-embed-input"
error={error && "Please enter a valid URL"}
label={t("common.videoUrl")}
label={t("neetoEditor.common.videoUrl")}
ref={inputRef}
size="medium"
type="text"
Expand All @@ -87,7 +87,7 @@ const EmbedOption = ({ isEmbedModalOpen, setIsEmbedModalOpen, editor }) => {
<Button
data-cy="neeto-editor-embed-cancel"
disabled={error || isEmpty(embedUrl)}
label={t("common.embed")}
label={t("neetoEditor.common.embed")}
onClick={handleEmbed}
/>
</Modal.Footer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ const upload = async (file, url) => {
}

const imageSizeInMB = MAX_IMAGE_SIZE / (1024 * 1024);
Toastr.error(t("error.imageSizeIsShouldBeLess", { limit: imageSizeInMB }));
Toastr.error(
t("neetoEditor.error.imageSizeIsShouldBeLess", { limit: imageSizeInMB })
);

return "";
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Placeholder = Extension.create({
excludeNodeTypes: ["variable", "codeBlock"],
emptyEditorClass: "is-editor-empty",
emptyNodeClass: "is-empty",
placeholder: t("placeholders.writeSomething"),
placeholder: t("neetoEditor.placeholders.writeSomething"),
showOnlyWhenEditable: true,
showOnlyCurrent: false,
includeChildren: false,
Expand Down
18 changes: 11 additions & 7 deletions src/components/Editor/LinkPopOver.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const LinkPopOver = ({ editor }) => {
.run();
setIsEditing(false);
} else {
setError(t("error.invalidUrl"));
setError(t("neetoEditor.error.invalidUrl"));
}
};

Expand Down Expand Up @@ -116,18 +116,22 @@ const LinkPopOver = ({ editor }) => {
<Input
autoFocus
{...{ error }}
label={t("menu.link")}
placeholder={t("placeholders.url")}
label={t("neetoEditor.menu.link")}
placeholder={t("neetoEditor.placeholders.url")}
style={{ width: "250px" }}
value={urlString}
onChange={({ target: { value } }) => setUrlString(value)}
onFocus={() => setError("")}
onKeyDown={handleKeyDown}
/>
<div className="ne-link-popover__edit-prompt-buttons">
<Button label={t("menu.link")} size="small" onClick={handleLink} />
<Button
label={t("common.cancel")}
label={t("neetoEditor.menu.link")}
size="small"
onClick={handleLink}
/>
<Button
label={t("neetoEditor.common.cancel")}
size="small"
style="text"
onClick={() => {
Expand All @@ -147,15 +151,15 @@ const LinkPopOver = ({ editor }) => {
{" - "}
<Button
className="ne-link-popover__option-button"
label={t("common.edit")}
label={t("neetoEditor.common.edit")}
size="small"
style="link"
onClick={() => setIsEditing(true)}
/>
<span>|</span>
<Button
className="ne-link-popover__option-button"
label={t("common.unlink")}
label={t("neetoEditor.common.unlink")}
size="small"
style="link"
onClick={handleUnlink}
Expand Down
10 changes: 6 additions & 4 deletions src/components/Editor/MediaUploader/LocalUploader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ const LocalUploader = ({
data: file,
});
} catch (error) {
if (error.message !== t("error.onBeforeFileAddedReturn")) {
Toastr.error(t("error.cannotAddFiles"));
if (error.message !== t("neetoEditor.error.onBeforeFileAddedReturn")) {
Toastr.error(t("neetoEditor.error.cannotAddFiles"));
}
}
});
Expand Down Expand Up @@ -129,9 +129,11 @@ const LocalUploader = ({
onChange={handleAddFile}
/>
<ImageUpload className="ne-media-uploader__dnd-icon" size={24} />
<Typography style="body2">{t("localUploader.dropFilesHere")}</Typography>
<Typography style="body2">
{t("neetoEditor.localUploader.dropFilesHere")}
</Typography>
<Typography style="body3">
{t("localUploader.maxFileSize", {
{t("neetoEditor.localUploader.maxFileSize", {
entity: convertToFileSize(uppyConfig.restrictions.maxFileSize),
})}
</Typography>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Editor/MediaUploader/Progress.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const Progress = ({ uppy, pendingUploads, setPendingUploads }) => {
</div>
) : (
<Typography style="body3">
{t("localUploader.completed")}
{t("neetoEditor.localUploader.completed")}
</Typography>
)}
</div>
Expand Down
5 changes: 2 additions & 3 deletions src/components/Editor/MediaUploader/URLForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const URLForm = ({
event.preventDefault();
URL_REGEXP.test(urlString)
? onSubmit(urlString)
: setError(t("error.invalidUrl"));
: setError(t("neetoEditor.error.invalidUrl"));
};

return (
Expand All @@ -33,9 +33,8 @@ const URLForm = ({
<Input
autoFocus
data-cy="neeto-editor-media-upload-url-input"
error={error}
{...{ error, placeholder }}
name="url"
placeholder={placeholder}
value={urlString}
onChange={({ target: { value } }) => setUrlString(value)}
onFocus={() => setError("")}
Expand Down
11 changes: 5 additions & 6 deletions src/components/Editor/MediaUploader/UnsplashImagePicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const UnsplashImagePicker = ({ onSubmit, unsplashApiKey }) => {
className="neeto-editor-unsplash-search"
data-cy="neeto-editor-unsplash-image-picker-search-input"
name="text"
placeholder={t("placeholders.searchUnsplash")}
placeholder={t("neetoEditor.placeholders.searchUnsplash")}
value={query}
onChange={({ target: { value } }) => {
setQuery(value);
Expand All @@ -82,15 +82,15 @@ const UnsplashImagePicker = ({ onSubmit, unsplashApiKey }) => {
className="neeto-editor-unsplash-gallery__text"
data-cy="neeto-editor-unsplash-image-picker-error"
>
{t("unsplash.errorMessage")}
{t("neetoEditor.unsplash.errorMessage")}
</p>
)}
{!error && !loading && isNilOrEmpty(images) && (
<p
className="neeto-editor-unsplash-gallery__text"
data-cy="neeto-editor-unsplash-image-picker-no-results-error"
>
{t("unsplash.noResults")}
{t("neetoEditor.unsplash.noResults")}
</p>
)}
{!error && (
Expand All @@ -99,8 +99,7 @@ const UnsplashImagePicker = ({ onSubmit, unsplashApiKey }) => {
pack
position
className="neeto-editor-unsplash-gallery"
hasMore={hasMore}
loadMore={loadMore}
{...{ hasMore, loadMore }}
loader={Loader}
ref={masonryRef}
style={{ width: "100%" }}
Expand Down Expand Up @@ -146,7 +145,7 @@ const UnsplashImagePicker = ({ onSubmit, unsplashApiKey }) => {
</MasonryInfiniteScroller>
{!hasMore && (
<p className="neeto-editor-unsplash-gallery__text">
{t("unsplash.end")}
{t("neetoEditor.unsplash.end")}
</p>
)}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Editor/MediaUploader/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const MediaUploader = ({ mediaUploader, onClose, editor, unsplashApiKey }) => {
)}
{activeTab === "link" && (
<URLForm
placeholder={t("placeholders.pasteLink")}
placeholder={t("neetoEditor.placeholders.pasteLink")}
buttonLabel={
mediaUploader.image ? "Upload image" : "Upload video"
}
Expand Down
11 changes: 4 additions & 7 deletions src/components/Editor/MediaUploader/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,17 @@ export const buildImageOptions = () => [
{
Icon: LeftAlign,
alignPos: "left",
optionName: t("menu.alignLeft"),
optionName: t("neetoEditor.menu.alignLeft"),
},
{
Icon: CenterAlign,
alignPos: "center",
optionName: t("menu.alignCenter"),
optionName: t("neetoEditor.menu.alignCenter"),
},
{
Icon: RightAlign,
alignPos: "right",
optionName: t("menu.alignRight"),
},
{
Icon: Delete,
optionName: t("menu.delete"),
optionName: t("neetoEditor.menu.alignRight"),
},
{ Icon: Delete, optionName: t("neetoEditor.menu.delete") },
];
2 changes: 1 addition & 1 deletion src/components/Editor/Menu/Bubble/LinkOption.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const LinkOption = ({ editor, handleClose, handleAnimateInvalidLink }) => {
className="neeto-editor-bubble-menu-link__input"
data-cy="neeto-editor-link-input"
name="url"
placeholder={t("placeholders.linkInput")}
placeholder={t("neetoEditor.placeholders.linkInput")}
value={link}
onChange={({ target: { value } }) => setLink(value)}
/>
Expand Down
Loading

0 comments on commit a4b63ec

Please sign in to comment.