GithubHelp home page GithubHelp logo

fevol / obsidian-translate Goto Github PK

View Code? Open in Web Editor NEW
84.0 84.0 4.0 160.58 MB

Translate text and entire notes in Obsidian

License: MIT License

JavaScript 33.63% TypeScript 54.93% CSS 0.01% SCSS 1.18% Svelte 10.25%
obsidian-md obsidian-plugin translate translation

obsidian-translate's People

Contributors

fevol avatar kometenstaub avatar solitary-sails avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

obsidian-translate's Issues

Feature Idea: Quick Cycle Possible Translations

Just an idea I had that could fits well with the plugin maybe?

So the plugin can already translate selected text into a different language. However, when I need to translate things, it's mostly more complicated words for which there are multiple possible translations.

What I could imagine would be to quickly cycle between the possible translations. So for example you select the word "grande" (french) and on the first run of the command, it becomes "big". run the command again, the word becomes "great", a third time, it becomes "tall".

That way, you could quickly cycle through possible translations (even without using the mouse) without having to look up all possible translations and then tediously copying or typing the translation you choose.

Translate selection without having to select language

Currently there are two steps required to translate a selection from keyboard, opening the 'Translate Selection' command via hotkeys (or one additional step: via command palette), and then typing in the language.

Perhaps it would be convenient if you could just execute one shortcut to translate the selection, based on the language_to (target language) you have set inside the Translation View? Let me know what you think!

Tasks

  • Add simple command to execute translate selection on selected language in $data.language_to
  • Find an easier way to set $data.language_to without having the Translation View open, and not polluting the command palette with commands that are identical - except for one thing

Issues

  • There are already too many commands for my taste, even more so if I take in to account the commands that will be added in the future

Bergamot integration

Implement client-side translation via Bergamot, requires minimal set-up for the user.

Tasks

  • Add WASM binary of Bergamot
  • Integrate Bergamot into Bergamot translate handler
  • Relative loading of WASM and Language Model
  • Download button for WASM
  • Dropdown to select models to add (determines available languages)
  • Download button for any selection of language Model
  • Performance improvements with loading binary and model
  • Update models if newer version is found on registry
  • Check for binary updates on reload of languages

Issues

  • Loading both the large WASM binary and the language model takes some time (start-up time for Obsidian increased by 0.7s on a speedy computer)

[BUG] FastText not in Filter Services

User report

Description: Fast Text cannot be selected as the option filter services does not contain the item.


Debugger data (do not alter)

plugin_version: "1.4.4"
platform: "Desktop"
framework_version: "1.1.9"
obsidian_version: "1.1.12"
selected_service: "deepl"

[Bug] Sync with spellchecker languages

After selecting the sync with spellchecker option, it

  1. still shows the dropdown for selecting new languages, but doesn't work
  2. after a restart of Obsidian, these languages are lost (not visible in the settings anymore, as well as missing from the sidebar pane

The translation service dropdown is empty

User report

Description: The translation service dropdown is empty
The translation service dropdown menu is empty. And the unique service tab visible is "FastText Settings".

TranslateSettings

Thanks so much for your excellent work!

Francesc Rosés


Debugger data (do not alter)

plugin_version: "1.4.6"
platform: "macOS"
framework_version: "1.3.7"
obsidian_version: "1.4.2"
selected_service: undefined

[Bug] Cannot load settings; use safe access in 2 places

plugin:obsidian-translate:42349 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'default_usage')
    at setupLanguageDetector (plugin:obsidian-translate:42349:47)
    at setupTranslationService (plugin:obsidian-translate:42365:5)
    at Object.$$self.$$.update (plugin:obsidian-translate:42596:27)
    at init (plugin:obsidian-translate:1248:6)
    at new Reactivity (plugin:obsidian-translate:42646:5)
    at TranslatorPlugin.onload (plugin:obsidian-translate:42765:23)

screenshot

The plugin cannot load the settings properly. The commands don't get loaded properly and after clicking on the Translate Tab in the community plugins, it is empty, and every new settings tab is empty as well and throws this error:

plugin:obsidian-translate:42699 Uncaught TypeError: Cannot read properties of undefined (reading '$destroy')
    at TranslatorSettingsTab.hide (plugin:obsidian-translate:42699:15)
    at t.openTab (app.js:1:2063355)
    at HTMLDivElement.<anonymous> (app.js:1:2062226)

screenshot

Error when clicking on the translate tab:

plugin:obsidian-translate:27282 Uncaught TypeError: Cannot read properties of undefined (reading 'default_usage')
    at Array.create_control_slot (plugin:obsidian-translate:27282:47)
    at create_slot (plugin:obsidian-translate:515:29)
    at create_fragment9 (plugin:obsidian-translate:2809:28)
    at init (plugin:obsidian-translate:1251:41)
    at new SettingItem (plugin:obsidian-translate:2927:9)
    at create_fragment15 (plugin:obsidian-translate:27406:18)
    at init (plugin:obsidian-translate:1251:41)
    at new SettingsPage (plugin:obsidian-translate:28094:5)
    at TranslatorSettingsTab.display (plugin:obsidian-translate:42687:17)
    at t.openTab (app.js:1:2063766)

screenshot

With a safe access (?) in these two places, it works again.

[feat] Translate on mod-enter

It would be cool if the sidebar could execute the translation on mod-enter (ctrl-enter on windows/linux, cmd-enter on macOS).

[feat] Support dragging pop-out windows back

Currently, the view gets attached to the containerEl. It has the effect that when dragging the sidebar view outside of the main window or into the root split of the main window, that there is no way to drag it back.

I would have made a PR, but as is visible in the second picture, the resizing is off when using contentEl and would need to be adjusted.

Current containerEl implementation:

current implementation

When using contentEl:

contentEl implementation

Writing tests for all API handlers

There are 10 different translation services, each having four different functions that could be called: 'validate, detect, translate, get languages', and each has multiple possible failure conditions, depending on API keys used, hosts,... It's getting quite tiresome to manually check every service when I do an overhaul of their code, so it's as good time as any to start writing automated tests with Jest.

Add shortcut hints to Translation View

Feature request: please add to the tranlation view hints for keyboard shortcuts for invoking translation and language swapping. I see already through trial and error that CMD+ENTER invokes the translate button.

Tnx!

image

Translate to new line

Hello,
I'd like that there is a command that translate to new line,don't change the selection text,insert the translation to new line.

Thanks!

[feat] select everyting on ctrl-A

I would appreciate if I could select all text with Ctrl-A. The reason for this is that I often copy text into it and would like to use that hotkey for selecting all the text that's already inside it.

So that I can Ctrl-A, Ctrl-V for inserting the new text.

OpenAI Translator

With beta release 1.4.5 (accessible using BRAT), the OpenAI service has been added to the plugin, by recommendation of @ckt1031 and inspired by the OpenAI Translator Application.

I will be releasing this update by the end of the week. However, I am eagerly looking for any feedback for this service.

Specifically:

  • How will you be using the service? Does it work decently?
  • Why do you prefer to translate with OpenAI over the other services (thus, should I be focusing more on GPT's capabilities?)

Some implementation details:

  • The service works by simply passing along following prompts for a given input:
    • Detect language: Identify the language of the input, please ONLY output its ISO639-1 code:\n INPUT
    • Translate (auto detect language): Translate following text to 'TARGET' without explanation, include ISO639-1 locale of the input in the first line:\n INPUT
    • Translate (source language given): Translate following text from 'SOURCE' to 'TARGET' without explanation:\n INPUT
  • Currently, I haven't considered the token limit at all. I made the assumption that people wouldn't translate entire notes using this service (current limit for GPT3.5 is at ~10.000 characters or ~1.000 words, or double that with GPT4)
  • The plugin tries to focus on only one thing, being translating text. I realise that GPT can be used in many more tasks (such as pronunciation, sentence dissection, word-by-word explanations, however, I personally feel that this is outside of the scope of the plugin, and would be tricky to implement)
  • If you use any proxy GPT services, please do let me know. Currently, only the official API is implemented and tested.

[BUG] Terms in both directions has no persistance

Type of change

  • Bug fix

Description

In Glossary tab, enable the toggle button has no persistance.

I think is related to that glossary tab too:
If i fill a glossary term and add it in one direction doesn't fill the reverse pair after click at the "reverse" button.
So i need fill the two ways.


Debugger data (do not alter)

plugin_version: "1.4.4"
platform: "Desktop"
framework_version: "0.15.6"
obsidian_version: "1.1.9"
selected_service: "bergamot"

Last character of text will be removed

See this gif:
gif

This will only happen once after changing the text, clicking the translate icon after that will not do anything.

SYSTEM INFO:
	Obsidian version: v0.15.2
	Installer version: v0.14.6
	Operating system: Windows 10 Home 10.0.19043
	Live preview: on
	Legacy editor: off
	Base theme: light
	Community theme: Minimal
	Snippets enabled: 7
	Safe mode: off
	Plugins installed: 34
	Plugins enabled: 3
		1: Hot Reload
		2: Obsidian42 - BRAT
		3: Translate - 1.1.4

Translation view: define default languages

Enjoying Obsidian Translate. Thank you for this tool!

It would be useful to assign default languages to the Translation View. So in settings, I can't say Language 1: is English, and Language 2: is Spanish, and Translation View always opens with those as defaults.

Tnx!

[BUG] Issue with Yandex Translate

User report

Description: ADD A SHORT DESCRIPTION HERE


Debugger data (do not alter)

plugin_version: "1.4.4"
platform: "Desktop"
framework_version: "1.1.9"
obsidian_version: "1.1.16"

FastText restores settings at startup

User report

Description: After to install fastText language model, this plugin saves the plugins list setup (which one is on or off), including the chosen theme and restores everything at obsidian startup.
So if you activate or deactivate plugins after activated this one, the changes will be "forgotten".
It's necessary activate obsidian-translate last if you want to avoid that.

Reproducible Steps

1- Choose bergamot as the service
2- Install bergamot models
3- Install fastText

After that, whathever modifications will be discarded at restart.

Temp Fix

Uninstall fastText or activate obsidian-translate last.


Debugger data (do not alter)

plugin_version: "1.4.3"
platform: "Desktop"
framework_version: "0.15.6"
obsidian_version: "1.1.9"
selected_service: "bergamot"

[BUG] Plugin breaks "More options" menu

User report

After installing this plugin and enabling it, I have got my "More options" menu broken. It doesn't scroll and has broken layout as long as the plugin is enabled. I have reproduced this bug on my usual vault and on newly created vault.

Here screenshot and video https://github.com/AntonTheDeveloper/bug-reports/tree/37e850c48cc6684c7a46d6734007621038b21d0e/obsidian-translate


Debugger data (do not alter)

plugin_version: "1.4.4"
platform: "Desktop"
framework_version: "1.1.16"
obsidian_version: "1.1.16"
selected_service: "google_translate"

Use normal callback

this.addCommand({
id: "translator-open-view",
name: "Open translation view",
icon: "translate",
editorCallback: () => {
this.activateTranslatorView();
},
});

Currently, the pane can only be opened when there is an editor in focus. But there doesn't need to be an editor for the translation pane to be useful.

Improve preservation of formatting when translating

Markdown formatting doesn't perfectly survive the translation process. The root of the issue lies mostly with the way that translation services handle and process text, so the solution will lie elsewhere. One possibility is applying post-processing to the output of the translation operation, fixing broken URL's, code blocks, etc.

Tasks

  • Fix URL links being broken after translation
  • Fix code blocks
  • Find more places where markdown breaks

Issues

  • Some translation services remove all formatting (i.e. Libre Translate), this will probably require a more heavy-handed approach to fixing
  • What approach could be taken to ensure that only the incorrect formatting will be fixed, and not other parts of the text?

Fanyi Youdao integration

(Request from Discord) Implement Youdao as a translation service

Tasks

  • Adapt DummyTranslate to use Youdao's API
  • Add appropriate options to settings page
  • Add service info to constants.ts
  • Add service info to README.md

Any chance for an API?

I would like to pass a word, source language, target language to the api and get back the translated word.

Probably the return value needs to be an array with the translation word and perhaps the descriptions of it.

Would that be possible?

Fasttext integration

Implement client-side language detection via the FastText library

Tasks

  • Add WASM binary of FastText
  • Integrate FastText into Bergamot translate handler
  • Relative loading of WASM and Language Model
  • Download button for WASM and Language Model
  • Allow user to choose which model to use (1MB vs 150MB model - not sure if anybody would want this though)
  • Performance improvements with loading binary and model

Issues

  • Loading both the large WASM binary and the language model takes some time (start-up time for Obsidian increased by 0.7s on a speedy computer)

Hotkey to open an existing Translate view

Hey,

First thanks for an awesome plugin, I really needed that.
However, when trying to use Translate I ran into an issue. I put Translate in the sidebar, where I think it will be most beneficial for me, but when I use a hotkey or the command to open the Translate View, it won't go to the instance already in the sidebar but always open a new pane.
Is it possible to use an existing instance if one is already opened?
I added a GIF to better explain the issue.

Thanks in advance!

Peek 2023-04-16 09-19

[BUG] Fanyi QQ integration does not work

User report

Description: ADD A SHORT DESCRIPTION HERE


Debugger data (do not alter)

plugin_version: "1.4.4"
platform: "Desktop"
framework_version: "1.1.16"
obsidian_version: "1.1.16"

Localization support

Add localization support for the plugin's UI elements and translation service languages, the list of languages supported is the same as those supported by Obsidian's (see here)

Submit language

IMPORTANT: Currently, the localization system is not fully set-up yet. If you'd like to contribute, please let me know that you're interested, and I'll try to get it sorted out as soon as possible.

If you'd like to add your language to the localizations, follow these steps:

  1. Fork this repository
  2. Edit the JSON file of your language (look for the .ts file containing your language's ISO code in this directory, you can find the ISO code/language locale to which your language here)
  3. Once completed, submit a pull request

Tasks

  • Replace every English string with corresponding localization identifier
  • Make localization process easier (introducing new localization strings should be quick)

[BUG] Issue with Fanyi Baidu

User report

Description: ADD A SHORT DESCRIPTION HERE


Debugger data (do not alter)

plugin_version: "1.4.4"
platform: "Desktop"
framework_version: "1.1.9"
obsidian_version: "1.1.16"

[ FR ] Mobile Support

Would you consider making the plugin available for mobile as well?

Translating on the go would be a huge win!

Thank you for looking into it.

[BUG] Fanyi Baidu – ADD A TITLE HERE

User report

Description: ADD A SHORT DESCRIPTION HERE


Debugger data (do not alter)

plugin_version: "1.4.4"
platform: "macOS"
framework_version: "1.1.9"
obsidian_version: "1.1.16"

Lingva integration

Implement Lingva as a translation service, this service scrapes translations from Google Translate, without accessing any Google services

Tasks

  • Adapt DummyTranslate to use Lingva's API
  • Add appropriate options to settings page
  • Add service info to constants.ts
  • Add service info to README.md

Issues

Probably not entirely legal

Hotkey to focus the source text box

Hi,

I really want to integrate Translate into my keyboard-centric flow, and currently when opening the view, in order to start typing a word to translate I need to press Tab 4 times.
Is it possible to open the view with the 'Type here' box already focused and ready to go?

Thanks in advance!

Reduce characters sent to translation service

Currently, the entire input gets sent to the selected translation service. If multiple translations are executed on a block of text (say, when the user is typing in the Translation View and they wish to check if their intermediate result is correct), the amount of characters sent to the service will grow exponentially - even more so if the user has auto translate enabled.

The solution for this problem is to only translate the new text. Below are some approaches that could be taken:

Caching

Cache translation results of the service

  • Implement rudementary cache inside DummyTranslate
  • After each request, add translation for sentence

Issues

  • What is a sentence? Not all languages end on periods, so how should those be processed?
  • (cont.) How do you properly split a body of text such that the meaning is still identical?

Only changes

Only translate parts of the entered text that were changed

Issues

  • Might be hard to implement (what constitutes as a change? one letter can cause an entirely different interpretation of a sentence)

deepl - failed to fetch

Hi,

just testing the plugin, but when I use my (free) Deepl API key, it says "failed to fetch".
Any idea?

BTW, any chance for the user to determine if he uses the pro API? I guess that is a different API domain.
Thanks!

Fanyi QQ integration

(Request from Discord) Implement QQ as a translation service

Tasks

  • Adapt DummyTranslate to use QQ's API
  • Add appropriate options to settings page
  • Add service info to constants.ts
  • Add service info to README.md

Feature request: Show both translation result and original text when doing a file translation

Hi, thanks for building such a powerful translation plugin, I think it's more powerful than those in obsidian plugin market.

I just realize it's more convenient when reading translation and original text in one file, because most translations are not very accurate and we need to see original text to get the meaning.

Will you consider to add a feature, when doing a file translation, show translation result and original text paragraph by paragraph, for example:

when we translate an English file to Chinese, the file finally show like this:


Obsidian is a powerful and extensible knowledge base that works on top of your local folder of plain text files.
Obsidian 是一个强大且可扩展的知识库它适用于纯文本文件的本地文件夹。

Everything is connected
一切都已连接

The human brain is non-linear: we jump from idea to idea, all the time. Your second brain should work the same.
人脑是非线性的:我们总是从一个想法跳到另一个想法。你的第二个大脑应该同样工作。

In Obsidian, making and following connections is frictionless. Tend to your notes like a gardener; at the end of the day, sit back and marvel at your own knowledge graph.
在 Obsidian 中,建立和跟随连接是无摩擦的。像园丁一样照顾你的笔记;在一天结束时,坐下来惊叹于您自己的知识图谱。


I am not sure this is a feature most people will need or not but it's definitely a difficult and complicated feature. I don't know obsidian plugin system can realize this or not, if not, you can just pass my request.

RTL is not supported

The Translation View currently only displays text from LTR, and the logical flow of the interface likewise occurs in that order.

Tasks

  • Check how other translation websites handle RTL script
  • Figure out if TextArea should automatically switch LTR/RTL on input script

PDF export contains source code

When exporting any note as PDF the compiled code for Yandex, and some additional code will be the first thing visible.

The code will also show up as the last thing in the DOM

Obsidian version: 0.15.3
Plugin version: 1.1.5

[BUG] Fanyi Baidu –

User report

Description:


Debugger data (do not alter)

service_version: "1.0.0"
obsidian_version: "0.15.8"
mobile: false

Paragraph breaks not preserved in lingva Eng-> japanese

Hi (long time no see). I haven't been using the plugin much lately for various reasons, but started up recently. One thing hanging me up is a snag with the lingva translator. It may not be with the plugin at all, but I find that in translating english to japanese, french and portuguese (the only languages I tested), paragraph breaks are not preserved, which was slowing me down. I don't konw if it something fixable on your end, but I thought I'd let you know. Aside from that, hope you are doing well...

Security improvements on API keys

Currently the API keys are stored in a plaintext file within the plugin's data.json. Some users might want a more secure solution, such that if their vault's files get leaked, the API keys of the translation services are (reasonably) protected.

I don't know what the most secure way to do this will be; and what people consider to be secure enough, so I'd love to hear your opinion on this matter!

Encrypt

Encrypt the API keys stored within data.json with an user provided password, this password can be added in local storage such that the user does not need to re-enter it each time Obsidian is booted up

Tasks

  • Setup SubtleCrypto for encryption of password strings
  • Add API key storage option inside settings page
  • Prompt user to set password on selecting this storage option
  • Store password in local storage such that the user only needs to enter it once for the device (add non-peristent option such that the user needs to enter password on plugin start-up)
  • Automatically encrypt/decrypt API keys inside data.json on (de)selecting option
  • On construction of translation service handler, decrypt the API key
  • Apply sufficient salt to the password
  • (? Do not allow two devices using different storage settings, as this could cause conflicting states with file synchronization services ?)

Do not save

User needs to add API key for translation service every time plugin is started up (API key never gets saved on disk)

Tasks

  • Intercept write of API key to options if setting is enabled

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.