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

Translation providers improvements #98

Merged

Conversation

fxprunayre
Copy link

@fxprunayre fxprunayre commented Mar 11, 2024

Better handle record which may contains languages

  • Add Anchor support
  • better preserve existing translations
  • add translate all,
  • translate only empty.
  • Also experiment support in suggestion in 115-3 (disabled for now - list of String is not supported, only one xpath at a time).

image

Configuration

  • Create a directive that can be reuse in any harvester
  • Add comon xpath selector

image

Add google translate service

image

Based on https://stackoverflow.com/questions/8147284/how-to-use-google-translate-api-in-my-java-application

Misc

Checklist

  • I have read the contribution guidelines
  • Pull request provided for main branch, backports managed with label
  • Good housekeeping of code, cleaning up comments, tests, and documentation
  • Clean commit history broken into understandable chucks, avoiding big commits with hundreds of files, cautious of reformatting and whitespace changes
  • Clean commit messages, longer verbose messages are encouraged
  • API Changes are identified in commit messages
  • Testing provided for features or enhancements using automatic tests
  • User documentation provided for new features or enhancements in manual
  • Build documentation provided for development instructions in README.md files
  • Library management using pom.xml dependency management. Update build documentation with intended library use and library tutorials or documentation

…ntains other language, add translate all, translate only empty.

Also experiment support in suggestion (disabled for now - list of xpath
is not supported, only one xpath at a time).
@@ -32,225 +32,176 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:gn-fn-metadata="http://geonetwork-opensource.org/xsl/functions/metadata"
xmlns:geonet="http://www.fao.org/geonetwork"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it required a template to remove geonet elements also, other xslt in the process folder has that type of template?

in the same xslt for iso19139 this line doesn't exist.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For harvesting no. I only tested suggestion with 115-3 for now but turned it off as it requires a bit more effort. Maybe we can check later when we add translation service in the editor and also align 19139 ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

geonet namespace is required for suggestion templates

* Create a script

```js
var mock = {
  parameter:{
    q:'hello',
    source:'en',
    target:'fr'
  }
};

function doGet(e) {
  e = e || mock;

  var sourceText = ''
  if (e.parameter.q){
    sourceText = e.parameter.q;
  }

  var sourceLang = '';
  if (e.parameter.source){
    sourceLang = e.parameter.source;
  }

  var targetLang = 'en';
  if (e.parameter.target){
    targetLang = e.parameter.target;
  }

  var translatedText = LanguageApp.translate(sourceText, sourceLang, targetLang, {contentType: 'html'});

  return ContentService.createTextOutput(translatedText).setMimeType(ContentService.MimeType.JSON);
}
```

* Deploy it as webapp for anonymous user
* Configure the service URL in the translation provider
…iguration. Add examples for easier XPath configuration.
@fxprunayre fxprunayre changed the title Support for translation providers / Better handle record which may contains languages Support for translation providers Apr 3, 2024
@fxprunayre fxprunayre changed the title Support for translation providers Translation providers improvements Apr 3, 2024
@josegar74 josegar74 merged commit 71b4ebd into GeoCat:44-translationproviders Apr 18, 2024
3 checks passed
josegar74 added a commit that referenced this pull request Jun 3, 2024
* Support for translation providers in harvesters

* Support for translation providers / fix artifact in services/pom.xml

* Support for translation providers / directive to select multiple languages

* Support for translation providers / update harvester translation and use ACE Editor widget for translation fields configuration

* Support for translation providers / refactor directive to select multiple languages to be generic

* Support for translation providers / directive to select multiple languages - use a watcher to initialize typeahead when the data is available

* Translation providers improvements (#98)

* Support for translation providers / Better handle record which may contains other language, add translate all, translate only empty.

Also experiment support in suggestion (disabled for now - list of xpath
is not supported, only one xpath at a time).

* Support for translation providers / Add google translate service

* Create a script

```js
var mock = {
  parameter:{
    q:'hello',
    source:'en',
    target:'fr'
  }
};

function doGet(e) {
  e = e || mock;

  var sourceText = ''
  if (e.parameter.q){
    sourceText = e.parameter.q;
  }

  var sourceLang = '';
  if (e.parameter.source){
    sourceLang = e.parameter.source;
  }

  var targetLang = 'en';
  if (e.parameter.target){
    targetLang = e.parameter.target;
  }

  var translatedText = LanguageApp.translate(sourceText, sourceLang, targetLang, {contentType: 'html'});

  return ContentService.createTextOutput(translatedText).setMimeType(ContentService.MimeType.JSON);
}
```

* Deploy it as webapp for anonymous user
* Configure the service URL in the translation provider

* Support for translation providers / Add Anchor support.

* Support for translation providers / Create one directive for the configuration. Add examples for easier XPath configuration.

* Support for translation providers / Improve translation.

* Support for translation providers / Fix bad xpath.

* Update translationproviders/src/main/java/org/fao/geonet/translations/googletranslate/GoogleTranslateService.java

* Update translationproviders/src/main/java/org/fao/geonet/translations/libretranslate/LibreTranslateClientException.java

* Update web-ui/src/main/resources/catalog/components/admin/harvester/partials/translate.html

* Update web-ui/src/main/resources/catalog/components/admin/harvester/partials/translate.html

---------

Co-authored-by: Jose García <[email protected]>

* Translation providers - support additional harvesters: GeoNetwork, Local filesystem, OAI-PHM, WebDav

---------

Co-authored-by: François Prunayre <[email protected]>
josegar74 added a commit that referenced this pull request Jun 18, 2024
* Support for translation providers in harvesters

* Support for translation providers / fix artifact in services/pom.xml

* Support for translation providers / directive to select multiple languages

* Support for translation providers / update harvester translation and use ACE Editor widget for translation fields configuration

* Support for translation providers / refactor directive to select multiple languages to be generic

* Support for translation providers / directive to select multiple languages - use a watcher to initialize typeahead when the data is available

* Translation providers improvements (#98)

* Support for translation providers / Better handle record which may contains other language, add translate all, translate only empty.

Also experiment support in suggestion (disabled for now - list of xpath
is not supported, only one xpath at a time).

* Support for translation providers / Add google translate service

* Create a script

```js
var mock = {
  parameter:{
    q:'hello',
    source:'en',
    target:'fr'
  }
};

function doGet(e) {
  e = e || mock;

  var sourceText = ''
  if (e.parameter.q){
    sourceText = e.parameter.q;
  }

  var sourceLang = '';
  if (e.parameter.source){
    sourceLang = e.parameter.source;
  }

  var targetLang = 'en';
  if (e.parameter.target){
    targetLang = e.parameter.target;
  }

  var translatedText = LanguageApp.translate(sourceText, sourceLang, targetLang, {contentType: 'html'});

  return ContentService.createTextOutput(translatedText).setMimeType(ContentService.MimeType.JSON);
}
```

* Deploy it as webapp for anonymous user
* Configure the service URL in the translation provider

* Support for translation providers / Add Anchor support.

* Support for translation providers / Create one directive for the configuration. Add examples for easier XPath configuration.

* Support for translation providers / Improve translation.

* Support for translation providers / Fix bad xpath.

* Update translationproviders/src/main/java/org/fao/geonet/translations/googletranslate/GoogleTranslateService.java

* Update translationproviders/src/main/java/org/fao/geonet/translations/libretranslate/LibreTranslateClientException.java

* Update web-ui/src/main/resources/catalog/components/admin/harvester/partials/translate.html

* Update web-ui/src/main/resources/catalog/components/admin/harvester/partials/translate.html

---------

Co-authored-by: Jose García <[email protected]>

* Translation providers - support additional harvesters: GeoNetwork, Local filesystem, OAI-PHM, WebDav

---------

Co-authored-by: François Prunayre <[email protected]>
juanluisrp pushed a commit that referenced this pull request Jul 23, 2024
…onetwork#8190)

* Support for translation providers in harvesters

* Support for translation providers / fix artifact in services/pom.xml

* Support for translation providers / directive to select multiple languages

* Support for translation providers / update harvester translation and use ACE Editor widget for translation fields configuration

* Support for translation providers / refactor directive to select multiple languages to be generic

* Support for translation providers / directive to select multiple languages - use a watcher to initialize typeahead when the data is available

* Translation providers improvements (#98)

* Support for translation providers / Better handle record which may contains other language, add translate all, translate only empty.

Also experiment support in suggestion (disabled for now - list of xpath
is not supported, only one xpath at a time).

* Support for translation providers / Add google translate service

* Create a script

```js
var mock = {
  parameter:{
    q:'hello',
    source:'en',
    target:'fr'
  }
};

function doGet(e) {
  e = e || mock;

  var sourceText = ''
  if (e.parameter.q){
    sourceText = e.parameter.q;
  }

  var sourceLang = '';
  if (e.parameter.source){
    sourceLang = e.parameter.source;
  }

  var targetLang = 'en';
  if (e.parameter.target){
    targetLang = e.parameter.target;
  }

  var translatedText = LanguageApp.translate(sourceText, sourceLang, targetLang, {contentType: 'html'});

  return ContentService.createTextOutput(translatedText).setMimeType(ContentService.MimeType.JSON);
}
```

* Deploy it as webapp for anonymous user
* Configure the service URL in the translation provider

* Support for translation providers / Add Anchor support.

* Support for translation providers / Create one directive for the configuration. Add examples for easier XPath configuration.

* Support for translation providers / Improve translation.

* Support for translation providers / Fix bad xpath.

* Update translationproviders/src/main/java/org/fao/geonet/translations/googletranslate/GoogleTranslateService.java

* Update translationproviders/src/main/java/org/fao/geonet/translations/libretranslate/LibreTranslateClientException.java

* Update web-ui/src/main/resources/catalog/components/admin/harvester/partials/translate.html

* Update web-ui/src/main/resources/catalog/components/admin/harvester/partials/translate.html

---------



* Translation providers - support additional harvesters: GeoNetwork, Local filesystem, OAI-PHM, WebDav

---------

Co-authored-by: François Prunayre <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants