Skip to content

Commit

Permalink
Merge pull request #134 from PasteBar/zh-CN-es-ES-uk-languages-support
Browse files Browse the repository at this point in the history
Adding es-ES, uk, it and zh-CH languages support, new requested features and bug fixes
  • Loading branch information
kurdin authored Aug 23, 2024
2 parents 058e310 + 0417fac commit 628ff2c
Show file tree
Hide file tree
Showing 144 changed files with 9,840 additions and 3,001 deletions.
19 changes: 19 additions & 0 deletions .changeset/four-cameras-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
'pastebar-app-ui': minor
---

Added support for zhCN Simplified Chinese language translation (thanks to @katelya77)
Added support for UK Ukrainian language with auto-generated translation (seeking help to improve)
Added support for esES Spanish language with auto-generated translation (seeking help to improve)
Added support for IT Italian language with auto-generated translation (seeking help to improve)
Added data-fn locale for each language
Added global hotkeys for show/hide the main app window option
Added global hotkeys for show/hide Quick Paste window near user's current cursor position
Added hide the app dock icon (macOS) option
Added "The app starts with main window hidden" option
Added "Show navbar elements on hover only" option
Added "Hide collections name on the navbar" option
Added PasteBar Quick Paste window with keyboard navigation, Enter or Ctrl + [number] to paste, Ctrl + F to search
Added Ctrl + click or Cmd + click to multi select/deselect history items
Fixed a bug where the contact form used an invalid link on Windows (#125)
Fixed a bug causing a markdown undefined error on window
3 changes: 0 additions & 3 deletions .env
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
DATABASE_URL=sqlite://local.pastebar-db.data
VITE_ENABLE_REACT_QUERY_DEVTOOLS=
VITE_DISABLE_SAVE_TRANSLATIONS=
VITE_DISABLE_LANGUAGE_FALLBACK=
MISSING_TRANSLATION_SAVE_PATH=../packages/pastebar-app-ui/src/locales/lang
3 changes: 0 additions & 3 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
DATABASE_URL=
VITE_ENABLE_REACT_QUERY_DEVTOOLS=
VITE_DISABLE_SAVE_TRANSLATIONS=
VITE_DISABLE_LANGUAGE_FALLBACK=
MISSING_TRANSLATION_SAVE_PATH=
9 changes: 9 additions & 0 deletions migrations/2023-08-05-230732_seeds/up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ VALUES ('isAutoMaskWordsListEnabled', NULL, false, NULL);
INSERT INTO settings (name, value_text, value_bool, value_int)
VALUES ('isAutoPreviewLinkCardsEnabled', NULL, true, NULL);

INSERT INTO settings (name, value_text, value_bool, value_int)
VALUES ('isHideMacOSDockIcon', NULL, false, NULL);

INSERT INTO settings (name, value_text, value_bool, value_int)
VALUES ('hotKeysShowHideMainAppWindow', '', NULL, NULL);

INSERT INTO settings (name, value_text, value_bool, value_int)
VALUES ('hotKeysShowHideQuickPasteWindow', '', NULL, NULL);

INSERT INTO settings (name, value_text, value_bool, value_int)
VALUES ('isAutoFavoriteOnDoubleCopyEnabled', NULL, true, NULL);

Expand Down
3 changes: 1 addition & 2 deletions packages/pastebar-app-ui/.env.sample
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
VITE_ENABLE_REACT_QUERY_DEVTOOLS=
VITE_DISABLE_SAVE_TRANSLATIONS=
VITE_DISABLE_LANGUAGE_FALLBACK=
VITE_ENABLE_DEV_AUTO_UPDATER=
PASTEBAR_APP_PATH=../..
VITE_CONTACT_SERVER_URL=https://contact.pastebar.app
28 changes: 28 additions & 0 deletions packages/pastebar-app-ui/quickpaste-index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<!-- react-debugger, run on dev: npx react-devtools -->
<!-- <script src="http://localhost:8097"></script> -->
<link rel="preload" href="src/assets/SourceCodePro-Regular.otf.woff2" as="font" type="font/woff2" crossorigin />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>PasteBar App</title>
</head>
<body class="bg-transparent">
<div id="root"></div>
<script>
window.isHistoryWindow = false;
window.isQuickPasteWindow = true;
window.isMainWindow = false;
</script>
<script type="module" src="src/quickpaste-main.tsx"></script>
<script>
function handleDrop(e) {
e.preventDefault();
}

window.addEventListener("dragover", handleDrop, false);
window.addEventListener("drop", handleDrop, false);
</script>
</body>
</html>
61 changes: 55 additions & 6 deletions packages/pastebar-app-ui/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useCallback, useEffect, useRef } from 'react'
import { useQueryClient } from '@tanstack/react-query'
import { listen } from '@tauri-apps/api/event'
import { register, unregisterAll } from '@tauri-apps/api/globalShortcut'
import { type } from '@tauri-apps/api/os'
import { invoke } from '@tauri-apps/api/tauri'
import { appWindow, LogicalSize, WebviewWindow } from '@tauri-apps/api/window'
Expand Down Expand Up @@ -77,9 +78,7 @@ function App() {
}, [isAppLocked.value])

useEffect(() => {
const appReadyResponse = appReady()

appReadyResponse.then(res => {
appReady().then(res => {
if (res === null) return

try {
Expand Down Expand Up @@ -110,6 +109,10 @@ function App() {
appDataDir: import.meta.env.TAURI_DEBUG ? appDevDataDir : appDataDir,
appLastUpdateVersion: settings.appLastUpdateVersion?.valueText,
appLastUpdateDate: settings.appLastUpdateDate?.valueText,
isHideMacOSDockIcon: settings.isHideMacOSDockIcon?.valueBool,
hotKeysShowHideMainAppWindow: settings.hotKeysShowHideMainAppWindow?.valueText,
hotKeysShowHideQuickPasteWindow:
settings.hotKeysShowHideQuickPasteWindow?.valueText,
isFirstRun: settings.isFirstRun?.valueBool,
isFirstRunAfterUpdate: settings.isFirstRunAfterUpdate?.valueBool,
isHistoryDetectLanguageEnabled:
Expand All @@ -118,6 +121,8 @@ function App() {
historyExclusionList: settings.historyExclusionList?.valueText,
historyExclusionAppList: settings.historyExclusionAppList?.valueText,
isExclusionListEnabled: settings.isExclusionListEnabled?.valueBool,
isKeepMainWindowClosedOnRestartEnabled:
settings.isKeepMainWindowClosedOnRestartEnabled?.valueBool,
isExclusionAppListEnabled: settings.isExclusionAppListEnabled?.valueBool,
isAutoMaskWordsListEnabled: settings.isAutoMaskWordsListEnabled?.valueBool,
autoMaskWordsList: settings.autoMaskWordsList?.valueText,
Expand Down Expand Up @@ -168,6 +173,8 @@ function App() {
isSearchNameOrLabelOnly: settings.isSearchNameOrLabelOnly?.valueBool,
isSkipAutoStartPrompt: settings.isSkipAutoStartPrompt?.valueBool,
isShowCollectionNameOnNavBar: settings.isShowCollectionNameOnNavBar?.valueBool,
isHideCollectionsOnNavBar: settings.isHideCollectionsOnNavBar?.valueBool,
isShowNavBarItemsOnHoverOnly: settings.isShowNavBarItemsOnHoverOnly?.valueBool,
isShowDisabledCollectionsOnNavBarMenu:
settings.isShowDisabledCollectionsOnNavBarMenu?.valueBool,
userSelectedLanguage: settings.userSelectedLanguage?.valueText,
Expand Down Expand Up @@ -203,6 +210,37 @@ function App() {
isAppLocked.value = true
}

if (settings.hotKeysShowHideMainAppWindow?.valueText) {
try {
register(settings.hotKeysShowHideMainAppWindow?.valueText, async () => {
if (document.hasFocus()) {
await appWindow.hide()
} else {
await appWindow.show()
await appWindow.setFocus()
}
}).catch(e => {
console.error(e)
})
} catch (e) {
console.error(e)
}
}

if (settings.hotKeysShowHideQuickPasteWindow?.valueText) {
try {
register(settings.hotKeysShowHideQuickPasteWindow?.valueText, async () => {
await uiStore.toggleHistoryQuickPasteWindow(
t('PasteBar Quick Paste', { ns: 'settings2' })
)
}).catch(e => {
console.error(e)
})
} catch (e) {
console.error(e)
}
}

if (
!settings.appToursCompletedList?.valueText
.split(',')
Expand Down Expand Up @@ -419,6 +457,10 @@ function App() {
})

return () => {
if (window.isMainWindow) {
unregisterAll()
}

listenToNavigateUnlisten.then(unlisten => {
unlisten()
})
Expand Down Expand Up @@ -479,11 +521,14 @@ function App() {
}, [uiState.fontSize])

useEffect(() => {
if (uiState.isSplitPanelView && window.isMainWindow) {
if (uiState.isSplitPanelView && window.isMainWindow && settingsStore.isAppReady) {
const openHistoryWindow = async () => {
invoke('open_history_window', { width: 0 }).then(() => {
invoke('open_history_window').then(() => {
historyWindowOpening.value = false
setTimeout(() => {
if (settingsStore.isKeepMainWindowClosedOnRestartEnabled) {
appWindow.hide()
}
historyWindow?.setFocus()
}, 300)
})
Expand All @@ -497,7 +542,11 @@ function App() {
historyWindow?.setFocus()
}, 300)
}
}, [uiState.isSplitPanelView])
}, [
uiState.isSplitPanelView,
settingsStore.isAppReady,
settingsStore.isKeepMainWindowClosedOnRestartEnabled,
])

return (
<>
Expand Down
Loading

0 comments on commit 628ff2c

Please sign in to comment.