how to Untranslated an image from a macro ?

Hi,

 I try by macro to untranslated an image in passolo 2018 18.0.178.0

The image comes from a .CHM file. My first image it's the Resource(6).

I can provide the lpu if you need.

When I try to change the value for the state of pslStateTranslated

The debugger stop and  I received the error on execution 

128) This state flag can not be set for this resource. 

On this line

prj.TransLists.Item(1).Resource(6).State(pslStateTranslated)= False

 

Set prj = PSL.ActiveProject 

If (prj.TransLists.Item(1).Resource(6).IsBinary )then

     If (prj.TransLists.Item(1).Resource(6).State(pslStateTranslated)) Then   

          ‘ import the source image in the translated list        

          filename = prj.TransLists.Item(1).SourceList.Resource(6).IDName       

          target2 = prj.TransLists.Item(1).SourceList.Resource(6).ExportBinary("D:\test",fileName)       

          prj.TransLists.Item(1).Resource(6).ImportBinary(target2)     

           ‘ try to set the image to untranslated. 

          prj.TransLists.Item(1).Resource(6).State(pslStateTranslated)= False       

          prj.TransLists.Item(1).Save 

     end if

end if

 

If this is the right way to untranslated an image?

emoji
Parents Reply Children
  • Hi Achim,

    In the help file have a picture of the user interface translated. I can't leave the picture of the user interface in English in the French version of the help file.

    I don't have choice to importbinary translated picture.

    My goal it's to untranslate an image. Like we do for a string. When you click un the red X to delete in the input box, the state return like to be before you translate.

    I want to be in same state before I importbinary the image. What are the step I need to do?

    The actual result I have are :

    If you create a new project with a new language, you check by macro the state for the image is :

    prj.TransLists.Item(1).Resource(6).State(pslStateTranslated) is False

    if you try to export the translated image, you have no file generate. 

    prj.TransLists.Item(1).Resource(6).ExportBinary("D:\test",fileName) .

    After import binary

    prj.TransLists.Item(1).Resource(6).ImportBinary(target2)

    If you test state fater  it's true

    prj.TransLists.Item(1).Resource(6).State(pslStateTranslated) is True.

    My goal it's to delete the translated image and have the state = false.

    Also in the user interface I can't find a way to untranslated a specific image. I ask the support and they can't find the way too.

    Thanks for your help 

     

    emoji
  • lease note that binary resources don’t have a .State(pslStateTranslated) property. It simply doesn’t exist in the data model. See here for more details: https://docs.rws.com/957276/464620/passolo-automation/pslresource-state So your code:

    prj.TransLists.Item(1).Resource(6).State(pslStateTranslated)

    will return an arbitrary result, but nothing that can be used, and it can’t be set, which explains the runtime error you reported in your last post.

    So let me come back to the initial goal of your request. Usually binary images in files like CHM, EXE, DLL will not be changed during the localization. If this becomes necessary because of text in images, Passolo offers functions to export the images, change them outside of Passolo then import back the changed images. In the Passolo data model binary resources such as images are not handled like string entries. So there is no Translated flag. If you changed the images using Export and Import, the only way back to the original images (or un-translate) is to re-import the original images into the project.

    emoji
  • Please try this code, which exports the source image and imports it back into the translated images:

        Dim trn As PslTransList
        For Each trn In prj.TransLists
            Dim i As Long
            For i = 1 To trn.ResourceCount
                Dim res As PslResource
                Set res = trn.Resource(i)
                If res.IsBinary Then
                    Dim fname As String
                    fname = trn.SourceList.Resource(i).ExportBinary(prj.Location, "")
                    res.ImportBinary(fname)
                    Kill fname
                End If
            Next i
            trn.Save
        Next
    emoji
  • Thanks Achim,

    Copy the original image in the translated, it's only a step but this is not a solution for me.

    To verify if a 1200 images which one need to be translated manually every 6 weeks, it's too long. 

    emoji
  • However, I hope that the code provided at least answers the original question "How to untranslate an image from a macro" sufficiently well and provides a solution to this problem.

    Passolo was developed for the localization of strings in graphical user interfaces. It contains a few functions that can be used to modify and replace images, but it does not have true image localization functions due to limitations of the underlying data model.

    For the vast majority of customers, the functions provided are sufficient because images are not usually localized. Therefore, for the management and localization of 1200 images in a large online documentation, other tools, such as large CMS systems, should be used.

    emoji