Loading ...
Sorry, an error occurred while loading the content.
 

Re: version 2.5.0 scripting option

Expand Messages
  • HOGG Maynard
    ... I had decided to play it safe and use the latest 2.3 update, but your comment intrigued me because I have a JavaScript filter that I d like to run on each
    Message 1 of 12 , Oct 22, 2011
      On Sun, Oct 23, 2011 at 03:18, GMX <wmhelton@...> wrote:
      > I've just installed 2.5.0 to try out some of the new functionality, but so far haven't figured out the new scripting option.

      I had decided to play it safe and use the latest 2.3 update, but your
      comment intrigued me because I have a JavaScript filter that I'd like
      to run on each source segment.

      > I've clicked on Options -> Scripting, had a window appear,

      I'm using the Windows version. No window. No Scripting on the Options menu.
    • Marc Prior
      You did install the plug-in? The feature isn t in the core app. Marc
      Message 2 of 12 , Oct 22, 2011
        You did install the plug-in? The feature isn't in the core app.

        Marc



        On 10/23/2011 01:07 AM, HOGG Maynard wrote:
        > On Sun, Oct 23, 2011 at 03:18, GMX<wmhelton@...> wrote:
        >> I've just installed 2.5.0 to try out some of the new functionality, but so far haven't figured out the new scripting option.
        > I had decided to play it safe and use the latest 2.3 update, but your
        > comment intrigued me because I have a JavaScript filter that I'd like
        > to run on each source segment.
        >
        >> I've clicked on Options -> Scripting, had a window appear,
        > I'm using the Windows version. No window. No Scripting on the Options menu.
        >
        >
        > ------------------------------------
        >
        > The OmegaT Project Philosophy:
        > http://www.omegat.org/en/philosophy.html
        > The OmegaT Project and You:
        > http://www.omegat.org/en/involved.html
        >
        > OmegaT contributors should join the "omegat-development" group
        > OmegaT localizers should join the "omegat-l10n" group
        > http://sourceforge.net/mail/?group_id=68187
        >
        > IRC channel: http://java.freenode.net//index.php?channel=omegat
        > or: irc://irc.freenode.net/omegat
        > Bug reports, feature requests, OmegaT test versions etc...:
        > http://sourceforge.net/projects/omegat/
        >
        > ------------------------------------
        >
        > Yahoo! Groups Links
        >
        >
        >
        >
      • HOGG Maynard
        ... What plug-in? Where? There is no mention in the help files.
        Message 3 of 12 , Oct 22, 2011
          On Sun, Oct 23, 2011 at 08:16, Marc Prior <mail@...> wrote:
          > You did install the plug-in? The feature isn't in the core app.

          What plug-in? Where? There is no mention in the help files.
        • Marc Prior
          From Didier s announcement of the 2.5.0 release on 2011-09-29: It is now possible to run scripts from within OmegaT. These scripts have access to the internal
          Message 4 of 12 , Oct 22, 2011
            From Didier's announcement of the 2.5.0 release on 2011-09-29:

            "It is now possible to run scripts from within OmegaT. These scripts have access to the internal model, so they can modify data without having to quit OmegaT. They can also create user interface elements. Currently, the languages supported are NetRexx, XSLT, Groovy and JavaScript. The scripting feature is a plugin (https://sourceforge.net/projects/omegat-plugins/files/OmegaT-Scripting/), and has to be installed separately. Some script samples are provided.


            2.5.0. is a "latest version", not a "standard version" (a beta, but our
            betas are closer to production quality than usual and we don't call them
            that), so documentation is still minimal.

            Marc



            On 10/23/2011 01:33 AM, HOGG Maynard wrote:
            > On Sun, Oct 23, 2011 at 08:16, Marc Prior<mail@...> wrote:
            >> You did install the plug-in? The feature isn't in the core app.
            > What plug-in? Where? There is no mention in the help files.
            >
            >
            > ------------------------------------
            >
            > The OmegaT Project Philosophy:
            > http://www.omegat.org/en/philosophy.html
            > The OmegaT Project and You:
            > http://www.omegat.org/en/involved.html
            >
            > OmegaT contributors should join the "omegat-development" group
            > OmegaT localizers should join the "omegat-l10n" group
            > http://sourceforge.net/mail/?group_id=68187
            >
            > IRC channel: http://java.freenode.net//index.php?channel=omegat
            > or: irc://irc.freenode.net/omegat
            > Bug reports, feature requests, OmegaT test versions etc...:
            > http://sourceforge.net/projects/omegat/
            >
            > ------------------------------------
            >
            > Yahoo! Groups Links
            >
            >
            >
            >
          • HOGG Maynard
            ... Thanks for the pointer. The message scrolled off the screen during my bout with bronchitis. Glancing through the sample scripts, I thought that I could
            Message 5 of 12 , Oct 26, 2011
              On Sun, Oct 23, 2011 at 08:49, Marc Prior <mail@...> wrote:
              >  From Didier's announcement of the 2.5.0 release on 2011-09-29:
              > "It is now possible to run scripts from within OmegaT. These scripts have access to the

              Thanks for the pointer. The message scrolled off the screen during my
              bout with bronchitis.

              Glancing through the sample scripts, I thought that I could rework
              check_same_segments.js into a script for automatically "translating"
              numbers-only segments.

              Here's as far as I got with the central loop before I get the message
              "Cannot find function setTranslation in object
              org.omegat.core.data.SourceTextEntry@8b1323."

              if (target) {/* do nothing*/}
              else if (source.match(/^[0-9]+$/) ) {
              ste.setTranslation(target);
              console.println(ste.entryNum() + "\t" + source + "\t" + target);
              segment_count++;
              }

              Needless to say, if plan further "else if" clauses to handle more
              complicated number formats.
            • Didier Briel
              ... I think your call lacks several parameters of setTranslation. From IProject.java /** * Set translation for entry. Use when user has typed a new
              Message 6 of 12 , Oct 26, 2011
                -----Original Message-----
                >From: OmegaT@yahoogroups.com [mailto:OmegaT@yahoogroups.com]On Behalf Of HOGG Maynard
                >Sent: Wednesday, October 26, 2011 12:06 PM
                >To: OmegaT@yahoogroups.com
                >Subject: Re: [OmT] Re: version 2.5.0 scripting option
                >
                >On Sun, Oct 23, 2011 at 08:49, Marc Prior <mail@...> wrote:
                >> From Didier's announcement of the 2.5.0 release on 2011-09-29:
                >> "It is now possible to run scripts from within OmegaT. These scripts have access to the
                >
                >Thanks for the pointer. The message scrolled off the screen during my
                >bout with bronchitis.
                >
                >Glancing through the sample scripts, I thought that I could rework
                >check_same_segments.js into a script for automatically "translating"
                >numbers-only segments.
                >
                >Here's as far as I got with the central loop before I get the message
                >"Cannot find function setTranslation in object
                >org.omegat.core.data.SourceTextEntry@8b1323."
                >
                > if (target) {/* do nothing*/}
                > else if (source.match(/^[0-9]+$/) ) {
                > ste.setTranslation(target);
                > console.println(ste.entryNum() + "\t" + source + "\t" + target);
                > segment_count++;
                > }
                >

                I think your call lacks several parameters of setTranslation.

                From IProject.java
                /**
                * Set translation for entry. Use when user has typed a new translation.
                *
                * @param entry
                * entry
                * @param trans
                * translation
                * @param isDefault
                * true if default translation should be changed
                */
                void setTranslation(SourceTextEntry entry, String trans, String note, boolean isDefault);


                Didier
              • Briac Pilpré
                Another way to do it could be (in Groovy) : def ste = editor.currentEntry; if (ste.srcText ==~ /^ d+$/ ) { console.println(editor.currentEntryNumber + t +
                Message 7 of 12 , Oct 26, 2011
                  Another way to do it could be (in Groovy) :

                  def ste = editor.currentEntry;

                  if (ste.srcText ==~ /^\d+$/ ) {
                  console.println(editor.currentEntryNumber + "\t" + ste.srcText );

                  editor.replaceEditText(ste.srcText);
                  }
                  editor.nextEntry();


                  On Wed, Oct 26, 2011 at 4:08 PM, Didier Briel <d.briel@...> wrote:

                  > **
                  >
                  >
                  > -----Original Message-----
                  > >From: OmegaT@yahoogroups.com [mailto:OmegaT@yahoogroups.com]On Behalf Of
                  > HOGG Maynard
                  > >Sent: Wednesday, October 26, 2011 12:06 PM
                  > >To: OmegaT@yahoogroups.com
                  > >Subject: Re: [OmT] Re: version 2.5.0 scripting option
                  > >
                  > >On Sun, Oct 23, 2011 at 08:49, Marc Prior <mail@...> wrote:
                  > >> From Didier's announcement of the 2.5.0 release on 2011-09-29:
                  > >> "It is now possible to run scripts from within OmegaT. These scripts
                  > have access to the
                  > >
                  > >Thanks for the pointer. The message scrolled off the screen during my
                  > >bout with bronchitis.
                  > >
                  > >Glancing through the sample scripts, I thought that I could rework
                  > >check_same_segments.js into a script for automatically "translating"
                  > >numbers-only segments.
                  > >
                  > >Here's as far as I got with the central loop before I get the message
                  > >"Cannot find function setTranslation in object
                  > >org.omegat.core.data.SourceTextEntry@8b1323."
                  > >
                  > > if (target) {/* do nothing*/}
                  > > else if (source.match(/^[0-9]+$/) ) {
                  > > ste.setTranslation(target);
                  > > console.println(ste.entryNum() + "\t" + source + "\t" + target);
                  > > segment_count++;
                  > > }
                  > >
                  >
                  > I think your call lacks several parameters of setTranslation.
                  >
                  > From IProject.java
                  > /**
                  > * Set translation for entry. Use when user has typed a new translation.
                  > *
                  > * @param entry
                  > * entry
                  > * @param trans
                  > * translation
                  > * @param isDefault
                  > * true if default translation should be changed
                  > */
                  > void setTranslation(SourceTextEntry entry, String trans, String note,
                  > boolean isDefault);
                  >
                  > Didier
                  >
                  >
                  >



                  --
                  briac


                  [Non-text portions of this message have been removed]
                • HOGG Maynard
                  ... I thought as much, but had to put research on the back burner while I did things manually—much easier now with Find s Filter option—to meet the
                  Message 8 of 12 , Oct 26, 2011
                    On Wed, Oct 26, 2011 at 23:08, Didier Briel <d.briel@...> wrote:
                    >>          ste.setTranslation(target);
                    > I think your call lacks several parameters of setTranslation.

                    I thought as much, but had to put research on the back burner while I
                    did things manually—much easier now with Find's Filter option—to meet
                    the deadline.
                  • HOGG Maynard
                    ... I m not sure what d encompasses, so will stick with [0-9] for Unified Han input. ... This almost works in JS—the list of segment numbers in the console
                    Message 9 of 12 , Oct 26, 2011
                      On Wed, Oct 26, 2011 at 23:25, Briac Pilpré <briacp@...> wrote:
                      > if (ste.srcText ==~ /^\d+$/  ) {

                      I'm not sure what \d encompasses, so will stick with [0-9] for Unified
                      Han input.

                      >    editor.replaceEditText(ste.srcText);

                      This almost works in JS—the list of segment numbers in the console is
                      correct, first of all—but the colors do not change.
                      project.getTranslation() returns null for the translated half of the
                      segments. I think I need an UPDATE or COMMIT option.

                      if (target || !source.match(/^[ -~]+$/)) {/* do nothing*/}
                      else if (source.match(/^[0-9]+$/) ) {
                      // ste.setTranslation(target); // error: missing arguments?
                      editor.replaceEditText(ste.srcText);
                      // ste.setTranslation(ste.entryNum(), ste.srcText, true);
                      console.println(ste.entryNum() + "\t" + source + "\t" +
                      project.getTranslation(ste));
                      segment_count++;
                      }
                    • HOGG Maynard
                      ... Progress, but similar error. Have I made a typo? JavaScript Error: Internal Error: org.mozilla.javascript.EcmaError: TypeError: Cannot find function
                      Message 10 of 12 , Oct 26, 2011
                        On Wed, Oct 26, 2011 at 23:08, Didier Briel <d.briel@...> wrote:
                        >>Here's as far as I got with the central loop before I get the message
                        >>"Cannot find function setTranslation in object
                        >>org.omegat.core.data.SourceTextEntry@8b1323."

                        > I think your call lacks several parameters of setTranslation.

                        > From IProject.java
                        >    /**
                        >     * Set translation for entry. Use when user has typed a new translation.
                        >     *
                        >     * @param entry
                        >     *            entry
                        >     * @param trans
                        >     *            translation
                        >     * @param isDefault
                        >     *            true if default translation should be changed
                        >     */
                        >    void setTranslation(SourceTextEntry entry, String trans, String note, boolean isDefault);

                        Progress, but similar error. Have I made a typo?

                        JavaScript Error: Internal Error: org.mozilla.javascript.EcmaError:
                        TypeError: Cannot find function setTranslation in object
                        org.omegat.core.data.SourceTextEntry@1675ec4.

                        if (target || !source.match(/^[ -~]+$/)) {/* do nothing*/}
                        else if (source.match(/^[0-9]+$/) ) {
                        // ste.setTranslation(target); // error: missing arguments?
                        // editor.replaceEditText(ste.srcText);
                        ste.setTranslation(ste.entryNum(), ste.srcText,
                        "fill_number_segments.js", true);
                        console.println(ste.entryNum() + "\t" + source + "\t" +
                        project.getTranslation(ste));
                        segment_count++;
                        }

                        Time for breakfast. And work.
                      • Didier Briel
                        ... These discussions should be better located under the omegat-development mailing list. I Cc on that list. ...
                        Message 11 of 12 , Oct 27, 2011
                          -----Original Message-----
                          >From: OmegaT@yahoogroups.com [mailto:OmegaT@yahoogroups.com]On Behalf Of HOGG Maynard
                          >Sent: Thursday, October 27, 2011 12:31 AM
                          >To: OmegaT@yahoogroups.com
                          >Subject: Re: [OmT] Re: version 2.5.0 scripting option

                          These discussions should be better located under the omegat-development mailing list.
                          I Cc on that list.

                          >On Wed, Oct 26, 2011 at 23:25, Briac Pilpré <briacp@...> wrote:
                          >> if (ste.srcText ==~ /^\d+$/ ) {
                          >
                          >I'm not sure what \d encompasses,

                          http://download.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html
                          Predefined character classes
                          \d A digit: [0-9]

                          >> editor.replaceEditText(ste.srcText);
                          >
                          >This almost works in JS-the list of segment numbers in the console is
                          >correct, first of all-but the colors do not change.
                          >project.getTranslation() returns null for the translated half of the
                          >segments. I think I need an UPDATE or COMMIT option.

                          Have you enabled "Allow translation to be equal to source" in Editing Behaviour?

                          Didier
                        • Didier Briel
                          ... These discussions should be better located under the omegat-development mailing list. I Cc on that list. ... ste.entryNum() is not an entry, is it? Didier
                          Message 12 of 12 , Oct 27, 2011
                            -----Original Message-----
                            >From: OmegaT@yahoogroups.com [mailto:OmegaT@yahoogroups.com]On Behalf Of HOGG Maynard
                            >Sent: Thursday, October 27, 2011 12:38 AM
                            >To: OmegaT@yahoogroups.com
                            >Subject: Re: [OmT] Re: version 2.5.0 scripting option

                            These discussions should be better located under the omegat-development mailing list.
                            I Cc on that list.

                            >On Wed, Oct 26, 2011 at 23:08, Didier Briel <d.briel@...> wrote:
                            >>>Here's as far as I got with the central loop before I get the message
                            >>>"Cannot find function setTranslation in object
                            >>>org.omegat.core.data.SourceTextEntry@8b1323."
                            >
                            >> I think your call lacks several parameters of setTranslation.
                            >
                            >> From IProject.java
                            >> /**
                            >> * Set translation for entry. Use when user has typed a new translation.
                            >> *
                            >> * @param entry
                            >> * entry
                            >> * @param trans
                            >> * translation
                            >> * @param isDefault
                            >> * true if default translation should be changed
                            >> */
                            >> void setTranslation(SourceTextEntry entry, String trans, String note, boolean isDefault);
                            >
                            >Progress, but similar error. Have I made a typo?
                            >
                            >JavaScript Error: Internal Error: org.mozilla.javascript.EcmaError:
                            >TypeError: Cannot find function setTranslation in object
                            >org.omegat.core.data.SourceTextEntry@1675ec4.
                            >
                            > if (target || !source.match(/^[ -~]+$/)) {/* do nothing*/}
                            > else if (source.match(/^[0-9]+$/) ) {
                            >// ste.setTranslation(target); // error: missing arguments?
                            >// editor.replaceEditText(ste.srcText);
                            > ste.setTranslation(ste.entryNum(), ste.srcText,
                            >"fill_number_segments.js", true);

                            ste.entryNum() is not an entry, is it?

                            Didier
                          Your message has been successfully submitted and would be delivered to recipients shortly.