From 8eb12b2280fc6c36e455f67cc64582cb29e750d6 Mon Sep 17 00:00:00 2001 From: hasecilu Date: Mon, 2 Sep 2024 18:16:21 -0600 Subject: [PATCH 01/43] i18n: Complete Spanish translation again --- README.es.md | 2 +- src/public/translations/es/translation.json | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.es.md b/README.es.md index c470ca01d..127a7bfe0 100644 --- a/README.es.md +++ b/README.es.md @@ -18,7 +18,7 @@ No hay pasos de migración especiales para migrar de una instancia de zadam/Tril ## 💬 Discuta con nosotros -Siéntase libre de unirse a nuestras conversaciones oficiales. ¡Nos encantaría escuchar de las características, sugerencias o problemas pueda tener! +Siéntase libre de unirse a nuestras conversaciones oficiales. ¡Nos encantaría escuchar de las características, sugerencias o problemas que pueda tener! - [Matrix](https://matrix.to/#/#triliumnext:matrix.org) (Para discusiones síncronas) - La sala `General` es replicada a [XMPP](xmpp:discuss@trilium.thisgreat.party?join) diff --git a/src/public/translations/es/translation.json b/src/public/translations/es/translation.json index 6f98ddd27..638658c61 100644 --- a/src/public/translations/es/translation.json +++ b/src/public/translations/es/translation.json @@ -645,6 +645,9 @@ "hide_floating_buttons_button": { "button_title": "Ocultar botones" }, + "svg_export_button": { + "button_title": "Exportar diagrama como SVG" + }, "relation_map_buttons": { "create_child_note_title": "Crear una nueva nota hijo y agregarla a este mapa de relaciones", "reset_pan_zoom_title": "Restablecer la panorámica y el zoom a las coordenadas y ampliación iniciales", @@ -1078,7 +1081,7 @@ "save_button": "Guardar" }, "tray": { - "title": "Bandeja", + "title": "Bandeja de sistema", "enable_tray": "Habilitar bandeja (es necesario reiniciar Trilium para que este cambio surta efecto)" }, "heading_style": { From 42c714891a7c9bd41e590386d37844ac40830c9c Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Fri, 6 Sep 2024 23:12:37 +0300 Subject: [PATCH 02/43] ci: Set up a test release process --- .github/workflows/main.yml | 1 - .github/workflows/release.yml | 102 ++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 85e8e7590..5ef3025fb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,7 +2,6 @@ name: Main on: push: branches: - - "develop" - "feature/update**" - "feature/server_esm**" paths-ignore: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..054781af1 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,102 @@ +name: Main +on: + push: + branches: + - develop + workflow_dispatch: +permissions: + contents: write +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + make-electron: + name: Make Electron + strategy: + fail-fast: false + matrix: + arch: [x64, arm64] + os: + - name: macos + image: macos-latest + extension: dmg + - name: linux + image: ubuntu-latest + extension: deb + - name: windows + image: windows-latest + extension: exe + runs-on: ${{ matrix.os.image }} + steps: + - uses: actions/checkout@v4 + - name: Set up node & dependencies + uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Set up Python for appdmg to be installed + if: ${{ matrix.os.name == 'macos' }} + run: brew install python-setuptools + - name: Install dependencies + run: npm ci + - name: Update build info + run: npm run update-build-info + - name: Run electron-forge + run: npm run make-electron -- --arch=${{ matrix.arch }} + - name: Prepare artifacts (Unix) + if: runner.os != 'windows' + run: | + mkdir -p upload + file=$(find out/make -name '*.zip' -print -quit) + cp "$file" "upload/TriliumNextNotes-${{ matrix.os.name }}-${{ matrix.arch }}-${{ github.ref_name }}.zip" + file=$(find out/make -name '*.${{ matrix.os.extension }}' -print -quit) + cp "$file" "upload/TriliumNextNotes-${{ matrix.os.name }}-${{ matrix.arch }}-${{ github.ref_name }}.${{ matrix.os.extension }}" + - name: Prepare artifacts (Windows) + if: runner.os == 'windows' + run: | + mkdir upload + $file = Get-ChildItem -Path out/make -Filter '*.zip' -Recurse | Select-Object -First 1 + Copy-Item -Path $file.FullName -Destination "upload/TriliumNextNotes-${{ matrix.os.name }}-${{ matrix.arch }}-${{ github.ref_name }}.zip" + $file = Get-ChildItem -Path out/make -Filter '*.${{ matrix.os.extension }}' -Recurse | Select-Object -First 1 + Copy-Item -Path $file.FullName -Destination "upload/TriliumNextNotes-${{ matrix.os.name }}-${{ matrix.arch }}-${{ github.ref_name }}.${{ matrix.os.extension }}" + - name: Publish artifacts + uses: actions/upload-artifact@v4 + with: + name: TriliumNextNotes ${{ matrix.os.name }} ${{ matrix.arch }}.zip + path: upload/*.zip + - name: Rename the output artifact + run: | + mv upload/*.${{ matrix.os.extension }} "upload/TriliumNextNotes ${{ matrix.os.name }} ${{ matrix.arch }}.${{matrix.os.extension}}" + - name: Publish test + uses: softprops/action-gh-release@v2 + with: + draft: true + tag_name: test_release + fail_on_unmatched_files: true + files: upload/*.${{matrix.os.extension}} + build_linux_server-x64: + name: Build Linux Server x86_64 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up node & dependencies + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "npm" + - name: Install dependencies + run: npm ci + - name: Run Linux server build (x86_64) + run: | + npm run update-build-info + ./bin/build-server.sh + - name: Prepare artifacts + if: runner.os != 'windows' + run: | + mkdir -p upload + file=$(find dist -name '*.tar.xz' -print -quit) + cp "$file" "upload/TriliumNextNotes-linux-x64-${{ github.ref_name }}.tar.xz" + - uses: actions/upload-artifact@v4 + with: + name: TriliumNextNotes linux server x64 + path: upload/TriliumNextNotes-linux-x64-${{ github.ref_name }}.tar.xz From 7248d5bab8ab8911c7072d84d08209dca79d0112 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Fri, 6 Sep 2024 23:59:09 +0300 Subject: [PATCH 03/43] ci: Release ZIP artifacts as well --- .github/workflows/release.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 054781af1..f936f7e90 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -67,13 +67,16 @@ jobs: - name: Rename the output artifact run: | mv upload/*.${{ matrix.os.extension }} "upload/TriliumNextNotes ${{ matrix.os.name }} ${{ matrix.arch }}.${{matrix.os.extension}}" + mv upload/*.zip "upload/TriliumNextNotes ${{ matrix.os.name }} ${{ matrix.arch }}.zip" - name: Publish test uses: softprops/action-gh-release@v2 with: draft: true tag_name: test_release fail_on_unmatched_files: true - files: upload/*.${{matrix.os.extension}} + files: | + upload/*.${{matrix.os.extension}} + upload/*.zip build_linux_server-x64: name: Build Linux Server x86_64 runs-on: ubuntu-latest From c964f9eeff5c8756ac68b4b4e49c15a541947111 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 7 Sep 2024 00:20:38 +0300 Subject: [PATCH 04/43] ci: Upload server build as well --- .github/workflows/release.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f936f7e90..e42501ac1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -68,7 +68,7 @@ jobs: run: | mv upload/*.${{ matrix.os.extension }} "upload/TriliumNextNotes ${{ matrix.os.name }} ${{ matrix.arch }}.${{matrix.os.extension}}" mv upload/*.zip "upload/TriliumNextNotes ${{ matrix.os.name }} ${{ matrix.arch }}.zip" - - name: Publish test + - name: Publish release uses: softprops/action-gh-release@v2 with: draft: true @@ -98,8 +98,12 @@ jobs: run: | mkdir -p upload file=$(find dist -name '*.tar.xz' -print -quit) - cp "$file" "upload/TriliumNextNotes-linux-x64-${{ github.ref_name }}.tar.xz" - - uses: actions/upload-artifact@v4 + cp "$file" "upload/TriliumNextNotes-linux-x64-${{ github.ref_name }}.tar.xz" + - name: Publish release + uses: softprops/action-gh-release@v2 with: - name: TriliumNextNotes linux server x64 - path: upload/TriliumNextNotes-linux-x64-${{ github.ref_name }}.tar.xz + draft: true + tag_name: test_release + fail_on_unmatched_files: true + files: | + upload/*.xz \ No newline at end of file From e4d6ab3a6e922bff11df34f9f37c64ca90ae8cbe Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 7 Sep 2024 00:46:58 +0300 Subject: [PATCH 05/43] ci: Refactor release workflow & add version in name --- .github/workflows/release.yml | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e42501ac1..caa84a042 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -48,35 +48,24 @@ jobs: run: | mkdir -p upload file=$(find out/make -name '*.zip' -print -quit) - cp "$file" "upload/TriliumNextNotes-${{ matrix.os.name }}-${{ matrix.arch }}-${{ github.ref_name }}.zip" + cp "$file" "upload/TriliumNextNotes-${{ github.ref_name }}-${{ matrix.os.name }}-${{ matrix.arch }}.zip" file=$(find out/make -name '*.${{ matrix.os.extension }}' -print -quit) - cp "$file" "upload/TriliumNextNotes-${{ matrix.os.name }}-${{ matrix.arch }}-${{ github.ref_name }}.${{ matrix.os.extension }}" + cp "$file" "upload/TriliumNextNotes-${{ github.ref_name }}-${{ matrix.os.name }}-${{ matrix.arch }}.${{ matrix.os.extension }}" - name: Prepare artifacts (Windows) if: runner.os == 'windows' run: | mkdir upload $file = Get-ChildItem -Path out/make -Filter '*.zip' -Recurse | Select-Object -First 1 - Copy-Item -Path $file.FullName -Destination "upload/TriliumNextNotes-${{ matrix.os.name }}-${{ matrix.arch }}-${{ github.ref_name }}.zip" + Copy-Item -Path $file.FullName -Destination "upload/TriliumNextNotes-${{ github.ref_name }}-${{ matrix.os.name }}-${{ matrix.arch }}.zip" $file = Get-ChildItem -Path out/make -Filter '*.${{ matrix.os.extension }}' -Recurse | Select-Object -First 1 - Copy-Item -Path $file.FullName -Destination "upload/TriliumNextNotes-${{ matrix.os.name }}-${{ matrix.arch }}-${{ github.ref_name }}.${{ matrix.os.extension }}" - - name: Publish artifacts - uses: actions/upload-artifact@v4 - with: - name: TriliumNextNotes ${{ matrix.os.name }} ${{ matrix.arch }}.zip - path: upload/*.zip - - name: Rename the output artifact - run: | - mv upload/*.${{ matrix.os.extension }} "upload/TriliumNextNotes ${{ matrix.os.name }} ${{ matrix.arch }}.${{matrix.os.extension}}" - mv upload/*.zip "upload/TriliumNextNotes ${{ matrix.os.name }} ${{ matrix.arch }}.zip" + Copy-Item -Path $file.FullName -Destination "upload/TriliumNextNotes-${{ github.ref_name }}-${{ matrix.os.name }}-${{ matrix.arch }}.${{ matrix.os.extension }}" - name: Publish release uses: softprops/action-gh-release@v2 with: draft: true tag_name: test_release fail_on_unmatched_files: true - files: | - upload/*.${{matrix.os.extension}} - upload/*.zip + files: upload/*.* build_linux_server-x64: name: Build Linux Server x86_64 runs-on: ubuntu-latest @@ -98,12 +87,11 @@ jobs: run: | mkdir -p upload file=$(find dist -name '*.tar.xz' -print -quit) - cp "$file" "upload/TriliumNextNotes-linux-x64-${{ github.ref_name }}.tar.xz" + cp "$file" "upload/TriliumNextNotes-${{ github.ref_name }}-linux-x64.tar.xz" - name: Publish release uses: softprops/action-gh-release@v2 with: draft: true tag_name: test_release fail_on_unmatched_files: true - files: | - upload/*.xz \ No newline at end of file + files: upload/*.* \ No newline at end of file From 6dee56d72e3f5bcdd6cf12e42400deab491ec2c3 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 7 Sep 2024 09:34:59 +0300 Subject: [PATCH 06/43] Prepare for release --- .github/workflows/release.yml | 4 ++-- bin/release.sh | 32 -------------------------------- 2 files changed, 2 insertions(+), 34 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index caa84a042..e888fef32 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,8 +1,8 @@ name: Main on: push: - branches: - - develop + tags: + - v* workflow_dispatch: permissions: contents: write diff --git a/bin/release.sh b/bin/release.sh index 30dd0c462..fea1e030f 100755 --- a/bin/release.sh +++ b/bin/release.sh @@ -47,35 +47,3 @@ echo "Tagging commit with $TAG" git tag $TAG git push origin $TAG - -bin/build.sh - -LINUX_X64_BUILD=trilium-linux-x64-$VERSION.tar.xz -DEBIAN_X64_BUILD=trilium_${VERSION}_amd64.deb -WINDOWS_X64_BUILD=trilium-windows-x64-$VERSION.zip -MAC_X64_BUILD=trilium-mac-x64-$VERSION.zip -MAC_ARM64_BUILD=trilium-mac-arm64-$VERSION.zip -SERVER_BUILD=trilium-linux-x64-server-$VERSION.tar.xz - -echo "Creating release in GitHub" - -EXTRA= - -if [[ $TAG == *"beta"* ]]; then - EXTRA=--prerelease -fi - -if [ ! -z "$GITHUB_CLI_AUTH_TOKEN" ]; then - echo "$GITHUB_CLI_AUTH_TOKEN" | gh auth login --with-token -fi - -gh release create -d "$TAG" \ - --title "$TAG release" \ - --notes "" \ - $EXTRA \ - "dist/$DEBIAN_X64_BUILD" \ - "dist/$LINUX_X64_BUILD" \ - "dist/$WINDOWS_X64_BUILD" \ - "dist/$MAC_X64_BUILD" \ - "dist/$MAC_ARM64_BUILD" \ - "dist/$SERVER_BUILD" From 89beda16fded71ca1f4f060418d1ba112ced44aa Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 7 Sep 2024 09:42:08 +0300 Subject: [PATCH 07/43] Clean up workflow --- .github/workflows/main.yml | 2 -- .github/workflows/release.yml | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5ef3025fb..2628a4ebb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,8 +7,6 @@ on: paths-ignore: - "docs/**" - ".github/workflows/main-docker.yml" - tags: - - "v*" workflow_dispatch: concurrency: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e888fef32..ddd49aa2e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,8 +1,8 @@ -name: Main +name: Release on: push: tags: - - v* + - "v*" workflow_dispatch: permissions: contents: write From c6abbf0cf7617dc4e16c7a4900e5a5320bdac782 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 7 Sep 2024 09:49:54 +0300 Subject: [PATCH 08/43] ci: Remove test name for release --- .github/workflows/release.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ddd49aa2e..95e0b90b7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -63,7 +63,6 @@ jobs: uses: softprops/action-gh-release@v2 with: draft: true - tag_name: test_release fail_on_unmatched_files: true files: upload/*.* build_linux_server-x64: @@ -92,6 +91,5 @@ jobs: uses: softprops/action-gh-release@v2 with: draft: true - tag_name: test_release fail_on_unmatched_files: true files: upload/*.* \ No newline at end of file From 4f6392ce14f2cd727f6ce93499fd0c8ba686321e Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 7 Sep 2024 10:02:28 +0300 Subject: [PATCH 09/43] ci: Rename server release artifact --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 95e0b90b7..0e1239625 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -86,7 +86,7 @@ jobs: run: | mkdir -p upload file=$(find dist -name '*.tar.xz' -print -quit) - cp "$file" "upload/TriliumNextNotes-${{ github.ref_name }}-linux-x64.tar.xz" + cp "$file" "upload/TriliumNextNotes-${{ github.ref_name }}-server-linux-x64.tar.xz" - name: Publish release uses: softprops/action-gh-release@v2 with: From 1c8cc3640240ac38a9761da48108c6ce0a017fdc Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 7 Sep 2024 10:02:55 +0300 Subject: [PATCH 10/43] release 0.90.5-beta --- package.json | 2 +- src/services/build.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 520c89ca6..fa556bca7 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "trilium", "productName": "TriliumNext Notes", "description": "Build your personal knowledge base with TriliumNext Notes", - "version": "0.90.4", + "version": "0.90.5-beta", "license": "AGPL-3.0-only", "main": "./dist/electron.js", "author": { diff --git a/src/services/build.ts b/src/services/build.ts index e56f37eea..01dbdd5d0 100644 --- a/src/services/build.ts +++ b/src/services/build.ts @@ -1,4 +1,4 @@ export default { - buildDate: "2024-08-09T22:05:59Z", - buildRevision: "2a5c444eff3eb99389339716ea8bfc989be90ecd" + buildDate: "2024-09-07T07:02:55Z", + buildRevision: "4f6392ce14f2cd727f6ce93499fd0c8ba686321e" }; From 7c0d6930fa8f20d269dcfbcbc8f636a25f6bb9a7 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 7 Sep 2024 21:35:51 +0300 Subject: [PATCH 11/43] build: Revert alpine build --- .github/workflows/main-docker-alpine.yml | 10 ---------- .github/workflows/main-docker.yml | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/.github/workflows/main-docker-alpine.yml b/.github/workflows/main-docker-alpine.yml index 3f9e24eea..cbf195c86 100644 --- a/.github/workflows/main-docker-alpine.yml +++ b/.github/workflows/main-docker-alpine.yml @@ -1,14 +1,4 @@ on: - push: - branches: - - "develop" - - "feature/update**" - - "feature/server_esm**" - paths-ignore: - - "docs/**" - - "bin/**" - tags: - - "v*" workflow_dispatch: env: diff --git a/.github/workflows/main-docker.yml b/.github/workflows/main-docker.yml index 52421b969..70a3592b1 100644 --- a/.github/workflows/main-docker.yml +++ b/.github/workflows/main-docker.yml @@ -16,7 +16,7 @@ env: DOCKERHUB_REGISTRY: docker.io IMAGE_NAME: ${{ github.repository }} TEST_TAG: triliumnext/notes:test - PLATFORMS: linux/arm64,linux/arm/v7 + PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7 jobs: test_docker: From 4106cc61b554137ee10ab84feebd6f2186759768 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 7 Sep 2024 21:36:34 +0300 Subject: [PATCH 12/43] release 0.90.6-beta --- package.json | 2 +- src/services/build.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index fa556bca7..b4e5299dd 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "trilium", "productName": "TriliumNext Notes", "description": "Build your personal knowledge base with TriliumNext Notes", - "version": "0.90.5-beta", + "version": "0.90.6-beta", "license": "AGPL-3.0-only", "main": "./dist/electron.js", "author": { diff --git a/src/services/build.ts b/src/services/build.ts index 01dbdd5d0..ea9553c7f 100644 --- a/src/services/build.ts +++ b/src/services/build.ts @@ -1,4 +1,4 @@ export default { - buildDate: "2024-09-07T07:02:55Z", - buildRevision: "4f6392ce14f2cd727f6ce93499fd0c8ba686321e" + buildDate: "2024-09-07T18:36:34Z", + buildRevision: "7c0d6930fa8f20d269dcfbcbc8f636a25f6bb9a7" }; From 0ac1f071cd68cade3f30300c4abc8d28a2308a2e Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 8 Sep 2024 11:33:37 +0300 Subject: [PATCH 13/43] i18n: Tweak two Romanian translations --- src/public/translations/ro/translation.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/public/translations/ro/translation.json b/src/public/translations/ro/translation.json index f3285c4e7..156869d3a 100644 --- a/src/public/translations/ro/translation.json +++ b/src/public/translations/ro/translation.json @@ -142,8 +142,8 @@ "icon_class": "valoarea acestei etichete este adăugată ca o clasă CSS la iconița notiței din ierarhia notițelor, fapt ce poate ajuta la identificarea vizuală mai rapidă a notițelor. Un exemplu ar fi „bx bx-home” pentru iconițe preluate din boxicons. Poate fi folosită în notițe de tip șablon.", "inbox": "locația implicită în care vor apărea noile notițe atunci când se crează o noitiță utilizând butonul „Crează notiță” din bara laterală, notițele vor fi create în interiorul notiței cu această etichetă.", "inherit": "atributele acestei notițe vor fi moștenite chiar dacă nu există o relație părinte-copil între notițe. A se vedea relația de tip șablon pentru un concept similar. De asemenea, a se vedea moștenirea atributelor în documentație.", - "inheritable": "Moștenibil", - "inheritable_title": "Atributele moștenibile vor fi moștenite tuturor descendenților acestei notițe.", + "inheritable": "Moștenibilă", + "inheritable_title": "Atributele moștenibile vor fi moștenite de către toți descendenții acestei notițe.", "inverse_relation": "Relație inversă", "inverse_relation_title": "Setare opțională pentru a defini relația inversă. Exemplu: Tată - Fiu sunt două relații inverse.", "is_owned_by_note": "este deținut(ă) de notița", @@ -1220,7 +1220,7 @@ }, "vim_key_bindings": { "enable_vim_keybindings": "Activează combinațiile de taste Vim", - "use_vim_keybindings_in_code_notes": "Permite utilizarea combinațiilor de taste în stil Vim pentru notițeled e tip cod (fără modul ex)" + "use_vim_keybindings_in_code_notes": "Permite utilizarea combinațiilor de taste în stil Vim pentru notițele de tip cod (fără modul ex)" }, "web_view": { "create_label": "Pentru a începe, creați o etichetă cu adresa URL de încorporat, e.g. #webViewSrc=\"https://www.google.com\"", From 7a567583f2b77608a9139d7e0ef6df7fb4217d3a Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 8 Sep 2024 11:49:23 +0300 Subject: [PATCH 14/43] i18n: Improve keybindings phrasing --- src/public/translations/cn/translation.json | 4 ++-- src/public/translations/en/translation.json | 4 ++-- src/public/translations/es/translation.json | 4 ++-- src/public/translations/ro/translation.json | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/public/translations/cn/translation.json b/src/public/translations/cn/translation.json index 950a24805..8cdf4e411 100644 --- a/src/public/translations/cn/translation.json +++ b/src/public/translations/cn/translation.json @@ -1023,8 +1023,8 @@ "title": "下拉菜单可用的MIME文件类型" }, "vim_key_bindings": { - "use_vim_keybindings_in_code_notes": "在代码笔记中使用Vim键绑定(无ex模式)", - "enable_vim_keybindings": "启用Vim键绑定" + "use_vim_keybindings_in_code_notes": "", + "enable_vim_keybindings": "" }, "wrap_lines": { "wrap_lines_in_code_notes": "代码笔记自动换行", diff --git a/src/public/translations/en/translation.json b/src/public/translations/en/translation.json index d92f2fe60..8273e6912 100644 --- a/src/public/translations/en/translation.json +++ b/src/public/translations/en/translation.json @@ -1026,8 +1026,8 @@ "title": "Available MIME types in the dropdown" }, "vim_key_bindings": { - "use_vim_keybindings_in_code_notes": "Use vim keybindings in code notes (no ex mode)", - "enable_vim_keybindings": "Enable Vim Keybindings" + "use_vim_keybindings_in_code_notes": "Vim keybindings", + "enable_vim_keybindings": "Enable Vim keybindings in code notes (no ex mode)" }, "wrap_lines": { "wrap_lines_in_code_notes": "Wrap lines in code notes", diff --git a/src/public/translations/es/translation.json b/src/public/translations/es/translation.json index 638658c61..45da9a3e2 100644 --- a/src/public/translations/es/translation.json +++ b/src/public/translations/es/translation.json @@ -1026,8 +1026,8 @@ "title": "Tipos MIME disponibles en el menú desplegable" }, "vim_key_bindings": { - "use_vim_keybindings_in_code_notes": "Utilizar combinaciones de teclas Vim en notas de código (no modo ex)", - "enable_vim_keybindings": "Habilitar combinaciones de teclas de Vim" + "use_vim_keybindings_in_code_notes": "", + "enable_vim_keybindings": "" }, "wrap_lines": { "wrap_lines_in_code_notes": "Ajustar líneas en notas de código", diff --git a/src/public/translations/ro/translation.json b/src/public/translations/ro/translation.json index 156869d3a..a4de3e3c2 100644 --- a/src/public/translations/ro/translation.json +++ b/src/public/translations/ro/translation.json @@ -1219,8 +1219,8 @@ "vacuuming_database": "Baza de date este în curs de compactare..." }, "vim_key_bindings": { - "enable_vim_keybindings": "Activează combinațiile de taste Vim", - "use_vim_keybindings_in_code_notes": "Permite utilizarea combinațiilor de taste în stil Vim pentru notițele de tip cod (fără modul ex)" + "enable_vim_keybindings": "Permite utilizarea combinațiilor de taste în stil Vim pentru notițele de tip cod (fără modul ex)", + "use_vim_keybindings_in_code_notes": "Combinații de taste Vim" }, "web_view": { "create_label": "Pentru a începe, creați o etichetă cu adresa URL de încorporat, e.g. #webViewSrc=\"https://www.google.com\"", From 4f7bbee7690753c89397de486e1744e980f7d2b6 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 8 Sep 2024 11:53:36 +0300 Subject: [PATCH 15/43] i18n: Fix erase attachments button translation --- src/public/translations/es/translation.json | 2 +- src/public/translations/ro/translation.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/public/translations/es/translation.json b/src/public/translations/es/translation.json index 45da9a3e2..c1176ad22 100644 --- a/src/public/translations/es/translation.json +++ b/src/public/translations/es/translation.json @@ -1046,7 +1046,7 @@ "attachment_auto_deletion_description": "Los archivos adjuntos se eliminan (y borran) automáticamente si ya no se hace referencia a ellos en su nota después de un tiempo de espera definido.", "erase_attachments_after_x_seconds": "Borrar archivos adjuntos después de X segundos de no usarse en su nota", "manual_erasing_description": "También puede activar el borrado manualmente (sin considerar el tiempo de espera definido anteriormente):", - "erase_unused_attachments_now": "Borrar ahora los archivos adjuntos no utilizados en la nota ", + "erase_unused_attachments_now": "Borrar ahora los archivos adjuntos no utilizados en la nota", "unused_attachments_erased": "Los archivos adjuntos no utilizados se han eliminado." }, "network_connections": { diff --git a/src/public/translations/ro/translation.json b/src/public/translations/ro/translation.json index a4de3e3c2..ab5f24a20 100644 --- a/src/public/translations/ro/translation.json +++ b/src/public/translations/ro/translation.json @@ -77,7 +77,7 @@ "attachment_auto_deletion_description": "Atașamentele se șterg automat (permanent) dacă nu sunt referențiate de către notița lor părinte după un timp prestabilit de timp.", "attachment_erasure_timeout": "Perioadă de ștergere a atașamentelor", "erase_attachments_after_x_seconds": "Șterge atașamentele după X secunde după ce acestea n-au mai fost folosite într-o notiță", - "erase_unused_attachments_now": "Se poate lansa o ștergere manuală (fără a mai considera perioada de grație definită anterior):", + "erase_unused_attachments_now": "Elimină atașamentele șterse acum", "manual_erasing_description": "Șterge acum toate atașamentele nefolosite din notițe", "unused_attachments_erased": "Atașamentele nefolosite au fost șterse." }, From c0d613c46d0c4c2d64de8ed25c483f7bc6c80214 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 8 Sep 2024 11:59:24 +0300 Subject: [PATCH 16/43] i18n: Translate note map buttons --- src/public/app/widgets/note_map.js | 5 +++-- src/public/translations/en/translation.json | 4 ++++ src/public/translations/ro/translation.json | 4 ++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/public/app/widgets/note_map.js b/src/public/app/widgets/note_map.js index ab7d2c0e0..f4b00dc81 100644 --- a/src/public/app/widgets/note_map.js +++ b/src/public/app/widgets/note_map.js @@ -6,6 +6,7 @@ import appContext from "../components/app_context.js"; import NoteContextAwareWidget from "./note_context_aware_widget.js"; import linkContextMenuService from "../menus/link_context_menu.js"; import utils from "../services/utils.js"; +import { t } from "../services/i18n.js"; const esc = utils.escapeHtml; @@ -30,8 +31,8 @@ const TPL = `
- - + +
diff --git a/src/public/translations/en/translation.json b/src/public/translations/en/translation.json index 8273e6912..cc7fd98ba 100644 --- a/src/public/translations/en/translation.json +++ b/src/public/translations/en/translation.json @@ -1244,5 +1244,9 @@ "note_is_editable": "Note is editable if it's not too long.", "note_is_read_only": "Note is read-only, but can be edited with a button click.", "note_is_always_editable": "Note is always editable, regardless of its length." + }, + "note-map": { + "button-link-map": "Link Map", + "button-tree-map": "Tree map" } } diff --git a/src/public/translations/ro/translation.json b/src/public/translations/ro/translation.json index ab5f24a20..07e450c3a 100644 --- a/src/public/translations/ro/translation.json +++ b/src/public/translations/ro/translation.json @@ -1244,5 +1244,9 @@ }, "svg_export_button": { "button_title": "Exportă diagrama ca SVG" + }, + "note-map": { + "button-link-map": "Harta legăturilor", + "button-tree-map": "Harta ierarhiei" } } From c33154d12832485ecfd8d5be153e0937078d1e5b Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 8 Sep 2024 12:32:22 +0300 Subject: [PATCH 17/43] i18n: Translate tree context menu --- src/public/app/menus/tree_context_menu.js | 53 +++++++++++---------- src/public/translations/en/translation.json | 28 +++++++++++ src/public/translations/ro/translation.json | 28 +++++++++++ 3 files changed, 83 insertions(+), 26 deletions(-) diff --git a/src/public/app/menus/tree_context_menu.js b/src/public/app/menus/tree_context_menu.js index e3e19dc93..684b31c99 100644 --- a/src/public/app/menus/tree_context_menu.js +++ b/src/public/app/menus/tree_context_menu.js @@ -8,6 +8,7 @@ import noteTypesService from "../services/note_types.js"; import server from "../services/server.js"; import toastService from "../services/toast.js"; import dialogService from "../services/dialog.js"; +import { t } from "../services/i18n.js"; export default class TreeContextMenu { /** @@ -48,55 +49,55 @@ export default class TreeContextMenu { const insertNoteAfterEnabled = isNotRoot && !isHoisted && parentNotSearch; return [ - { title: 'Open in a new tab Ctrl+Click', command: "openInTab", uiIcon: "bx bx-empty", enabled: noSelectedNotes }, - { title: 'Open in a new split', command: "openNoteInSplit", uiIcon: "bx bx-dock-right", enabled: noSelectedNotes }, - { title: 'Insert note after ', command: "insertNoteAfter", uiIcon: "bx bx-plus", + { title: `${t("tree-context-menu.open-in-a-new-tab")} Ctrl+Click`, command: "openInTab", uiIcon: "bx bx-empty", enabled: noSelectedNotes }, + { title: t("tree-context-menu.open-in-a-new-split"), command: "openNoteInSplit", uiIcon: "bx bx-dock-right", enabled: noSelectedNotes }, + { title: `${t("tree-context-menu.insert-note-after")} `, command: "insertNoteAfter", uiIcon: "bx bx-plus", items: insertNoteAfterEnabled ? await noteTypesService.getNoteTypeItems("insertNoteAfter") : null, enabled: insertNoteAfterEnabled && noSelectedNotes && notOptions }, - { title: 'Insert child note ', command: "insertChildNote", uiIcon: "bx bx-plus", + { title: `${t("tree-context-menu.insert-child-note")} `, command: "insertChildNote", uiIcon: "bx bx-plus", items: notSearch ? await noteTypesService.getNoteTypeItems("insertChildNote") : null, enabled: notSearch && noSelectedNotes && notOptions }, - { title: 'Delete ', command: "deleteNotes", uiIcon: "bx bx-trash", + { title: `${t("tree-context-menu.delete")} `, command: "deleteNotes", uiIcon: "bx bx-trash", enabled: isNotRoot && !isHoisted && parentNotSearch && notOptions }, { title: "----" }, - { title: 'Search in subtree ', command: "searchInSubtree", uiIcon: "bx bx-search", + { title: `${t("tree-context-menu.search-in-subtree")} `, command: "searchInSubtree", uiIcon: "bx bx-search", enabled: notSearch && noSelectedNotes }, isHoisted ? null : { title: 'Hoist note ', command: "toggleNoteHoisting", uiIcon: "bx bx-empty", enabled: noSelectedNotes && notSearch }, !isHoisted || !isNotRoot ? null : { title: 'Unhoist note ', command: "toggleNoteHoisting", uiIcon: "bx bx-door-open" }, - { title: 'Edit branch prefix ', command: "editBranchPrefix", uiIcon: "bx bx-empty", + { title: `${t("tree-context-menu.edit-branch-prefix")} `, command: "editBranchPrefix", uiIcon: "bx bx-empty", enabled: isNotRoot && parentNotSearch && noSelectedNotes && notOptions }, - { title: "Advanced", uiIcon: "bx bx-empty", enabled: true, items: [ - { title: 'Expand subtree ', command: "expandSubtree", uiIcon: "bx bx-expand", enabled: noSelectedNotes }, - { title: 'Collapse subtree ', command: "collapseSubtree", uiIcon: "bx bx-collapse", enabled: noSelectedNotes }, - { title: 'Sort by ... ', command: "sortChildNotes", uiIcon: "bx bx-empty", enabled: noSelectedNotes && notSearch }, - { title: 'Recent changes in subtree', command: "recentChangesInSubtree", uiIcon: "bx bx-history", enabled: noSelectedNotes && notOptions }, - { title: 'Convert to attachment', command: "convertNoteToAttachment", uiIcon: "bx bx-empty", enabled: isNotRoot && !isHoisted && notOptions }, - { title: 'Copy note path to clipboard', command: "copyNotePathToClipboard", uiIcon: "bx bx-empty", enabled: true } + { title: t("tree-context-menu.advanced"), uiIcon: "bx bx-empty", enabled: true, items: [ + { title: `${t("tree-context-menu.expand-subtree")} `, command: "expandSubtree", uiIcon: "bx bx-expand", enabled: noSelectedNotes }, + { title: `${t("tree-context-menu.collapse-subtree")} `, command: "collapseSubtree", uiIcon: "bx bx-collapse", enabled: noSelectedNotes }, + { title: `${t("tree-context-menu.sort-by")} `, command: "sortChildNotes", uiIcon: "bx bx-empty", enabled: noSelectedNotes && notSearch }, + { title: t("tree-context-menu.recent-changes-in-subtree"), command: "recentChangesInSubtree", uiIcon: "bx bx-history", enabled: noSelectedNotes && notOptions }, + { title: t("tree-context-menu.convert-to-attachment"), command: "convertNoteToAttachment", uiIcon: "bx bx-empty", enabled: isNotRoot && !isHoisted && notOptions }, + { title: t("tree-context-menu.copy-note-path-to-clipboard"), command: "copyNotePathToClipboard", uiIcon: "bx bx-empty", enabled: true } ] }, { title: "----" }, - { title: "Protect subtree", command: "protectSubtree", uiIcon: "bx bx-check-shield", enabled: noSelectedNotes }, - { title: "Unprotect subtree", command: "unprotectSubtree", uiIcon: "bx bx-shield", enabled: noSelectedNotes }, + { title: t("tree-context-menu.protect-subtree"), command: "protectSubtree", uiIcon: "bx bx-check-shield", enabled: noSelectedNotes }, + { title: t("tree-context-menu.unprotect-subtree"), command: "unprotectSubtree", uiIcon: "bx bx-shield", enabled: noSelectedNotes }, { title: "----" }, - { title: 'Copy / clone ', command: "copyNotesToClipboard", uiIcon: "bx bx-copy", + { title: `${t("tree-context-menu.copy-clone")} `, command: "copyNotesToClipboard", uiIcon: "bx bx-copy", enabled: isNotRoot && !isHoisted }, - { title: 'Clone to ... ', command: "cloneNotesTo", uiIcon: "bx bx-empty", + { title: `${t("tree-context-menu.clone-to")} `, command: "cloneNotesTo", uiIcon: "bx bx-empty", enabled: isNotRoot && !isHoisted }, - { title: 'Cut ', command: "cutNotesToClipboard", uiIcon: "bx bx-cut", + { title: `${t("tree-context-menu.cut")} `, command: "cutNotesToClipboard", uiIcon: "bx bx-cut", enabled: isNotRoot && !isHoisted && parentNotSearch }, - { title: 'Move to ... ', command: "moveNotesTo", uiIcon: "bx bx-empty", + { title: `${t("tree-context-menu.move-to")} `, command: "moveNotesTo", uiIcon: "bx bx-empty", enabled: isNotRoot && !isHoisted && parentNotSearch }, - { title: 'Paste into ', command: "pasteNotesFromClipboard", uiIcon: "bx bx-paste", + { title: `${t("tree-context-menu.paste-into")} `, command: "pasteNotesFromClipboard", uiIcon: "bx bx-paste", enabled: !clipboard.isClipboardEmpty() && notSearch && noSelectedNotes }, - { title: 'Paste after', command: "pasteNotesAfterFromClipboard", uiIcon: "bx bx-paste", + { title: t("tree-context-menu.paste-after"), command: "pasteNotesAfterFromClipboard", uiIcon: "bx bx-paste", enabled: !clipboard.isClipboardEmpty() && isNotRoot && !isHoisted && parentNotSearch && noSelectedNotes }, - { title: `Duplicate subtree `, command: "duplicateSubtree", uiIcon: "bx bx-empty", + { title: `${t("tree-context-menu.duplicate-subtree")} `, command: "duplicateSubtree", uiIcon: "bx bx-empty", enabled: parentNotSearch && isNotRoot && !isHoisted && notOptions }, { title: "----" }, - { title: "Export", command: "exportNote", uiIcon: "bx bx-empty", + { title: t("tree-context-menu.export"), command: "exportNote", uiIcon: "bx bx-empty", enabled: notSearch && noSelectedNotes && notOptions }, - { title: "Import into note", command: "importIntoNote", uiIcon: "bx bx-empty", + { title: t("tree-context-menu.import-into-note"), command: "importIntoNote", uiIcon: "bx bx-empty", enabled: notSearch && noSelectedNotes && notOptions }, - { title: "Apply bulk actions", command: "openBulkActionsDialog", uiIcon: "bx bx-list-plus", + { title: t("tree-context-menu.apply-bulk-actions"), command: "openBulkActionsDialog", uiIcon: "bx bx-list-plus", enabled: true } ].filter(row => row !== null); } diff --git a/src/public/translations/en/translation.json b/src/public/translations/en/translation.json index cc7fd98ba..9e08beac4 100644 --- a/src/public/translations/en/translation.json +++ b/src/public/translations/en/translation.json @@ -1248,5 +1248,33 @@ "note-map": { "button-link-map": "Link Map", "button-tree-map": "Tree map" + }, + "tree-context-menu": { + "open-in-a-new-tab": "Open in a new tab", + "open-in-a-new-split": "Open in a new split", + "insert-note-after": "Insert note after", + "insert-child-note": "Insert child note", + "delete": "Delete", + "search-in-subtree": "Search in subtree", + "edit-branch-prefix": "Edit branch prefix", + "advanced": "Advanced", + "expand-subtree": "Expand subtree", + "collapse-subtree": "Collapse subtree", + "sort-by": "Sort by...", + "recent-changes-in-subtree": "Recent changes in subtree", + "convert-to-attachment": "Convert to attachment", + "copy-note-path-to-clipboard": "Copy note path to clipboard", + "protect-subtree": "Protect subtree", + "unprotect-subtree": "Unprotect subtree", + "copy-clone": "Copy / clone", + "clone-to": "Clone to...", + "cut": "Cut", + "move-to": "Move to...", + "paste-into": "Paste into", + "paste-after": "Paste after", + "duplicate-subtree": "Duplicate subtree", + "export": "Export", + "import-into-note": "Import into note", + "apply-bulk-actions": "Apply bulk actions" } } diff --git a/src/public/translations/ro/translation.json b/src/public/translations/ro/translation.json index 07e450c3a..7bc5ccfb6 100644 --- a/src/public/translations/ro/translation.json +++ b/src/public/translations/ro/translation.json @@ -1248,5 +1248,33 @@ "note-map": { "button-link-map": "Harta legăturilor", "button-tree-map": "Harta ierarhiei" + }, + "tree-context-menu": { + "advanced": "Opțiuni avansate", + "apply-bulk-actions": "Aplică acțiuni în masă", + "clone-to": "Clonare în...", + "collapse-subtree": "Minimizează subnotițele", + "convert-to-attachment": "Convertește în atașament", + "copy-clone": "Copiază/clonează", + "copy-note-path-to-clipboard": "Copiază calea notiței în clipboard", + "cut": "Decupează", + "delete": "Șterge", + "duplicate-subtree": "Dublifică ierarhia", + "edit-branch-prefix": "Editează prefixul ramurii", + "expand-subtree": "Expandează subnotițele", + "export": "Exportă", + "import-into-note": "Importă în notiță", + "insert-child-note": "Inserează subnotiță", + "insert-note-after": "Inserează după notiță", + "move-to": "Mutare la...", + "open-in-a-new-split": "Deschide în lateral", + "open-in-a-new-tab": "Deschide în tab nou", + "paste-after": "Lipește după notiță", + "paste-into": "Lipește în notiță", + "protect-subtree": "Protejează ierarhia", + "recent-changes-in-subtree": "Schimbări recente în ierarhie", + "search-in-subtree": "Caută în ierarhie", + "sort-by": "Ordonare după...", + "unprotect-subtree": "Deprotejează ierarhia" } } From c1010a79f9b9e5c8a70ec82c5b6288e19372224d Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 8 Sep 2024 14:37:40 +0300 Subject: [PATCH 18/43] server: Initialize backend translations --- package-lock.json | 10 ++++++++-- package.json | 1 + src/www.ts | 13 +++++++++++++ translations/cn/server.json | 1 + translations/en/server.json | 1 + translations/es/server.json | 1 + translations/ro/server.json | 1 + 7 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 translations/cn/server.json create mode 100644 translations/en/server.json create mode 100644 translations/es/server.json create mode 100644 translations/ro/server.json diff --git a/package-lock.json b/package-lock.json index f8b61d20a..1b2f392eb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "trilium", - "version": "0.90.4", + "version": "0.90.6-beta", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "trilium", - "version": "0.90.4", + "version": "0.90.6-beta", "license": "AGPL-3.0-only", "dependencies": { "@braintree/sanitize-url": "^7.1.0", @@ -48,6 +48,7 @@ "http-proxy-agent": "7.0.2", "https-proxy-agent": "^7.0.5", "i18next": "^23.14.0", + "i18next-fs-backend": "^2.3.2", "i18next-http-backend": "^2.6.1", "image-type": "4.1.0", "ini": "^4.1.3", @@ -9660,6 +9661,11 @@ "@babel/runtime": "^7.23.2" } }, + "node_modules/i18next-fs-backend": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/i18next-fs-backend/-/i18next-fs-backend-2.3.2.tgz", + "integrity": "sha512-LIwUlkqDZnUI8lnUxBnEj8K/FrHQTT/Sc+1rvDm9E8YvvY5YxzoEAASNx+W5M9DfD5s77lI5vSAFWeTp26B/3Q==" + }, "node_modules/i18next-http-backend": { "version": "2.6.1", "resolved": "https://registry.npmjs.org/i18next-http-backend/-/i18next-http-backend-2.6.1.tgz", diff --git a/package.json b/package.json index b4e5299dd..49406a256 100644 --- a/package.json +++ b/package.json @@ -88,6 +88,7 @@ "http-proxy-agent": "7.0.2", "https-proxy-agent": "^7.0.5", "i18next": "^23.14.0", + "i18next-fs-backend": "^2.3.2", "i18next-http-backend": "^2.6.1", "image-type": "4.1.0", "ini": "^4.1.3", diff --git a/src/www.ts b/src/www.ts index 5986cc1b2..8b67fe75c 100644 --- a/src/www.ts +++ b/src/www.ts @@ -12,6 +12,8 @@ import utils from "./services/utils.js"; import port from "./services/port.js"; import host from "./services/host.js"; import semver from "semver"; +import i18next from "i18next"; +import Backend from "i18next-fs-backend"; // setup basic error handling even before requiring dependencies, since those can produce errors as well @@ -57,6 +59,17 @@ async function startTrilium() { (await import('electron')).app.requestSingleInstanceLock(); } + // Initialize translations + i18next.use(Backend).init({ + lng: "ro", + fallbackLng: "en", + ns: "server", + backend: { + loadPath: "translations/{{lng}}/{{ns}}.json" + }, + debug: true + }); + log.info(JSON.stringify(appInfo, null, 2)); // for perf. issues it's good to know the rough configuration diff --git a/translations/cn/server.json b/translations/cn/server.json new file mode 100644 index 000000000..9e26dfeeb --- /dev/null +++ b/translations/cn/server.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/translations/en/server.json b/translations/en/server.json new file mode 100644 index 000000000..9e26dfeeb --- /dev/null +++ b/translations/en/server.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/translations/es/server.json b/translations/es/server.json new file mode 100644 index 000000000..9e26dfeeb --- /dev/null +++ b/translations/es/server.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/translations/ro/server.json b/translations/ro/server.json new file mode 100644 index 000000000..9e26dfeeb --- /dev/null +++ b/translations/ro/server.json @@ -0,0 +1 @@ +{} \ No newline at end of file From b45fde2e5f04628e57584291b4df43ccf19a7fd1 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 8 Sep 2024 15:05:18 +0300 Subject: [PATCH 19/43] server: Set up early initialization of i18n --- electron.ts | 2 +- package.json | 16 ++++++++-------- src/main.ts | 26 ++++++++++++++++++++++++++ src/services/keyboard_actions.ts | 3 ++- src/www.ts | 16 ++-------------- 5 files changed, 39 insertions(+), 24 deletions(-) create mode 100644 src/main.ts diff --git a/electron.ts b/electron.ts index 0f0e03cd0..6ebf9a9cf 100644 --- a/electron.ts +++ b/electron.ts @@ -70,4 +70,4 @@ electron.app.on("will-quit", () => { // this is to disable electron warning spam in the dev console (local development only) process.env["ELECTRON_DISABLE_SECURITY_WARNINGS"] = "true"; -await import('./src/www.js'); +await import('./src/main.js'); diff --git a/package.json b/package.json index 49406a256..9c2d773f1 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ }, "copyright": "", "bin": { - "trilium": "src/www.js" + "trilium": "src/main.js" }, "repository": { "type": "git", @@ -20,10 +20,10 @@ }, "type": "module", "scripts": { - "start-server": "cross-env TRILIUM_DATA_DIR=./data TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 nodemon src/www.ts", - "start-server-safe": "cross-env TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 nodemon src/www.ts", - "start-server-no-dir": "cross-env TRILIUM_SAFE_MODE=1 TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 nodemon src/www.ts", - "start-test-server": "npm run switch-server; rimraf ./data-test; cross-env TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data-test TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 TRILIUM_ENV=dev TRILIUM_PORT=9999 ts-node src/www.ts", + "start-server": "cross-env TRILIUM_DATA_DIR=./data TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 nodemon src/main.ts", + "start-server-safe": "cross-env TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 nodemon src/main.ts", + "start-server-no-dir": "cross-env TRILIUM_SAFE_MODE=1 TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 nodemon src/main.ts", + "start-test-server": "npm run switch-server; rimraf ./data-test; cross-env TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data-test TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 TRILIUM_ENV=dev TRILIUM_PORT=9999 ts-node src/main.ts", "qstart-server": "npm run switch-server && npm run start-server", "start-electron": "npm run prepare-dist && cross-env TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 TRILIUM_ENV=dev electron ./dist/electron.js --inspect=5858 .", "start-electron-no-dir": "cross-env TRILIUM_SAFE_MODE=1 TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 electron --inspect=5858 .", @@ -43,9 +43,9 @@ "prepare-dist": "rimraf ./dist && tsc && tsx ./bin/copy-dist.ts", "update-build-info": "tsx bin/update-build-info.ts", "errors": "tsc --watch --noEmit", - "integration-edit-db": "cross-env TRILIUM_INTEGRATION_TEST=edit TRILIUM_PORT=8081 TRILIUM_DATA_DIR=./integration-tests/db nodemon src/www.ts", - "integration-mem-db": "cross-env TRILIUM_INTEGRATION_TEST=memory TRILIUM_PORT=8082 TRILIUM_DATA_DIR=./integration-tests/db nodemon src/www.ts", - "integration-mem-db-dev": "cross-env TRILIUM_INTEGRATION_TEST=memory TRILIUM_PORT=8082 TRILIUM_ENV=dev TRILIUM_DATA_DIR=./integration-tests/db nodemon src/www.ts", + "integration-edit-db": "cross-env TRILIUM_INTEGRATION_TEST=edit TRILIUM_PORT=8081 TRILIUM_DATA_DIR=./integration-tests/db nodemon src/main.ts", + "integration-mem-db": "cross-env TRILIUM_INTEGRATION_TEST=memory TRILIUM_PORT=8082 TRILIUM_DATA_DIR=./integration-tests/db nodemon src/main.ts", + "integration-mem-db-dev": "cross-env TRILIUM_INTEGRATION_TEST=memory TRILIUM_PORT=8082 TRILIUM_ENV=dev TRILIUM_DATA_DIR=./integration-tests/db nodemon src/main.ts", "generate-document": "cross-env nodemon src/tools/generate_document.ts 1000" }, "dependencies": { diff --git a/src/main.ts b/src/main.ts new file mode 100644 index 000000000..2878ca818 --- /dev/null +++ b/src/main.ts @@ -0,0 +1,26 @@ +import i18next from "i18next"; +import Backend from "i18next-fs-backend"; +/* + * Make sure not to import any modules that depend on localized messages via i18next here, as the initializations + * are loaded later and will result in an empty string. + */ + +async function initializeTranslations() { + // Initialize translations + await i18next.use(Backend).init({ + lng: "ro", + fallbackLng: "en", + ns: "server", + backend: { + loadPath: "translations/{{lng}}/{{ns}}.json" + }, + debug: true + }); +} + +async function startApplication() { + await import("./www.js"); +} + +await initializeTranslations(); +await startApplication(); \ No newline at end of file diff --git a/src/services/keyboard_actions.ts b/src/services/keyboard_actions.ts index 28e3aeeb4..25c438a48 100644 --- a/src/services/keyboard_actions.ts +++ b/src/services/keyboard_actions.ts @@ -4,6 +4,7 @@ import optionService from "./options.js"; import log from "./log.js"; import utils from "./utils.js"; import { KeyboardShortcut } from './keyboard_actions_interface.js'; +import { t } from "i18next"; const isMac = process.platform === "darwin"; const isElectron = utils.isElectron(); @@ -19,7 +20,7 @@ const isElectron = utils.isElectron(); const DEFAULT_KEYBOARD_ACTIONS: KeyboardShortcut[] = [ { - separator: "Note navigation" + separator: t("keyboard-actions.note-navigation") }, { actionName: "backInNoteHistory", diff --git a/src/www.ts b/src/www.ts index 8b67fe75c..e7632c506 100644 --- a/src/www.ts +++ b/src/www.ts @@ -1,4 +1,5 @@ #!/usr/bin/env node + import app from "./app.js"; import sessionParser from "./routes/session_parser.js"; import fs from "fs"; @@ -12,8 +13,6 @@ import utils from "./services/utils.js"; import port from "./services/port.js"; import host from "./services/host.js"; import semver from "semver"; -import i18next from "i18next"; -import Backend from "i18next-fs-backend"; // setup basic error handling even before requiring dependencies, since those can produce errors as well @@ -57,18 +56,7 @@ async function startTrilium() { */ if (utils.isElectron()) { (await import('electron')).app.requestSingleInstanceLock(); - } - - // Initialize translations - i18next.use(Backend).init({ - lng: "ro", - fallbackLng: "en", - ns: "server", - backend: { - loadPath: "translations/{{lng}}/{{ns}}.json" - }, - debug: true - }); + } log.info(JSON.stringify(appInfo, null, 2)); From 0fed54f1c374711aa0894a8a20f2be37e5398213 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 8 Sep 2024 15:33:06 +0300 Subject: [PATCH 20/43] server: Translate keyboard actions --- src/services/keyboard_actions.ts | 181 +++++++++++++++---------------- translations/en/server.json | 95 +++++++++++++++- translations/ro/server.json | 6 +- 3 files changed, 189 insertions(+), 93 deletions(-) diff --git a/src/services/keyboard_actions.ts b/src/services/keyboard_actions.ts index 25c438a48..c00186ef6 100644 --- a/src/services/keyboard_actions.ts +++ b/src/services/keyboard_actions.ts @@ -20,7 +20,7 @@ const isElectron = utils.isElectron(); const DEFAULT_KEYBOARD_ACTIONS: KeyboardShortcut[] = [ { - separator: t("keyboard-actions.note-navigation") + separator: t("keyboard_actions.note-navigation") }, { actionName: "backInNoteHistory", @@ -37,7 +37,7 @@ const DEFAULT_KEYBOARD_ACTIONS: KeyboardShortcut[] = [ { actionName: "jumpToNote", defaultShortcuts: ["CommandOrControl+J"], - description: 'Open "Jump to note" dialog', + description: t("keyboard_actions.open-jump-to-note-dialog"), scope: "window" }, { @@ -53,37 +53,37 @@ const DEFAULT_KEYBOARD_ACTIONS: KeyboardShortcut[] = [ { actionName: "searchInSubtree", defaultShortcuts: ["CommandOrControl+Shift+S"], - description: "Search for notes in the active note's subtree", + description: t("keyboard_actions.search-in-subtree"), scope: "note-tree" }, { actionName: "expandSubtree", defaultShortcuts: [], - description: "Expand subtree of current note", + description: t("keyboard_actions.expand-subtree"), scope: "note-tree" }, { actionName: "collapseTree", defaultShortcuts: ["Alt+C"], - description: "Collapses the complete note tree", + description: t("keyboard_actions.collapse-tree"), scope: "window" }, { actionName: "collapseSubtree", defaultShortcuts: ["Alt+-"], - description: "Collapses subtree of current note", + description: t("keyboard_actions.collapse-subtree"), scope: "note-tree" }, { actionName: "sortChildNotes", defaultShortcuts: ["Alt+S"], - description: "Sort child notes", + description: t("keyboard_actions.sort-child-notes"), scope: "note-tree" }, { - separator: "Creating and moving notes" + separator: t("keyboard_actions.creating-and-moving-notes") }, { actionName: "createNoteAfter", @@ -98,49 +98,49 @@ const DEFAULT_KEYBOARD_ACTIONS: KeyboardShortcut[] = [ { actionName: "createNoteIntoInbox", defaultShortcuts: ["global:CommandOrControl+Alt+P"], - description: "Create and open in the inbox (if defined) or day note", + description: t("keyboard_actions.create-note-into-inbox"), scope: "window" }, { actionName: "deleteNotes", defaultShortcuts: ["Delete"], - description: "Delete note", + description: t("keyboard_actions.delete-note"), scope: "note-tree" }, { actionName: "moveNoteUp", defaultShortcuts: isMac ? ["Alt+Up"] : ["CommandOrControl+Up"], - description: "Move note up", + description: t("keyboard_actions.move-note-up"), scope: "note-tree" }, { actionName: "moveNoteDown", defaultShortcuts: isMac ? ["Alt+Down"] : ["CommandOrControl+Down"], - description: "Move note down", + description: t("keyboard_actions.move-note-down"), scope: "note-tree" }, { actionName: "moveNoteUpInHierarchy", defaultShortcuts: isMac ? ["Alt+Left"] : ["CommandOrControl+Left"], - description: "Move note up in hierarchy", + description: t("keyboard_actions.move-note-up-in-hierarchy"), scope: "note-tree" }, { actionName: "moveNoteDownInHierarchy", defaultShortcuts: isMac ? ["Alt+Right"] : ["CommandOrControl+Right"], - description: "Move note down in hierarchy", + description: t("keyboard_actions.move-note-down-in-hierarchy"), scope: "note-tree" }, { actionName: "editNoteTitle", defaultShortcuts: ["Enter"], - description: "Jump from tree to the note detail and edit title", + description: t("keyboard_actions.edit-note-title"), scope: "note-tree" }, { actionName: "editBranchPrefix", defaultShortcuts: ["F2"], - description: "Show Edit branch prefix dialog", + description: t("keyboard_actions.edit-branch-prefix"), scope: "note-tree" }, { @@ -155,399 +155,398 @@ const DEFAULT_KEYBOARD_ACTIONS: KeyboardShortcut[] = [ }, { - separator: "Note clipboard" + separator: t("keyboard_actions.note-clipboard") }, - { actionName: "copyNotesToClipboard", defaultShortcuts: ["CommandOrControl+C"], - description: "Copy selected notes to the clipboard", + description: t("keyboard_actions.copy-notes-to-clipboard"), scope: "note-tree" }, { actionName: "pasteNotesFromClipboard", defaultShortcuts: ["CommandOrControl+V"], - description: "Paste notes from the clipboard into active note", + description: t("keyboard_actions.paste-notes-from-clipboard"), scope: "note-tree" }, { actionName: "cutNotesToClipboard", defaultShortcuts: ["CommandOrControl+X"], - description: "Cut selected notes to the clipboard", + description: t("keyboard_actions.cut-notes-to-clipboard"), scope: "note-tree" }, { actionName: "selectAllNotesInParent", defaultShortcuts: ["CommandOrControl+A"], - description: "Select all notes from the current note level", + description: t("keyboard_actions.select-all-notes-in-parent"), scope: "note-tree" }, { actionName: "addNoteAboveToSelection", defaultShortcuts: ["Shift+Up"], - description: "Add note above to the selection", + description: t("keyboard_actions.add-note-above-to-the-selection"), scope: "note-tree" }, { actionName: "addNoteBelowToSelection", defaultShortcuts: ["Shift+Down"], - description: "Add note above to the selection", + description: t("keyboard_actions.add-note-below-to-selection"), scope: "note-tree" }, { actionName: "duplicateSubtree", defaultShortcuts: [], - description: "Duplicate subtree", + description: t("keyboard_actions.duplicate-subtree"), scope: "note-tree" }, { - separator: "Tabs & Windows" + separator: t("keyboard_actions.tabs-and-windows") }, { actionName: "openNewTab", defaultShortcuts: isElectron ? ["CommandOrControl+T"] : [], - description: "Opens new tab", + description: t("keyboard_actions.open-new-tab"), scope: "window" }, { actionName: "closeActiveTab", defaultShortcuts: isElectron ? ["CommandOrControl+W"] : [], - description: "Closes active tab", + description: t("keyboard_actions.close-active-tab"), scope: "window" }, { actionName: "reopenLastTab", defaultShortcuts: isElectron ? ["CommandOrControl+Shift+T"] : [], - description: "Reopens the last closed tab", + description: t("keyboard_actions.reopen-last-tab"), scope: "window" }, { actionName: "activateNextTab", defaultShortcuts: isElectron ? ["CommandOrControl+Tab", "CommandOrControl+PageDown"] : [], - description: "Activates tab on the right", + description: t("keyboard_actions.activate-next-tab"), scope: "window" }, { actionName: "activatePreviousTab", defaultShortcuts: isElectron ? ["CommandOrControl+Shift+Tab", "CommandOrControl+PageUp"] : [], - description: "Activates tab on the left", + description: t("keyboard_actions.activate-previous-tab"), scope: "window" }, { actionName: "openNewWindow", defaultShortcuts: [], - description: "Open new empty window", + description: t("keyboard_actions.open-new-window"), scope: "window" }, { actionName: "toggleTray", defaultShortcuts: [], - description: "Shows/hides the application from the system tray", + description: t("keyboard_actions.toggle-tray"), scope: "window" }, { actionName: "firstTab", defaultShortcuts: ["CommandOrControl+1"], - description: "Activates the first tab in the list", + description: t("keyboard_actions.first-tab"), scope: "window" }, { actionName: "secondTab", defaultShortcuts: ["CommandOrControl+2"], - description: "Activates the second tab in the list", + description: t("keyboard_actions.second-tab"), scope: "window" }, { actionName: "thirdTab", defaultShortcuts: ["CommandOrControl+3"], - description: "Activates the third tab in the list", + description: t("keyboard_actions.third-tab"), scope: "window" }, { actionName: "fourthTab", defaultShortcuts: ["CommandOrControl+4"], - description: "Activates the fourth tab in the list", + description: t("keyboard_actions.fourth-tab"), scope: "window" }, { actionName: "fifthTab", defaultShortcuts: ["CommandOrControl+5"], - description: "Activates the fifth tab in the list", + description: t("keyboard_actions.fifth-tab"), scope: "window" }, { actionName: "sixthTab", defaultShortcuts: ["CommandOrControl+6"], - description: "Activates the sixth tab in the list", + description: t("keyboard_actions.sixth-tab"), scope: "window" }, { actionName: "seventhTab", defaultShortcuts: ["CommandOrControl+7"], - description: "Activates the seventh tab in the list", + description: t("keyboard_actions.seventh-tab"), scope: "window" }, { actionName: "eigthTab", defaultShortcuts: ["CommandOrControl+8"], - description: "Activates the eighth tab in the list", + description: t("keyboard_actions.eight-tab"), scope: "window" }, { actionName: "ninthTab", defaultShortcuts: ["CommandOrControl+9"], - description: "Activates the ninth tab in the list", + description: t("keyboard_actions.ninth-tab"), scope: "window" }, { actionName: "lastTab", defaultShortcuts: [], - description: "Activates the last tab in the list", + description: t("keyboard_actions.last-tab"), scope: "window" }, { - separator: "Dialogs" + separator: t("keyboard_actions.dialogs") }, { actionName: "showNoteSource", defaultShortcuts: [], - description: "Shows Note Source dialog", + description: t("keyboard_actions.show-note-source"), scope: "window" }, { actionName: "showOptions", defaultShortcuts: [], - description: "Shows Options dialog", + description: t("keyboard_actions.show-options"), scope: "window" }, { actionName: "showRevisions", defaultShortcuts: [], - description: "Shows Note Revisions dialog", + description: t("keyboard_actions.show-revisions"), scope: "window" }, { actionName: "showRecentChanges", defaultShortcuts: [], - description: "Shows Recent Changes dialog", + description: t("keyboard_actions.show-recent-changes"), scope: "window" }, { actionName: "showSQLConsole", defaultShortcuts: ["Alt+O"], - description: "Shows SQL Console dialog", + description: t("keyboard_actions.show-sql-console"), scope: "window" }, { actionName: "showBackendLog", defaultShortcuts: [], - description: "Shows Backend Log dialog", + description: t("keyboard_actions.show-backend-log"), scope: "window" }, { actionName: "showHelp", defaultShortcuts: ["F1"], - description: "Shows built-in Help / cheatsheet", + description: t("keyboard_actions.show-help"), scope: "window" }, { - separator: "Text note operations" + separator: t("keyboard_actions.text-note-operations") }, { actionName: "addLinkToText", defaultShortcuts: ["CommandOrControl+L"], - description: "Open dialog to add link to the text", + description: t("keyboard_actions.add-link-to-text"), scope: "text-detail" }, { actionName: "followLinkUnderCursor", defaultShortcuts: ["CommandOrControl+Enter"], - description: "Follow link within which the caret is placed", + description: t("keyboard_actions.follow-link-under-cursor"), scope: "text-detail" }, { actionName: "insertDateTimeToText", defaultShortcuts: ["Alt+T"], - description: "Insert current date & time into text", + description: t("keyboard_actions.insert-date-and-time-to-text"), scope: "text-detail" }, { actionName: "pasteMarkdownIntoText", defaultShortcuts: [], - description: "Pastes Markdown from clipboard into text note", + description: t("keyboard_actions.paste-markdown-into-text"), scope: "text-detail" }, { actionName: "cutIntoNote", defaultShortcuts: [], - description: "Cuts the selection from the current note and creates subnote with the selected text", + description: t("keyboard_actions.cut-into-note"), scope: "text-detail" }, { actionName: "addIncludeNoteToText", defaultShortcuts: [], - description: "Opens the dialog to include a note", + description: t("keyboard_actions.add-include-note-to-text"), scope: "text-detail" }, { actionName: "editReadOnlyNote", defaultShortcuts: [], - description: "Edit a read-only note", + description: t("keyboard_actions.edit-readonly-note"), scope: "window" }, { - separator: "Attributes (labels & relations)" + separator: t("keyboard_actions.attributes-labels-and-relations") }, { actionName: "addNewLabel", defaultShortcuts: ["Alt+L"], - description: "Create new label", + description: t("keyboard_actions.add-new-label"), scope: "window" }, { actionName: "addNewRelation", defaultShortcuts: ["Alt+R"], - description: "Create new relation", + description: t("keyboard_actions.create-new-relation"), scope: "window" }, { - separator: "Ribbon tabs" + separator: t("keyboard_actions.ribbon-tabs") }, { actionName: "toggleRibbonTabBasicProperties", defaultShortcuts: [], - description: "Toggle Basic Properties", + description: t("keyboard_actions.toggle-basic-properties"), scope: "window" }, { actionName: "toggleRibbonTabBookProperties", defaultShortcuts: [], - description: "Toggle Book Properties", + description: t("keyboard_actions.toggle-book-properties"), scope: "window" }, { actionName: "toggleRibbonTabFileProperties", defaultShortcuts: [], - description: "Toggle File Properties", + description: t("keyboard_actions.toggle-file-properties"), scope: "window" }, { actionName: "toggleRibbonTabImageProperties", defaultShortcuts: [], - description: "Toggle Image Properties", + description: t("keyboard_actions.toggle-image-properties"), scope: "window" }, { actionName: "toggleRibbonTabOwnedAttributes", defaultShortcuts: ["Alt+A"], - description: "Toggle Owned Attributes", + description: t("keyboard_actions.toggle-owned-attributes"), scope: "window" }, { actionName: "toggleRibbonTabInheritedAttributes", defaultShortcuts: [], - description: "Toggle Inherited Attributes", + description: t("keyboard_actions.toggle-inherited-attributes"), scope: "window" }, { actionName: "toggleRibbonTabPromotedAttributes", defaultShortcuts: [], - description: "Toggle Promoted Attributes", + description: t("keyboard_actions.toggle-promoted-attributes"), scope: "window" }, { actionName: "toggleRibbonTabNoteMap", defaultShortcuts: [], - description: "Toggle Link Map", + description: t("keyboard_actions.toggle-link-map"), scope: "window" }, { actionName: "toggleRibbonTabNoteInfo", defaultShortcuts: [], - description: "Toggle Note Info", + description: t("keyboard_actions.toggle-note-info"), scope: "window" }, { actionName: "toggleRibbonTabNotePaths", defaultShortcuts: [], - description: "Toggle Note Paths", + description: t("keyboard_actions.toggle-note-paths"), scope: "window" }, { actionName: "toggleRibbonTabSimilarNotes", defaultShortcuts: [], - description: "Toggle Similar Notes", + description: t("keyboard_actions.toggle-similar-notes"), scope: "window" }, { - separator: "Other" + separator: t("keyboard_actions.other") }, { actionName: "toggleRightPane", defaultShortcuts: [], - description: "Toggle the display of the right pane, which includes Table of Contents and Highlights", + description: t("keyboard_actions.toggle-right-pane"), scope: "window" }, { actionName: "printActiveNote", defaultShortcuts: [], - description: "Print active note", + description: t("keyboard_actions.print-active-note"), scope: "window" }, { actionName: "openNoteExternally", defaultShortcuts: [], - description: "Open note as a file with default application", + description: t("keyboard_actions.open-note-externally"), scope: "window" }, { actionName: "renderActiveNote", defaultShortcuts: [], - description: "Render (re-render) active note", + description: t("keyboard_actions.render-active-note"), scope: "window" }, { actionName: "runActiveNote", defaultShortcuts: ["CommandOrControl+Enter"], - description: "Run active JavaScript (frontend/backend) code note", + description: t("keyboard_actions.run-active-note"), scope: "code-detail" }, { actionName: "toggleNoteHoisting", defaultShortcuts: ["Alt+H"], - description: "Toggles note hoisting of active note", + description: t("keyboard_actions.toggle-note-hoisting"), scope: "window" }, { actionName: "unhoist", defaultShortcuts: ["Alt+U"], - description: "Unhoist from anywhere", + description: t("keyboard_actions.unhoist"), scope: "window" }, { actionName: "reloadFrontendApp", defaultShortcuts: ["F5", "CommandOrControl+R"], - description: "Reload frontend App", + description: t("keyboard_actions.reload-frontend-app"), scope: "window" }, { actionName: "openDevTools", defaultShortcuts: isElectron ? ["CommandOrControl+Shift+I"] : [], - description: "Open dev tools", + description: t("keyboard_actions.open-dev-tools"), scope: "window" }, { @@ -558,43 +557,43 @@ const DEFAULT_KEYBOARD_ACTIONS: KeyboardShortcut[] = [ { actionName: "toggleLeftPane", defaultShortcuts: [], - description: "Toggle left (note tree) panel", + description: t("keyboard_actions.toggle-left-note-tree-panel"), scope: "window" }, { actionName: "toggleFullscreen", defaultShortcuts: ["F11"], - description: "Toggle full screen", + description: t("keyboard_actions.toggle-full-screen"), scope: "window" }, { actionName: "zoomOut", defaultShortcuts: isElectron ? ["CommandOrControl+-"] : [], - description: "Zoom Out", + description: t("keyboard_actions.zoom-out"), scope: "window" }, { actionName: "zoomIn", - description: "Zoom In", + description: t("keyboard_actions.zoom-in"), defaultShortcuts: isElectron ? ["CommandOrControl+="] : [], scope: "window" }, { actionName: "zoomReset", - description: "Reset zoom level", + description: t("keyboard_actions.reset-zoom-level"), defaultShortcuts: isElectron ? ["CommandOrControl+0"] : [], scope: "window" }, { actionName: "copyWithoutFormatting", defaultShortcuts: ["CommandOrControl+Alt+C"], - description: "Copy selected text without formatting", + description: t("keyboard_actions.copy-without-formatting"), scope: "text-detail" }, { actionName: "forceSaveRevision", defaultShortcuts: [], - description: "Force creating / saving new note revision of the active note", + description: t("keyboard_actions.force-save-revision"), scope: "window" } ]; diff --git a/translations/en/server.json b/translations/en/server.json index 9e26dfeeb..9a22298c7 100644 --- a/translations/en/server.json +++ b/translations/en/server.json @@ -1 +1,94 @@ -{} \ No newline at end of file +{ + "keyboard_actions": { + "open-jump-to-note-dialog": "Open \"Jump to note\" dialog", + "search-in-subtree": "Search for notes in the active note's subtree", + "expand-subtree": "Expand subtree of current note", + "collapse-tree": "Collapses the complete note tree", + "collapse-subtree": "Collapses subtree of current note", + "sort-child-notes": "Sort child notes", + "creating-and-moving-notes": "Creating and moving notes", + "create-note-into-inbox": "Create and open in the inbox (if defined) or day note", + "delete-note": "Delete note", + "move-note-up": "Move note up", + "move-note-down": "Move note down", + "move-note-up-in-hierarchy": "Move note up in hierarchy", + "move-note-down-in-hierarchy": "Move note down in hierarchy", + "edit-note-title": "Jump from tree to the note detail and edit title", + "edit-branch-prefix": "Show Edit branch prefix dialog", + "note-clipboard": "Note clipboard", + "copy-notes-to-clipboard": "Copy selected notes to the clipboard", + "paste-notes-from-clipboard": "Paste notes from the clipboard into active note", + "cut-notes-to-clipboard": "Cut selected notes to the clipboard", + "select-all-notes-in-parent": "Select all notes from the current note level", + "add-note-above-to-the-selection": "Add note above to the selection", + "add-note-below-to-selection": "Add note above to the selection", + "duplicate-subtree": "Duplicate subtree", + "tabs-and-windows": "Tabs & Windows", + "open-new-tab": "Opens new tab", + "close-active-tab": "Closes active tab", + "reopen-last-tab": "Reopens the last closed tab", + "activate-next-tab": "Activates tab on the right", + "activate-previous-tab": "Activates tab on the left", + "open-new-window": "Open new empty window", + "toggle-tray": "Shows/hides the application from the system tray", + "first-tab": "Activates the first tab in the list", + "second-tab": "Activates the second tab in the list", + "third-tab": "Activates the third tab in the list", + "fourth-tab": "Activates the fourth tab in the list", + "fifth-tab": "Activates the fifth tab in the list", + "sixth-tab": "Activates the sixth tab in the list", + "seventh-tab": "Activates the seventh tab in the list", + "eight-tab": "Activates the eighth tab in the list", + "ninth-tab": "Activates the ninth tab in the list", + "last-tab": "Activates the last tab in the list", + "dialogs": "Dialogs", + "show-note-source": "Shows Note Source dialog", + "show-options": "Shows Options dialog", + "show-revisions": "Shows Note Revisions dialog", + "show-recent-changes": "Shows Recent Changes dialog", + "show-sql-console": "Shows SQL Console dialog", + "show-backend-log": "Shows Backend Log dialog", + "text-note-operations": "Text note operations", + "add-link-to-text": "Open dialog to add link to the text", + "follow-link-under-cursor": "Follow link within which the caret is placed", + "insert-date-and-time-to-text": "Insert current date & time into text", + "paste-markdown-into-text": "Pastes Markdown from clipboard into text note", + "cut-into-note": "Cuts the selection from the current note and creates subnote with the selected text", + "add-include-note-to-text": "Opens the dialog to include a note", + "edit-readonly-note": "Edit a read-only note", + "attributes-labels-and-relations": "Attributes (labels & relations)", + "add-new-label": "Create new label", + "create-new-relation": "Create new relation", + "ribbon-tabs": "Ribbon tabs", + "toggle-basic-properties": "Toggle Basic Properties", + "toggle-file-properties": "Toggle File Properties", + "toggle-image-properties": "Toggle Image Properties", + "toggle-owned-attributes": "Toggle Owned Attributes", + "toggle-inherited-attributes": "Toggle Inherited Attributes", + "toggle-promoted-attributes": "Toggle Promoted Attributes", + "toggle-link-map": "Toggle Link Map", + "toggle-note-info": "Toggle Note Info", + "toggle-note-paths": "Toggle Note Paths", + "toggle-similar-notes": "Toggle Similar Notes", + "other": "Other", + "toggle-right-pane": "Toggle the display of the right pane, which includes Table of Contents and Highlights", + "print-active-note": "Print active note", + "open-note-externally": "Open note as a file with default application", + "render-active-note": "Render (re-render) active note", + "run-active-note": "Run active JavaScript (frontend/backend) code note", + "toggle-note-hoisting": "Toggles note hoisting of active note", + "unhoist": "Unhoist from anywhere", + "reload-frontend-app": "Reload frontend App", + "open-dev-tools": "Open dev tools", + "toggle-left-note-tree-panel": "Toggle left (note tree) panel", + "toggle-full-screen": "Toggle full screen", + "zoom-out": "Zoom Out", + "zoom-in": "Zoom In", + "note-navigation": "Note navigation", + "reset-zoom-level": "Reset zoom level", + "copy-without-formatting": "Copy selected text without formatting", + "force-save-revision": "Force creating / saving new note revision of the active note", + "show-help": "Shows built-in Help / cheatsheet", + "toggle-book-properties": "Toggle Book Properties" + } +} diff --git a/translations/ro/server.json b/translations/ro/server.json index 9e26dfeeb..439659592 100644 --- a/translations/ro/server.json +++ b/translations/ro/server.json @@ -1 +1,5 @@ -{} \ No newline at end of file +{ + "keyboard-actions": { + "note-navigation": "Navigarea printre notițe" + } +} From 69f9457bda3015dc3d1b7a85011c90c36f4e309e Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 8 Sep 2024 16:04:00 +0300 Subject: [PATCH 21/43] i18n: Translate keyboard actions into Romanian --- translations/en/server.json | 2 +- translations/ro/server.json | 92 +++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 1 deletion(-) diff --git a/translations/en/server.json b/translations/en/server.json index 9a22298c7..a7129796d 100644 --- a/translations/en/server.json +++ b/translations/en/server.json @@ -7,7 +7,7 @@ "collapse-subtree": "Collapses subtree of current note", "sort-child-notes": "Sort child notes", "creating-and-moving-notes": "Creating and moving notes", - "create-note-into-inbox": "Create and open in the inbox (if defined) or day note", + "create-note-into-inbox": "Create a note in the inbox (if defined) or day note", "delete-note": "Delete note", "move-note-up": "Move note up", "move-note-down": "Move note down", diff --git a/translations/ro/server.json b/translations/ro/server.json index 439659592..62414fd60 100644 --- a/translations/ro/server.json +++ b/translations/ro/server.json @@ -1,5 +1,97 @@ { "keyboard-actions": { "note-navigation": "Navigarea printre notițe" + }, + "keyboard_actions": { + "activate-next-tab": "Activează tab-ul din dreapta", + "activate-previous-tab": "Activează tab-ul din stânga", + "add-include-note-to-text": "Deschide fereastra de includere notițe", + "add-link-to-text": "Deschide fereastra de adaugă legături în text", + "add-new-label": "Crează o nouă etichetă", + "add-note-above-to-the-selection": "Adaugă notița deasupra selecției", + "add-note-below-to-selection": "Adaugă notița deasupra selecției", + "attributes-labels-and-relations": "Atribute (etichete și relații)", + "close-active-tab": "Închide tab-ul activ", + "collapse-subtree": "Minimizează ierarhia notiței curente", + "collapse-tree": "Minimizează întreaga ierarhie de notițe", + "copy-notes-to-clipboard": "Copiază notițele selectate în clipboard", + "copy-without-formatting": "Copiază textul selectat fără formatare", + "create-new-relation": "Crează o nouă relație", + "create-note-into-inbox": "Crează o notiță și o deschide în inbox (dacă este definit) sau notița zilnică", + "cut-notes-to-clipboard": "Decupează notițele selectate în clipboard", + "creating-and-moving-notes": "Crearea și mutarea notițelor", + "cut-into-note": "Decupează selecția din notița curentă și crează o subnotiță cu textul selectat", + "delete-note": "Șterge notița", + "dialogs": "Ferestre", + "duplicate-subtree": "Dublifică subnotițele", + "edit-branch-prefix": "Afișează ecranul „Editează prefixul ramurii”", + "edit-note-title": "Sare de la arborele notițelor la detaliile notiței și editează titlul", + "edit-readonly-note": "Editează o notiță care este în modul doar în citire", + "eight-tab": "Activează cel de-al optelea tab din listă", + "expand-subtree": "Expandează ierarhia notiței curente", + "fifth-tab": "Activează cel de-al cincelea tab din listă", + "first-tab": "Activează cel primul tab din listă", + "follow-link-under-cursor": "Urmărește legătura de sub poziția cursorului", + "force-save-revision": "Forțează crearea/salvarea unei noi revizii ale notiției curente", + "fourth-tab": "Activează cel de-al patrulea tab din listă", + "insert-date-and-time-to-text": "Inserează data curentă și timpul în text", + "last-tab": "Activează ultimul tab din listă", + "move-note-down": "Mută notița mai jos", + "move-note-down-in-hierarchy": "Mută notița mai jos în ierarhie", + "move-note-up": "Mută notița mai sus", + "move-note-up-in-hierarchy": "Mută notița mai sus în ierarhie", + "ninth-tab": "Activează cel de-al nouălea tab din listă", + "note-clipboard": "Clipboard-ul notițelor", + "note-navigation": "Navigarea printre notițe", + "open-dev-tools": "Deschide uneltele de dezvoltator", + "open-jump-to-note-dialog": "Deschide ecranul „Sari la notiță”", + "open-new-tab": "Deschide un tab nou", + "open-new-window": "Deschide o nouă fereastră goală", + "open-note-externally": "Deschide notița ca un fișier utilizând aplicația implicită", + "other": "Altele", + "paste-markdown-into-text": "Lipește text Markdown din clipboard în notița de tip text", + "paste-notes-from-clipboard": "Lipește notițele din clipboard în notița activă", + "print-active-note": "Imprimă notița activă", + "reload-frontend-app": "Reîncarcă interfața grafică", + "render-active-note": "Reîmprospătează notița activă", + "reopen-last-tab": "Deschide din nou ultimul tab închis", + "reset-zoom-level": "Resetează nivelul de magnificare", + "ribbon-tabs": "Tab-urile din panglică", + "run-active-note": "Rulează notița curentă de tip JavaScript (frontend sau backend)", + "search-in-subtree": "Caută notițe în ierarhia notiței active", + "second-tab": "Activează cel de-al doilea tab din listă", + "select-all-notes-in-parent": "Selectează toate notițele din nivelul notiței curente", + "seventh-tab": "Activează cel de-al șaptelea tab din listă", + "show-backend-log": "Afișează fereastra „Log-uri din backend”", + "show-help": "Afișează informații utile", + "show-note-source": "Afișează fereastra „Sursa notiței”", + "show-options": "Afișează fereastra de opțiuni", + "show-recent-changes": "Afișează fereastra „Schimbări recente”", + "show-revisions": "Afișează fereastra „Revizii ale notiței”", + "show-sql-console": "Afișează ecranul „Consolă SQL”", + "sixth-tab": "Activează cel de-al șaselea tab din listă", + "sort-child-notes": "Ordonează subnotițele", + "tabs-and-windows": "Tab-uri și ferestre", + "text-note-operations": "Operații asupra notițelor text", + "third-tab": "Activează cel de-al treilea tab din listă", + "toggle-basic-properties": "Comută tab-ul „Proprietăți de bază”", + "toggle-book-properties": "Comută tab-ul „Proprietăți ale cărții”", + "toggle-file-properties": "Comută tab-ul „Proprietăți fișier”", + "toggle-full-screen": "Comută modul ecran complet", + "toggle-image-properties": "Comută tab-ul „Proprietăți imagini”", + "toggle-inherited-attributes": "Comută tab-ul „Atribute moștenite”", + "toggle-left-note-tree-panel": "Comută panoul din stânga (arborele notițelor)", + "toggle-link-map": "Comută harta legăturilor", + "toggle-note-hoisting": "Comută focalizarea pe notița curentă", + "toggle-note-info": "Comută tab-ul „Informații despre notiță”", + "toggle-note-paths": "Comută tab-ul „Căile notiței”", + "toggle-owned-attributes": "Comută tab-ul „Atribute proprii”", + "toggle-promoted-attributes": "Comută tab-ul „Atribute promovate”", + "toggle-right-pane": "Comută afișarea panoului din dreapta, ce include tabela de conținut și evidențieri", + "toggle-similar-notes": "Comută tab-ul „Notițe similare”", + "toggle-tray": "Afișează/ascunde aplicația din tray-ul de sistem", + "unhoist": "Defocalizează complet", + "zoom-in": "Mărește zoom-ul", + "zoom-out": "Micșorează zoom-ul" } } From a9e6c887f27c621ff3594f1e125829c59c5ed3ef Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 8 Sep 2024 16:04:14 +0300 Subject: [PATCH 22/43] i18n: Configure extensions & nodemon --- .vscode/settings.json | 3 ++- nodemon.json | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index a2203a03b..805d4b906 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,7 +6,8 @@ "i18n-ally.sourceLanguage": "en", "i18n-ally.keystyle": "nested", "i18n-ally.localesPaths": [ - "./src/public/translations" + "./src/public/translations", + "./translations" ], "[jsonc]": { "editor.defaultFormatter": "vscode.json-language-features" diff --git a/nodemon.json b/nodemon.json index 1266e1b4c..efaf5f759 100644 --- a/nodemon.json +++ b/nodemon.json @@ -3,7 +3,10 @@ "ignore": [".git", "node_modules/**/node_modules", "src/public/"], "verbose": false, "exec": "tsx", - "watch": ["src/"], + "watch": [ + "src/", + "translations/" + ], "signal": "SIGTERM", "env": { "NODE_ENV": "development" From d00c028a0c410bd61f12b29c6585c615729ebe51 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 8 Sep 2024 16:38:12 +0300 Subject: [PATCH 23/43] client: Fix note actions not fitting on all languages --- src/public/app/widgets/buttons/note_actions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/public/app/widgets/buttons/note_actions.js b/src/public/app/widgets/buttons/note_actions.js index fa3a14de6..1c8e53f3f 100644 --- a/src/public/app/widgets/buttons/note_actions.js +++ b/src/public/app/widgets/buttons/note_actions.js @@ -17,7 +17,7 @@ const TPL = ` } .note-actions .dropdown-menu { - width: 15em; + min-width: 15em; } .note-actions .dropdown-item[disabled], .note-actions .dropdown-item[disabled]:hover { From 68042994e0c285d8dc13fa64ade4ebda00ad62fb Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 8 Sep 2024 17:40:05 +0300 Subject: [PATCH 24/43] electron: Fix loading of i18n --- bin/build-server.sh | 2 +- bin/copy-trilium.sh | 4 ++-- electron-main.ts | 4 ++++ package-lock.json | 2 +- package.json | 4 ++-- src/main.ts | 15 +-------------- src/services/i18n.ts | 15 +++++++++++++++ 7 files changed, 26 insertions(+), 20 deletions(-) create mode 100644 electron-main.ts create mode 100644 src/services/i18n.ts diff --git a/bin/build-server.sh b/bin/build-server.sh index a0357b046..be00cf592 100755 --- a/bin/build-server.sh +++ b/bin/build-server.sh @@ -22,7 +22,7 @@ rm -r $PKG_DIR/node/lib/node_modules/npm rm -r $PKG_DIR/node/include/node rm -r $PKG_DIR/node_modules/electron* -rm -r $PKG_DIR/electron.js +rm -r $PKG_DIR/electron*.js printf "#!/bin/sh\n./node/bin/node src/www" > $PKG_DIR/trilium.sh chmod 755 $PKG_DIR/trilium.sh diff --git a/bin/copy-trilium.sh b/bin/copy-trilium.sh index 25b881dd7..ca2acf674 100755 --- a/bin/copy-trilium.sh +++ b/bin/copy-trilium.sh @@ -37,11 +37,11 @@ for f in 'package.json' 'package-lock.json' 'README.md' 'LICENSE' 'config-sample done # Patch package.json main -sed -i 's/.\/dist\/electron.js/electron.js/g' "$DIR/package.json" +sed -i 's/.\/dist\/electron-main.js/electron-main.js/g' "$DIR/package.json" script_dir=$(realpath $(dirname $0)) cp -R "$script_dir/../build/src" "$DIR" -cp "$script_dir/../build/electron.js" "$DIR" +cp "$script_dir/../build/electron-main.js" "$DIR" # run in subshell (so we return to original dir) (cd $DIR && npm install --omit=dev) diff --git a/electron-main.ts b/electron-main.ts new file mode 100644 index 000000000..6fff6ae6b --- /dev/null +++ b/electron-main.ts @@ -0,0 +1,4 @@ +import { initializeTranslations } from "./src/services/i18n.js"; + +await initializeTranslations(); +await import("./electron.js") \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 1b2f392eb..99eae360a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -99,7 +99,7 @@ "yauzl": "^3.1.3" }, "bin": { - "trilium": "src/www.js" + "trilium": "src/main.js" }, "devDependencies": { "@electron-forge/cli": "^7.4.0", diff --git a/package.json b/package.json index 9c2d773f1..d75f90ae2 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Build your personal knowledge base with TriliumNext Notes", "version": "0.90.6-beta", "license": "AGPL-3.0-only", - "main": "./dist/electron.js", + "main": "./dist/electron-main.js", "author": { "name": "TriliumNext Notes Team", "email": "contact@eliandoran.me", @@ -25,7 +25,7 @@ "start-server-no-dir": "cross-env TRILIUM_SAFE_MODE=1 TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 nodemon src/main.ts", "start-test-server": "npm run switch-server; rimraf ./data-test; cross-env TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data-test TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 TRILIUM_ENV=dev TRILIUM_PORT=9999 ts-node src/main.ts", "qstart-server": "npm run switch-server && npm run start-server", - "start-electron": "npm run prepare-dist && cross-env TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 TRILIUM_ENV=dev electron ./dist/electron.js --inspect=5858 .", + "start-electron": "npm run prepare-dist && cross-env TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 TRILIUM_ENV=dev electron ./dist/electron-main.js --inspect=5858 .", "start-electron-no-dir": "cross-env TRILIUM_SAFE_MODE=1 TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 electron --inspect=5858 .", "qstart-electron": "npm run switch-electron && npm run start-electron", "switch-server": "rimraf ./node_modules/better-sqlite3 && npm install", diff --git a/src/main.ts b/src/main.ts index 2878ca818..c38b85933 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,22 +1,9 @@ -import i18next from "i18next"; -import Backend from "i18next-fs-backend"; /* * Make sure not to import any modules that depend on localized messages via i18next here, as the initializations * are loaded later and will result in an empty string. */ -async function initializeTranslations() { - // Initialize translations - await i18next.use(Backend).init({ - lng: "ro", - fallbackLng: "en", - ns: "server", - backend: { - loadPath: "translations/{{lng}}/{{ns}}.json" - }, - debug: true - }); -} +import { initializeTranslations } from "./services/i18n.js"; async function startApplication() { await import("./www.js"); diff --git a/src/services/i18n.ts b/src/services/i18n.ts new file mode 100644 index 000000000..9cd5e7562 --- /dev/null +++ b/src/services/i18n.ts @@ -0,0 +1,15 @@ +import i18next from "i18next"; +import Backend from "i18next-fs-backend"; + +export async function initializeTranslations() { + // Initialize translations + await i18next.use(Backend).init({ + lng: "ro", + fallbackLng: "en", + ns: "server", + backend: { + loadPath: "translations/{{lng}}/{{ns}}.json" + }, + debug: true + }); +} \ No newline at end of file From 317b7b4c595a78e377d6b86b3147c5c893fedc8a Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 8 Sep 2024 18:01:08 +0300 Subject: [PATCH 25/43] server: Implement basic restore of language --- src/services/i18n.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/services/i18n.ts b/src/services/i18n.ts index 9cd5e7562..a7faf2fe6 100644 --- a/src/services/i18n.ts +++ b/src/services/i18n.ts @@ -1,10 +1,11 @@ import i18next from "i18next"; import Backend from "i18next-fs-backend"; +import options from "./options.js"; export async function initializeTranslations() { // Initialize translations await i18next.use(Backend).init({ - lng: "ro", + lng: await getCurrentLanguage(), fallbackLng: "en", ns: "server", backend: { @@ -12,4 +13,16 @@ export async function initializeTranslations() { }, debug: true }); +} + +function getCurrentLanguage() { + let language; + language = options.getOption("locale"); + + if (!language) { + console.info("Language option not found, falling back to en."); + language = "en"; + } + + return language; } \ No newline at end of file From c25c8c753de646e010add4f51759c902f55d5d07 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 8 Sep 2024 18:12:16 +0300 Subject: [PATCH 26/43] server: Translate login page --- src/app.ts | 6 ++++++ src/views/login.ejs | 12 ++++++------ translations/en/server.json | 8 ++++++++ translations/ro/server.json | 8 ++++++++ 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/app.ts b/src/app.ts index 351bd6f0a..4fabebcc5 100644 --- a/src/app.ts +++ b/src/app.ts @@ -14,6 +14,7 @@ import custom from "./routes/custom.js"; import error_handlers from "./routes/error_handlers.js"; import { startScheduledCleanup } from "./services/erase.js"; import sql_init from "./services/sql_init.js"; +import { t } from "i18next"; await import('./services/handlers.js'); await import('./becca/becca_loader.js'); @@ -29,6 +30,11 @@ sql_init.initializeDb(); app.set('views', path.join(scriptDir, 'views')); app.set('view engine', 'ejs'); +app.use((req, res, next) => { + res.locals.t = t; + return next(); +}); + if (!utils.isElectron()) { app.use(compression()); // HTTP compression } diff --git a/src/views/login.ejs b/src/views/login.ejs index 34aa0c732..be01bd623 100644 --- a/src/views/login.ejs +++ b/src/views/login.ejs @@ -3,24 +3,24 @@ - Login + <%= t("login.title") %>
-

Trilium login

+

<%= t("login.heading") %>

<% if (failedAuth) { %>
- Password is incorrect. Please try again. + <%= t("login.incorrect-password") %>
<% } %>
- +
@@ -28,12 +28,12 @@
- +
diff --git a/translations/en/server.json b/translations/en/server.json index a7129796d..15211f1d9 100644 --- a/translations/en/server.json +++ b/translations/en/server.json @@ -90,5 +90,13 @@ "force-save-revision": "Force creating / saving new note revision of the active note", "show-help": "Shows built-in Help / cheatsheet", "toggle-book-properties": "Toggle Book Properties" + }, + "login": { + "title": "Login", + "heading": "Trilium login", + "incorrect-password": "Password is incorrect. Please try again.", + "password": "Password", + "remember-me": "Remember me", + "button": "Login" } } diff --git a/translations/ro/server.json b/translations/ro/server.json index 62414fd60..ef9abe6a6 100644 --- a/translations/ro/server.json +++ b/translations/ro/server.json @@ -93,5 +93,13 @@ "unhoist": "Defocalizează complet", "zoom-in": "Mărește zoom-ul", "zoom-out": "Micșorează zoom-ul" + }, + "login": { + "button": "Autentifică", + "heading": "Autentificare în Trilium", + "incorrect-password": "Parola nu este corectă. Încercați din nou.", + "password": "Parolă", + "remember-me": "Ține-mă minte", + "title": "Autentificare" } } From 1fbc65b00761b711bff806511a1defdc3d728790 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 8 Sep 2024 18:23:06 +0300 Subject: [PATCH 27/43] electron: Fix crash on first start due to i18n --- src/services/i18n.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/services/i18n.ts b/src/services/i18n.ts index a7faf2fe6..ea109499c 100644 --- a/src/services/i18n.ts +++ b/src/services/i18n.ts @@ -1,6 +1,7 @@ import i18next from "i18next"; import Backend from "i18next-fs-backend"; import options from "./options.js"; +import sql_init from "./sql_init.js"; export async function initializeTranslations() { // Initialize translations @@ -17,7 +18,9 @@ export async function initializeTranslations() { function getCurrentLanguage() { let language; - language = options.getOption("locale"); + if (sql_init.isDbInitialized()) { + language = options.getOption("locale"); + } if (!language) { console.info("Language option not found, falling back to en."); From 58d1e77ac1fa0b188b9c84ea49fb00918ed7fcac Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 8 Sep 2024 18:28:29 +0300 Subject: [PATCH 28/43] server: Translate set password page --- src/views/set_password.ejs | 12 ++++++------ translations/en/server.json | 7 +++++++ translations/ro/server.json | 7 +++++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/views/set_password.ejs b/src/views/set_password.ejs index a23abb797..6aa11df18 100644 --- a/src/views/set_password.ejs +++ b/src/views/set_password.ejs @@ -3,14 +3,14 @@ - Login + <%= t("login.title") %>
-

Set password

+

<%= t("set_password.heading") %>

<% if (error) { %>
@@ -18,24 +18,24 @@
<% } %> -

Before you can start using Trilium from web, you need to set a password first. You will then use this password to login.

+

<%= t("set_password.description") %>

- +
- +
- +
diff --git a/translations/en/server.json b/translations/en/server.json index 15211f1d9..f29e06641 100644 --- a/translations/en/server.json +++ b/translations/en/server.json @@ -98,5 +98,12 @@ "password": "Password", "remember-me": "Remember me", "button": "Login" + }, + "set_password": { + "heading": "Set password", + "description": "Before you can start using Trilium from web, you need to set a password first. You will then use this password to login.", + "password": "Password", + "password-confirmation": "Password confirmation", + "button": "Set password" } } diff --git a/translations/ro/server.json b/translations/ro/server.json index ef9abe6a6..f99dfb7b6 100644 --- a/translations/ro/server.json +++ b/translations/ro/server.json @@ -101,5 +101,12 @@ "password": "Parolă", "remember-me": "Ține-mă minte", "title": "Autentificare" + }, + "set_password": { + "heading": "Setare parolă", + "button": "Setează parola", + "description": "Înainte de a putea utiliza Trilium din navigator, trebuie mai întâi setată o parolă. Ulterior această parolă va fi folosită la autentificare.", + "password": "Parolă", + "password-confirmation": "Confirmarea parolei" } } From 94857d88022bca4b8a00b1c1431deed4cc2f9a04 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 8 Sep 2024 18:55:11 +0300 Subject: [PATCH 29/43] server: Translate JavaScript required --- src/views/desktop.ejs | 2 +- src/views/mobile.ejs | 2 +- src/views/setup.ejs | 2 +- translations/en/server.json | 3 ++- translations/ro/server.json | 3 ++- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/views/desktop.ejs b/src/views/desktop.ejs index 64135659a..59a4b2b4f 100644 --- a/src/views/desktop.ejs +++ b/src/views/desktop.ejs @@ -7,7 +7,7 @@ TriliumNext Notes - +