From 4354ee7ba1c6ac9a9567944ae6169b1664e0ea8a Mon Sep 17 00:00:00 2001
From: Mohamed Bassem <me@mbassem.com>
Date: Sun, 17 Nov 2024 00:33:28 +0000
Subject: feature: Add i18n support. Fixes #57 (#635)

* feature(web): Add basic scaffolding for i18n

* refactor: Switch most of the app's strings to use i18n strings

* fix: Remove unused i18next-resources-for-ts command

* Add user setting

* More translations

* Drop the german translation for now
---
 .../components/dashboard/BulkBookmarksAction.tsx   | 28 ++++++++++++----------
 1 file changed, 16 insertions(+), 12 deletions(-)

(limited to 'apps/web/components/dashboard/BulkBookmarksAction.tsx')

diff --git a/apps/web/components/dashboard/BulkBookmarksAction.tsx b/apps/web/components/dashboard/BulkBookmarksAction.tsx
index c78b65db..eb0e0cec 100644
--- a/apps/web/components/dashboard/BulkBookmarksAction.tsx
+++ b/apps/web/components/dashboard/BulkBookmarksAction.tsx
@@ -9,6 +9,7 @@ import {
 import ActionConfirmingDialog from "@/components/ui/action-confirming-dialog";
 import { useToast } from "@/components/ui/use-toast";
 import useBulkActionsStore from "@/lib/bulkActions";
+import { useTranslation } from "@/lib/i18n/client";
 import {
   CheckCheck,
   FileDown,
@@ -33,6 +34,7 @@ import BulkTagModal from "./bookmarks/BulkTagModal";
 import { ArchivedActionIcon, FavouritedActionIcon } from "./bookmarks/icons";
 
 export default function BulkBookmarksAction() {
+  const { t } = useTranslation();
   const { selectedBookmarks, isBulkEditEnabled } = useBulkActionsStore();
   const setIsBulkEditEnabled = useBulkActionsStore(
     (state) => state.setIsBulkEditEnabled,
@@ -179,7 +181,7 @@ export default function BulkBookmarksAction() {
   const actionList = [
     {
       name: isClipboardAvailable()
-        ? "Copy Links"
+        ? t("actions.copy_link")
         : "Copying is only available over https",
       icon: <Link size={18} />,
       action: () => copyLinks(),
@@ -187,55 +189,57 @@ export default function BulkBookmarksAction() {
       hidden: !isBulkEditEnabled,
     },
     {
-      name: "Add to List",
+      name: t("actions.add_to_list"),
       icon: <List size={18} />,
       action: () => setManageListsModalOpen(true),
       isPending: false,
       hidden: !isBulkEditEnabled,
     },
     {
-      name: "Edit Tags",
+      name: t("actions.edit_tags"),
       icon: <Hash size={18} />,
       action: () => setBulkTagModalOpen(true),
       isPending: false,
       hidden: !isBulkEditEnabled,
     },
     {
-      name: alreadyFavourited ? "Unfavourite" : "Favourite",
+      name: alreadyFavourited ? t("actions.unfavorite") : t("actions.favorite"),
       icon: <FavouritedActionIcon favourited={!!alreadyFavourited} size={18} />,
       action: () => updateBookmarks({ favourited: !alreadyFavourited }),
       isPending: updateBookmarkMutator.isPending,
       hidden: !isBulkEditEnabled,
     },
     {
-      name: alreadyArchived ? "Un-archive" : "Archive",
+      name: alreadyArchived ? t("actions.unarchive") : t("actions.archive"),
       icon: <ArchivedActionIcon size={18} archived={!!alreadyArchived} />,
       action: () => updateBookmarks({ archived: !alreadyArchived }),
       isPending: updateBookmarkMutator.isPending,
       hidden: !isBulkEditEnabled,
     },
     {
-      name: "Download Full Page Archive",
+      name: t("actions.download_full_page_archive"),
       icon: <FileDown size={18} />,
       action: () => recrawlBookmarks(true),
       isPending: recrawlBookmarkMutator.isPending,
       hidden: !isBulkEditEnabled,
     },
     {
-      name: "Refresh",
+      name: t("actions.refresh"),
       icon: <RotateCw size={18} />,
       action: () => recrawlBookmarks(false),
       isPending: recrawlBookmarkMutator.isPending,
       hidden: !isBulkEditEnabled,
     },
     {
-      name: "Delete",
+      name: t("actions.delete"),
       icon: <Trash2 size={18} color="red" />,
       action: () => setIsDeleteDialogOpen(true),
       hidden: !isBulkEditEnabled,
     },
     {
-      name: isEverythingSelected() ? "Unselect All" : "Select All",
+      name: isEverythingSelected()
+        ? t("actions.unselect_all")
+        : t("actions.select_all"),
       icon: (
         <p className="flex items-center gap-2">
           ( <CheckCheck size={18} /> {selectedBookmarks.length} )
@@ -247,14 +251,14 @@ export default function BulkBookmarksAction() {
       hidden: !isBulkEditEnabled,
     },
     {
-      name: "Close bulk edit",
+      name: t("actions.close_bulk_edit"),
       icon: <X size={18} />,
       action: () => setIsBulkEditEnabled(false),
       alwaysEnable: true,
       hidden: !isBulkEditEnabled,
     },
     {
-      name: "Bulk Edit",
+      name: t("actions.bulk_edit"),
       icon: <Pencil size={18} />,
       action: () => setIsBulkEditEnabled(true),
       alwaysEnable: true,
@@ -276,7 +280,7 @@ export default function BulkBookmarksAction() {
             loading={deleteBookmarkMutator.isPending}
             onClick={() => deleteBookmarks()}
           >
-            Delete
+            {t("actions.delete")}
           </ActionButton>
         )}
       />
-- 
cgit v1.2.3-70-g09d2

