Coder Social home page Coder Social logo

Comments (15)

jason-fox avatar jason-fox commented on June 2, 2024

Since this plug has been developed under UNIX, unsurprisingly this is another Windows incompatibility. This is probably down to one of two things:

  1. Spaces in your file path C:\Users\Michael\Documents\CE\Documentation\eLABin1 xml (eng)\eLABin1\SCPI\out2\skl - try replacing the spaces in eLABin1 xml (eng) with underscores e.g.eLABin1_xml_eng.
  2. Your document DOCTYPE not being present in the list of DTDs - just add a line here

It may be easier just to run via a Docker Image to pretend to be a Unix environment.

To investigate further, run the transform under trace debug mode and attach the full logs.

dita -d -f xliff-create -i XXX -o YYY

from fox.jason.translate.xliff.

Tiemichael avatar Tiemichael commented on June 2, 2024

Thank you the very fast reply!
I have replaced the spaces with underscores, but the output does not change.
Any idea what DOCTYPE is missing? I had added some already earlier in build_dita2translate.xml and build_dita2translate_template.xml.
If I find time I will explore the usage of Docker or Linux.

The full logs are attached:
dita_t.log
dita_c.log

from fox.jason.translate.xliff.

Tiemichael avatar Tiemichael commented on June 2, 2024

Update:
After installing dita on an Ubuntu-machine I got it running.
xliff-create: shows the same warnings as under Windows
xliff-tranlate: using Bing/Azure: the Header property "Ocp-Apim-Subscription-Region" is missing. After adding it together with a region (eg 'southeastasia') to translate1.1.jar it's working.
xliff-dita: OxygenXML shows several errors with the generated dita-file, mainly related to 'xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/". After manually deleting these, I was able to generate a translated PDF.

There are still quite a lot of areas I need to figure out, but in general it's working for me.
Thanks!

from fox.jason.translate.xliff.

jason-fox avatar jason-fox commented on June 2, 2024

xliff-tranlate: using Bing/Azure: the Header property "Ocp-Apim-Subscription-Region" is missing.

Is it just the call to the Azure translate which is missing the header?

curl -X POST 'https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&from=en&to=de' \
-H 'Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY' \
-H 'Ocp-Apim-Subscription-Region: YOUR_SUBSCRIPTION_REGION' \
-H 'Content-Type: application/json' \
--data-raw '[{ "text": "How much for the cup of coffee?" }]' | json_pp

I guess this plugin was created before the multi-service subscription key was introduced. If you raise a PR where the changes need to be made I could review (I assume the header would remain as an optional extra.)

from fox.jason.translate.xliff.

jason-fox avatar jason-fox commented on June 2, 2024

xliff-dita: OxygenXML shows several errors with the generated dita-file, mainly related to 'xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/".

Could you supply a broken snippet and a working one? The xliff-dita transform could attempt to do more clean up if necessary.

from fox.jason.translate.xliff.

Tiemichael avatar Tiemichael commented on June 2, 2024

Azure translate: yes, it's just this header which is missing.
I am not familiar with Java, so I don't know how to add it to the configuration.properties and command-line options.

Attached are 2 files (before_ and after_clean) which you can compare side by side:
before_clean.txt
after_clean.txt

from fox.jason.translate.xliff.

jason-fox avatar jason-fox commented on June 2, 2024

I've added the optional region header:

dita uninstall fox.jason.translate.xliff
dita install https://github.com/jason-fox/fox.jason.translate.xliff/archive/master.zip
dita -f xliff-translate -i XXX -o YYY translate.region=westus translate.apikey=XXX

should now work on UNIX. See 05ee72e

from fox.jason.translate.xliff.

Tiemichael avatar Tiemichael commented on June 2, 2024

So Fast!!!
Does it also support an entry in configuration.properties?
Will test tomorrow ...

from fox.jason.translate.xliff.

Tiemichael avatar Tiemichael commented on June 2, 2024

after installing the new plugin I am unable to get the translation to work.
I also realized the following:

  • dita uninstall fox.jason.translate.xlifffox.jason.prismjs - is not working, should be dita uninstall fox.jason.translate.xliff
  • dita -f xliff-translate -i XXX -o YYY translate.region=westus translate.apikey=XXX - I think it should be --translate.region=westus --translate.apikey=XXX

When starting xliff-translate I get an error:

 `translate.init:
[bing-auth] Current OS is Linux
[bing-auth] Output redirected to property: bing.out
[bing-auth] Executing 'curl' with arguments:
[bing-auth] '-X'
[bing-auth] 'POST'
[bing-auth] '-H'
[bing-auth] 'Ocp-Apim-Subscription-Key: xxxxxx'
[bing-auth] '-H'
[bing-auth] 'Content-type: application/x-www-form-urlencoded'
[bing-auth] '-H'
[bing-auth] 'Content-length: 0'
[bing-auth] '--output'
[bing-auth] '/tmp/temp20210429105736807/null456598806.txt'
[bing-auth] '-sS'
[bing-auth] 'https://api.cognitive.microsoft.com/sts/v1.0/issuetoken'
[bing-auth] 
[bing-auth] The ' characters around the executable and arguments are
[bing-auth] not part of the command.
[auth-bing] 
 [loadfile] loading /tmp/temp20210429105736807/null456598806.txt into property bing.bearer.token
 [loadfile] loaded 225 characters
Overriding previous definition of reference to XLFF004F
  [antcall] Exiting /home/michael/dita-ot-3.6.1/build.xml.
Error: The following error occurred while executing this line:
jar:file:/home/michael/dita-ot-3.6.1/plugins/fox.jason.translate.xliff/lib/translate-1.2.jar!/fox/jason/translate/antlib.xml:465: [XLFF004F][FATAL] Microsoft Azure credentials not set. Update the configuration.properties file to hold your URL and API Key`

from fox.jason.translate.xliff.

jason-fox avatar jason-fox commented on June 2, 2024

Ah, that is the /issuetoken endpoint not the /translate endpoint. I've added the same if...then...else to auth - please pull and retest:

dita uninstall fox.jason.translate.xliff
dita install https://github.com/jason-fox/fox.jason.translate.xliff/archive/master.zip
dita -f xliff-translate -i XXX -o YYY --translate.region=westus --translate.apikey=XXX

see: 5fb54fc

from fox.jason.translate.xliff.

Tiemichael avatar Tiemichael commented on June 2, 2024

At the moment I am unable to succeed ..

translate.init:
[bing-auth] Current OS is Linux
[bing-auth] Output redirected to property: bing.out
[bing-auth] Executing 'curl' with arguments:
[bing-auth] '-X'
[bing-auth] 'POST'
[bing-auth] '-H'
[bing-auth] 'Ocp-Apim-Subscription-Key: 1234567'
[bing-auth] '-H'
[bing-auth] 'Ocp-Apim-Subscription-Region: southeastasia'
[bing-auth] '-H'
[bing-auth] 'Content-type: application/x-www-form-urlencoded'
[bing-auth] '-H'
[bing-auth] 'Content-length: 0'
[bing-auth] '--output'
[bing-auth] '/tmp/temp20210429160203278/null1976694167.txt'
[bing-auth] '-sS'
[bing-auth] 'https://api.cognitive.microsoft.com/sts/v1.0/issuetoken'
[bing-auth] 
[bing-auth] The ' characters around the executable and arguments are
[bing-auth] not part of the command.
[auth-bing] 
 [loadfile] loading /tmp/temp20210429160203278/null1976694167.txt into property bing.bearer.token
 [loadfile] loaded 225 characters
Overriding previous definition of reference to XLFF004F
  [antcall] Exiting /home/michael/dita-ot-3.6.1/build.xml.
Error: The following error occurred while executing this line:
jar:file:/home/michael/dita-ot-3.6.1/plugins/fox.jason.translate.xliff/lib/translate-1.2.jar!/fox/jason/translate/antlib.xml:485: [XLFF004F][FATAL] Microsoft Azure credentials not set. Update the configuration.properties file to hold your URL and API Key.

It would be great if you can add the 'translate.region' to the configuration.properties file

PS: just saw: 'Content-type: application/x-www-form-urlencoded', shouldn't it be "Content-type: application/json") ?

from fox.jason.translate.xliff.

jason-fox avatar jason-fox commented on June 2, 2024

The default configuration.properties file holds:

# Microsoft Azure
bing.apikey=XXX
bing.authentication.url=https://api.cognitive.microsoft.com/sts/v1.0/issuetoken
bing.translate.url=https://api.cognitive.microsofttranslator.com/translate

I've tested it and the following Curl statements work for me:

curl -L -X POST 'https://api.cognitive.microsoft.com/sts/v1.0/issuetoken' \
-H 'Ocp-Apim-Subscription-Key: <bing.apikey>' \
-H 'Content-Length: 0'

creates a bearer token which works for me:

curl -L -X POST 'https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&to=es' \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
--data-raw '[{"Text":"Hello, what is your name?"}]'

uses the token and returns:

[
    {
        "detectedLanguage": {
            "language": "en",
            "score": 1.0
        },
        "translations": [
            {
                "text": "Hola, ¿cómo te llamas?",
                "to": "es"
            }
        ]
    }
]

alternatively I can use the subscription code directly:

curl -L -X POST 'https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&to=es' \
-H 'Ocp-Apim-Subscription-Key: <bing.apikey>' \
-H 'Content-Type: application/json' \
--data-raw '[{"Text":"Hello, what is your name?"}]'

returns

[
    {
        "detectedLanguage": {
            "language": "en",
            "score": 1.0
        },
        "translations": [
            {
                "text": "Hola, ¿cómo te llamas?",
                "to": "es"
            }
        ]
    }
]

Can you provide the Curl statement you would normally use to log in to Azure using the regional variant.

Also try raising the debug level to -d and running with and without region and attaching the error message you are getting from Azure

dita -d -f xliff-translate -i XXX -o YYY --translate.region=westus --translate.apikey=XXX

and

dita -f xliff-translate -i XXX -o YYY  --translate.apikey=XXX

from fox.jason.translate.xliff.

Tiemichael avatar Tiemichael commented on June 2, 2024

I was following the official documentation from https://docs.microsoft.com/en-us/azure/cognitive-services/translator/reference/v3-0-reference, and for me the following is working:
curl -L -X POST 'https://southeastasia.api.cognitive.microsoft.com/sts/v1.0/issuetoken'
-H 'Ocp-Apim-Subscription-Key: xxxxxxx' -H 'Content-Length: 0'

After changing the configuration.properties file to: bing.authentication.url=https://southeastasia.api.cognitive.microsoft.com/sts/v1.0/issuetoken the translation is working.

Sorry, I missed this earlier ...
Thanks

from fox.jason.translate.xliff.

Tiemichael avatar Tiemichael commented on June 2, 2024

sorry to bother you again:

After translating a longer document, I realize that:
'glossrefs' are missing from the translation.

I saw the file 'no-translate-elements.xsl' which seems to specify elements which are not translated.
After the translation the <codeph>-tag is missing

<p> inside <ul> <li> are missing: everything is 1 long line

from fox.jason.translate.xliff.

jason-fox avatar jason-fox commented on June 2, 2024

Documentation has been updated regarding URLs - closing

from fox.jason.translate.xliff.

Related Issues (6)

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.