danielnaber / oxygen-languagetool-plugin

LanguageTool plugin for the Oxygen XML editor
GNU Lesser General Public License v2.1
8 stars 4 forks source link

Better detection of language #1

Closed raducoravu closed 10 years ago

raducoravu commented 10 years ago

Better detection of language + compound edit when replacing changes

danielnaber commented 10 years ago

I had merged this but had to revert it again, sorry - the problem is that the user interface language that you use isn't always the same as the language for spell checking. For example, with your change it tried to check my English documents with German rules, as my user interface is in German.

raducoravu commented 10 years ago

Sorry about that. I understand, I initially thought you wanted to get access to the user interface language for which there was API. But you actually wanted to access the default spell checker language. Sorry about that. And indeed we do not yet have API to directly access options because a plugin might also obtain user names and passwords saved in there and we've decided that would probably be a bad thing.

I originally started to modify "org.languagetool.oxygen.LanguageToolPluginExtension.getDefaultLanguageCode(WSAuthorEditorPage)" because on my computer which has English locale it returns "en" but the spell checking server does not expect this as a value, it wants "en-US" so initially when I tested this the spell check feature did not work at all.

In my opinion we could improve this in two ways:

1) The plugin already has a preferences page, we should allow users to configure there in a read-only combo box the language in which the spell check should be done on the server. And the language should be one of the languages allowed by the server. In the same preferences page we could maybe allow the user to set up the URL to the server (by default it would still be http://localhost:8081).

2) When the spell check is done, in the XML content there may be possible that xml:lang attributes exist on elements. Our bundled spell checker takes this into account. So when you have a paragraph with xml:lang="de" it will be checked in German even if the default spell check language is English. But this could be postponed.

danielnaber commented 10 years ago

Yes, these are good ideas for improvement (although I'll have to wait for patches, as I don't have time to work on that myself).

Please note that spell checking is confusing with LanguageTool: for languages that have variants (en-US, de-AT etc), you need to specify the variant (en-US) to get spell checking activated. For languages that don't have variants (fr, ru, most others), you'll get spell checking anyway.

raducoravu commented 10 years ago

I'll see if I can get somebody on our side to work on this for a couple of days. Ideally on the server side if the language is like "en" and the server has variants, it could somehow merge all variants and check with that merged dictionary. Can the server be queried about which exact languages are supported?

danielnaber commented 10 years ago

Supported languages can be queried like this: https://languagetool.org:8081/Languages. I'm not sure about merging the languages, people might be very confused if both en-US and en-GB are accepted at the same time.

raducoravu commented 10 years ago

Ok, I started adding some issues:

https://github.com/danielnaber/oxygen-languagetool-plugin/issues

and we'll discuss via the issues if necessary.