Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggest phrases based existing translations when entering new translation text #409

Open
ernestasjuska opened this issue Sep 28, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request up for grabs

Comments

@ernestasjuska
Copy link

Hi,

One pain point in current editor is that whole target translation has to be entered manually when suitable translation if not found automatically. Then you have to go to the XLIFF file and search for similar source text.

It would be useful to have some kind of text autocompletion based on existing translations.
For example if you have translation "My Super Cool Field" -> "Mano labai kietas laukas", when inputing translation it should suggest it when starting to type "Mano lab...".

It should work similar to VS Code's word completion feature but instead work with phrases (in this case it could suggest full field caption, e.g. "Grynasis pokytis").
image

Thanks.

@ernestasjuska ernestasjuska added the enhancement New feature or request label Sep 28, 2022
@ernestasjuska
Copy link
Author

ernestasjuska commented Sep 28, 2022

For tooltips we use same format pretty much everywhere ("Specifies the value of the ... field." -> "Nurodo lauko ... reikšmę."). Could this be automatically suggested by the XLIFF editor?
(moved to #410)

@jwikman
Copy link
Owner

jwikman commented Sep 29, 2022

Hi @ernestasjuska,

Just to be sure I understand your issue:
You request a word/sentence completion in our XLIFF Editor, not in the XLF file, right?

If so, I might be able look into how to solve word completion, similar to how it works if you open the XLF file in text mode in VSCode. Adding a sentence completion will probably be waaay to complicated to solve, I'm afraid.

Would word completion in the XLIFF editor be of any help at all for you?

(to keep this issue clean, I moved the second feature request to it's own issue (#410))

@ernestasjuska
Copy link
Author

ernestasjuska commented Sep 30, 2022

Yes, the feature would in the XLIFF editor for entering translations. Word completion will suffice, it should also suggest words based on the previous word.

Words would be sequences of letters, single letter words should be allowed.

Words should be stored in lowercase, but when autocompleting the casing of the word should be decided by the previous word or current word first two letters:

  • XXXX _ -> XXXX YYYY, (if previous word is upper case then current word is upper case)
  • Xxxx _ -> Xxxx Yyyy, (if previous word is title case then current word is title case)
  • xxxx _ -> xxxx yyyy, (if previous word lower case then current word is lower case)
  • ... YY_ -> ... YYYY, (if current word starts with two upper case letters then current word is upper case)
  • ... Y_ -> ... Yyyy, (if current word starts with upper case letter then the current word title case)
  • ... y_ -> ... yyyy. (if current word starts with lower case letter then current word is lower case)

Autocompletion should not care where cursor is on the word (same as in code editing).
In completion list, words based on previous word should be suggested at then top.

So for translations "Some Document No.", "Document Date", "Item No.":

  • if you type "som_" it should suggest "some".
  • if you type "Document _" it should suggest "Date", "No", "Some";
  • if you type "Document D_" it should suggest "Date", "Document";
  • if you type "Document DA_" it should suggest "DATE";
  • if you type "Document _DA" it should suggest "DATE"; (cursor moved to the begging of the word)
  • if you type "Document d_" it should suggest "date", "document", "some".

I make example using the trie data structure (https://github.com/ernestasjuska/TrieThis/blob/main/TrieThis/Program.cs). Other than reading the translation file and splitting translations into words (took around 6 seconds for Base Application translation file; 2 seconds for 2000 translation units file) it works pretty fast.

VS Code also supports fuzzy matches, e.g. typing "Doct" would suggest word "Document". There is a fuzzy search algorithm in this repo https://github.com/derekparker/trie, but I haven't touched golang seriously to understand it.

Thanks.

@theschitz
Copy link
Collaborator

Thank you for the detailed description and helpful references @ernestasjuska.

I'll look into developing this feature. At the moment there's little time and energy for me to spare so I won't promise when I'll start but I'll update this issue. In the mean time if you feel adventurous you are very welcome to have a stab at it yourself 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request up for grabs
Projects
None yet
Development

No branches or pull requests

3 participants