Closed brogowski closed 2 years ago
Hmm, on the other hand function with gts-prompt-picker
works only in reverse - asking always for "pl" to "en" translation.
(defun my/go-translate ()
(interactive)
(gts-translate (gts-translator
:picker (gts-prompt-picker)
:engines (gts-google-engine)
:render (gts-buffer-render))))
The current picker mainly relies on gts-picker-lang-match-alist
for language judgment.
I'm not familiar with pl
, so it's not builtin. But you can add your rule by adding:
(add-to-list 'gts-picker-lang-match-alist
(cons "pl" "[regexp to judge whether current input is pl]"))
Of course, this mechanism of automatic judgment is not perfect, because some languages are really difficult to distinguish.
Then, you can:
use x
in the result buffer to switch language
customize your own pick path logic
:
(defmethod gts-path ((o gts-prompt-picker) text)
;; return a proper path for your own
)
Or, you can try to provide PR to make the auto judgment more perfect.
Thanks @lorniu - I've added simple regex for pl
(it's latin based).
(add-to-list 'gts-picker-lang-match-alist
(cons "pl" "^[a-zA-Z\u0105-\u017b,.;_ ]+$"))
and now it starts with translation from pl
to en
.
However, I don't think that's going to be useful for you since it is overriding en
regex.
Thanks so much for this useful package!
I ran into this issue just now.
How would I make the gts-translator
function use my custom gts-path
function? Maybe I can submit it to:path
, or is that only for cons paths?
All I want is for the path order to remain as it is when I submit it. That is, (cons "en" "sv")
should go from EN -> SV, and (cons "sv" "en")
should go from SV -> EN. I only use this package programmatically, not through the UI, so I can't hit x
to switch.
Maybe there should be a global function for this.
Thoughts?
For context, here is the relevant code:
(gts-translate (gts-translator
:picker (gts-noprompt-picker :texter (my/gts-string-texter))
:engines (gts-bing-engine)
:render (my/gts-insert-render)
:path lang ;; (cons "en" "sv") or (cons "sv" "en"), both result in the same result currently: EN -> SV
))
Hi,
I'm trying to write small function to get translation show up in minibuffer.
However it looks like language pairs are ordered alphabetically... I'm getting translation from "en" to "pl" instead of "pl" to "en".
Is there any way I can specify translate direction?