Is there a way to update/pretranslate only some source or translation lists by macro?

Hi,

in my workflow, I'm using a macro tor updating and leveraging the source string lists, filtering some strings and to update and pretranslate the target string lists afterwards.

Unfortunately, I didn't found a possibility to update and leverage the source lists as a collection - not by updating/leveraging each source list one by one instead of all source lists as a collection.
And I didn't found a possibility to update and pretranslate the target string lists - for a single language - as a collection instead of one by one, too.

Please be so kind to let me know, how updating, leveraging and pretranslating can be run as a single action by a macro instead of updating, laveraging and pretranslating each string list one by one.
If you have any further questions, please don't hesitate to let me know.
Thank you very much in advance for your support.

Kind regards and have a nice day.
Nils

emoji
Parents
  • Updating single lists can be done using PslTransList.Update and PslSourceList.Update.

    Updating lists as a collection can be done using PslProject.UpdateTransLists and PslProject.UpdateSourceLists.

    emoji
  • Hello ,

    thanks for your reply.

    Is there a way, to "create" a collection of some source or target string lists?
    For example, I'd like to pre translate only string lists of one target language instead of all target languages. And the same for updating the target string lists.
    At the moment, I'm running the pre translation as well as the update for each string list separately using "PslTransList.Update" and "...autotranslate".

    Wouldn't it be better and/or more efficient/less time consuming to update some string lists as a collection instead of one by one?

    Kind regards
    Nils

    emoji
  • Hello,

    can anybody give me a short example, how to create a new collection of string lists and how to add single string lists to this collection in a Passolo macro, please?

    I think, creating is done by 

    Fullscreen
    1
    Dim SourceListCollection As New ???
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    But "As New" what?
    And how do I add single lists to this collection to be able to run an update or leverage afterwards? Thinking


    I'd like to run a "leverage" as well as an update of only the string lists in the colletion. (Instead of leveraging or updating all string lists at once or every string list, one by one.)

    Thank you very much in advance for your support.

    Best regards and have an easy day.
    Nils

    emoji
  • I don't know whether it would make sense to talk about possible approaches to implementing a collection here. If this is really desired, I would probably implement a class (Class PslSourceListCollection), which then gets the methods I need implemented. Examples would be management functions such as RemoveAll, Add, etc. but also Passolo-specific functions such as PreTranslate or Update or Leverage. If such a class were designed and implemented, it could be used in various macros.

    Although I have already implemented a lot of macros, it never occurred to me to implement further classes and objects as macro classes in addition to the Passolo object model. The methods and properties (here Update and Leverage) provided by the Passolo object model have been sufficient for me in most of the use cases.

    In order to implement the required functions, I mostly worked with loops and in my opinion this would also be necessary if there were a collection. My approach would be:

    For Each src In prj.SourceLists
        If Condition Then
            src.Update
        End If
    Next src
    

    With the usage of a collection, it may look like this:

    Dim SrcColl As New PslSourceListCollection
    SrcColl.RemoveAll
    For Each src In prj.SourceLists
        If Condition Then
            SrcColl.Add src
        End If
    Next src
    SrcColl.UpdateAll
    

    My approach can't really be reused very well, but one of the goals was always to deliver a solution as quickly as possible and with as little effort as possible.

    emoji
  • Good morning ,

    thank you very much for your reply and especially for your example coding.

    I've been thinking about creating and using a collection of string lists, because RWS support mentioned during a support case: "The macro you use seems to perform the leverage on files one by one instead of running a single batch of files, this should be changed, if possible, to select all the files and run a single leverage action which should help again with performance."

    If I understand your reply correctly, it should be "enough" (regarding especially the performance), to use the existing classes and objects from the Passolo object model and, for example, to run a

    Fullscreen
    1
    2
    3
    4
    5
    For Each TranslationList In project.TransLists
    If TranslationList.Language.LangID = Language.LangID Then
    TranslationList.Leverage(EnglishProject)
    End If
    Next
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    if we only want to leverage or update some of the string lists. Or would it be better from your point of view, to use new collections in this case?

    Best regards and have an easy day.
    Nils

    emoji
  • PslTransList.Leverage is a method that can be called file by file only. Running Leverage on a batch of translation or source lists is just possible using the UI. So a collection cannot help here, because the Leverage must also be called file by file in the methods of the collection class.

    What might help regarding performance is that fact that each method that runs on complete lists (like Leverage) will automatically save its changes when it ends. When your project is on a shared network drive and unpacked, that might take ages. To prevent this, please use

    prj.SuspendSaving
    For Each TranslationList In Project.TransLists
        If TranslationList.Language.LangID = Language.LangID Then
            TranslationList.Leverage(EnglishProject)
        End If
    Next
    prj.ResumeSaving

    This might already help to boost performance.

    emoji
  • Hello ,

    that's a good hint! Slight smile
    Can unpacking and repacking of a project be done, only using the UI or using a macro, too? Unfortunately, I didn't found a possibility, to do this within a macro, until now.

    Best regards
    Nils

    emoji
  • Packing and Unpacking is a one-off task that is only available in the UI. It will usually be done just once then the project is used in unpacked mode.

    emoji
  • Hello ,

    sorry for asking again:
    I've now tried suspending the saving process prior and resuming it after all steps, the macro should do.
    Unfortunately, the changes to the string lists seams not to be saved.

    Fullscreen
    1
    2
    3
    4
    5
    project.SuspendSaving
    For Each SourceList In project.SourceLists
    ...
    Next
    project.ResumeSaving
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    How do I save the changes to the string lists?

    Best regards and thank you very much for your support.
    Nils

    emoji
  • Oh, I thought this is clear and have not mentioned it. Use

    SourceList.Save
    emoji
  • Good morning ,

    I didn't thought, I'd have to use

    Fullscreen
    1
    SourceList.Save
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    Face palmJoy
    Now, it's working as expected. Thumbsup

    Thank you very much again for your support.

    Best regards and have a great and easy day.
    Nils

    emoji
  • Would be good, if you can report if there are performance gains.

    emoji
Reply Children
  • Hello  ,
    I'll try to test it as soon as I've been able to "fix" my issue with 

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    Dim TranslationList As PslTransList
    With TranslationList
    For Each TranslationList In project.TransLists
    PSL.Output "Übersetzungsliste: '" & .Title & "'..."
    If .IsDeleted = False Then
    Do Something
    End If
    Next
    End With
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    , leading to "(10094) ActiveX-Automation: Ojektvariable ist 'Nothing'".
    It's some kind of learning by doing and try and error. Laughing

    emoji
  • I think the problem is, that the With statement is using an undefined variable that isn't set. TranslationList will be defined in For Each loop for the first time.

    emoji
  • Good morning ,

    yes, that's been the error. Rolling eyes
    And Ithought, that one could use a "For Each..." loop with PslSourceList and PslTransList, too. But as far as I know now, they are arrays and "For Each..." can't be used with this two objects. But, step by step, I'm getting a little closer to what I'd like to achieve. Wink

    Thank you very much again, for your great support!

    Best regards
    Nils

    emoji