1. #1
    Senior Member Follow User Gallery
    Join Date
    Feb 2015
    Location
    Paris
    Posts
    263

    Default localization and ZfileUtils

    Hi, i just come up to integrate the localization to one of my plugin, but it's impossible to bring it to work.

    i has respect the instructions i just don't use the Zscript insert method; i grab the routines that are useful and copied all that in my plugin.

    let me list them here :


    ZFU_GetCurrentLanguage
    ZFU_RegisterLocalizationFile
    ZFU_LocalizeText
    ZFU_LocalizeTitle
    ZFU_LocalizeInfo
    ZFU_LocalizeDescr
    ZFU_StrReplaceArg
    InitZFUtilsTests
    and the last:
    [RoutineCall, InitZFUtilsTests]

    Issue description :

    The localization crashes Zbrush at the startup
    if i compile my plugin with this uncommented line :
    [RoutineCall, InitZFUtilsTests]
    i get this :



    Now if i run Zbrush, with that line disable, Zbrush will starts correctly,
    I edit my plugin code removing the // before that line, then I reload the plugin, and the localization is working great.

    It seems like the ZFU_RegisterLocalizationFile is the source of the crash .

    Any idea what's is going wrong ? i make sure i use the very last version of the zfileutil.dll but it doesn't resolve the issue.
    Plugins & Toolsets for Zbrush 4R8 : zCycler Pro | Plugin Manager |Matiere 3d | Twitter | @Facelessmindz

  2. #2
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    The point about <zscriptinsert> is the code is inserted at that point. Sometimes that can be critical.

    Have you tried the test zscript included in the ZFileUtils zip? Does that give the same error? If so, please let me know what OS you are on, so I can look into it. If you don't get the error then there's a problem with your code.

  3. #3
    Senior Member Follow User Gallery
    Join Date
    Feb 2015
    Location
    Paris
    Posts
    263

    Default

    great it doesn't crashes anymore, it's seems important to implement the routine before the [routinedef, checkSystem,//routine code] and [routinecall, checksystem]
    I don't want to use the zscript insert because i don't see the point of having this script at the Zplug64 dir root.

    So ok it doesn't crashes but it just doesn't translate any text or info at the moment.

    what the ZFU_GetCurrentLanguage routine is for ? i don't see it called from somewhere.
    Plugins & Toolsets for Zbrush 4R8 : zCycler Pro | Plugin Manager |Matiere 3d | Twitter | @Facelessmindz

  4. #4
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    If you use <zscriptinsert> the inserted zscript is compiled along with your main plugin script into a single ZSC. You don't need to include any text files in your distribution. It can be a useful way of keeping larger scripts manageable or adding routines you use often. But it can make scripts less readable.

    You need to provide translation files. The example script has just English and French, in the "lang" folder of the MyPluginData folder. Your plugin should call the ZFU_RegisterLocalizationFile routine when it loads. This registers the English translation file (the path is passed to the routine as an argument) and then automatically checks for the other language files in the same location. They should all have the same file name with the relevant language suffix as described here: http://docs.pixologic.com/user-guide.../localization/

    For the example zscript, you will need to change the language to French before you will see any translations. The interface is changed automatically, although the example only has two buttons that are translated - Rename SubTool and Rename Layer. The Localize Text button and those below it provide a way to test the translation but in practice you will probably only need to retrieve the translation for Note messages such as the one that you get when pressing the Rename SubTool button. If you press the Localize Text button and enter #ZFU_RENAME_SUBTOOL_CONFIRMATION you will get the message text returned. (Be sure to include the hash # at the beginning - this tells ZBrush to search for a message tag rather than text.)

    The ZFU_GetCurrentLanguage routine is for getting the current language. You might need to know this if your plugin loads content that is specific to a language. The routine isn't demonstrated in the example.

    HTH,

  5. #5
    Senior Member Follow User Gallery
    Join Date
    Feb 2015
    Location
    Paris
    Posts
    263

    Default

    Hello Marcus, thank you for the remind me about how the inserted zscript is compiled with the plugin, I wasn't sure, as i come with the source file into the zutilfiles, and I get confused just because of that ^^

    Ok, good to know localizeText routine is mainly for testing purpose, because, it still don't work for me, nothing get translated in my plugin at the moment.
    I finally tested you method with the inserted zscript, and it doesn't change any thing.
    I tested with a new fresh ansi document (xml) just to make sure that when i save the copy provided from the zip, wasn't encoded
    into a a wrong mode, but without any effect, it still just doesn't work. and feel out of solution to bring it to work.

    If will post you informed about my progress

    Nicolas
    Plugins & Toolsets for Zbrush 4R8 : zCycler Pro | Plugin Manager |Matiere 3d | Twitter | @Facelessmindz

  6. #6
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    Nicolas,

    If you want me to look at your script you can send me a private message, if you want.

  7. #7
    Senior Member Follow User Gallery
    Join Date
    Feb 2015
    Location
    Paris
    Posts
    263

    Default

    sorry for being long before to reply, like with the max var def thread , still need to reply correctly
    I can't to share the source code, not that i don't want, but i seems that something ins my code break the
    localization to work. it still don't have any idea what would break it, i try to disable some part of the source code, but it not easy
    with a plugin of almost 20k of line of code, and i use Streamed comments to describes the routine and their functionning, which mean i can't to have streamed comment into streamed comments, and making my life harder to debug the localization.
    I reused the test plugin made for my test on var def limits, and turned it into another test plugin but for another purpose this time.
    The localization is working well with this test plugin, so i can repeat the code in my main plugin, but still doesn't work.
    I first have disables every button item of the UI section of my code, was easier because there is not much stream comments.
    Well it let just three button in my plugin and the localization has failed. i had another try by just disabling subpallet on after another and no luck too.
    I had disabled all startup routines ( creation of the MVarDef list that content the uistates and startup routine), still no luck.

    I will have to duplicate my plugin, and just remove routine after routine until i found what cause this.
    at the moment the only difference i got is that one :



    if check system is not after init routine and the init routine call , i still get the system error, like posted on the first topic.
    That just weird
    Plugins & Toolsets for Zbrush 4R8 : zCycler Pro | Plugin Manager |Matiere 3d | Twitter | @Facelessmindz

  8. #8
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    The CheckSystem routine sets the dllPath variable with the path to the DLL file. That needs to be set first so that all calls to the DLL using [FileExecute] can find the DLL and run. If you call InitZFUtilsTests first then when that routine calls ZFU_RegisterLocalizationFile it will fail.

  9. #9
    Senior Member Follow User Gallery
    Join Date
    Feb 2015
    Location
    Paris
    Posts
    263

    Default

    yes exactly at some point it worked with the correct order, and after reverting the disabling of some code sections, it doesn't work anymore :/
    Plugins & Toolsets for Zbrush 4R8 : zCycler Pro | Plugin Manager |Matiere 3d | Twitter | @Facelessmindz

  10. #10
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    Well, without seeing your code I couldn't begin to say what's going wrong.

  11. #11
    Senior Member Follow User Gallery
    Join Date
    Feb 2015
    Location
    Paris
    Posts
    263

    Default

    but it not easy to share, the toolset is using two plugins data directory,
    the code of that toolset contains more than 230 routinesdef , and even more buttons/sliders and switches, well i don't think you have time for that.
    i gonna try few tweak again and keep you posted, if i just isolated some part of the code to recreate another plugin to share with you it's going to be hard.
    i also a a lot of icon that are scattered from the main ZgametoolsData directory, and the Ztexturerdata directory.
    Yes i gonna keep a shared plugin data, because i just want to keep all toolsets optimal and prevent from loading the common icons two or three time depending of the toolsets installed
    from this common plugindata directory i share the zfileutils lib and dll, curl for licensing, common icons, the common plugin data has a toolset for those who want the connect zbrush to the app of their choice for 2D and 3D editing.
    The ZCore which is a toolset i wanted to remove a week ago, but when i had tried recently to integrate the full licensing process in Ztexturer, i run in issue with the max def variable limitation so i revert my mind.
    i tried from the test plugin to run from the the zfile utils from a different plugin directory, it worked well, so it not a problem to load the dll from zgametoolsdata/zfileutils.dll, or ZtexturerData/zfileutils.dll.
    the

    I can share the header in case you spot anything , i let the checksystem after the initzfileutils

    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // ZFileUtils Globals VARIABLES
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    [VarDef,isMac,0]//do we have a Mac or PC
    [VarDef,Zvers,0]//ZBrush version
    [VarDef,dllPath,""]//plugin DLL path
    [VarDef,dllVersion,0]//plugin DLL version
    [VarDef,err,0]//standard error
    [VarDef,folderName,""]//folder path/name
    [VarDef,fileName,""]//file path/name
    [VarDef,copyFileName, ""]// Name of file to copy to
    [VarSet,index,0] //seems unused
    /* Unused Global Variables :
    [VarDef,fileCount, 0]// Number of files loaded -- unused

    //[VarDef,gSharedPath,""] //path to shared/public MyPluginData folder
    */

    // Get current language
    // @returns the current language index2
    [RoutineDef, ZFU_GetCurrentLanguage,
    [VarSet, lang, [FileExecute, [Var, dllPath], GetCurrentLanguage]]

    , lang]

    // Register localization files for the plugin
    // @enFilePath: path to the english xml localization file, must be formated "[name]en.xml"
    // other languages are deduced as being "[name]fr.xml", "[name]jp.xml", etc...

    [RoutineDef, ZFU_RegisterLocalizationFile,
    [FileExecute, [Var, dllPath], RegisterLocalizationFile, enFilePath]
    , enFilePath]

    [RoutineDef, ZFU_LocalizeText,
    [If, [MemGetSize, ZFU_Mem_Temp],, [MemCreate, ZFU_Mem_Temp, 256]]
    [If, [FileExecute, [Var, dllPath], GetLocalizedText, text,, ZFU_Mem_Temp],,
    [MemReadString, ZFU_Mem_Temp, text]
    ]
    [MemDelete, ZFU_Mem_Temp]
    , text]

    [RoutineDef, ZFU_LocalizeTitle,
    [If, [MemGetSize, ZFU_Mem_Temp],, [MemCreate, ZFU_Mem_Temp, 256]]
    [If, [FileExecute, [Var, dllPath], GetLocalizedTitle, text,, ZFU_Mem_Temp],,
    [MemReadString, ZFU_Mem_Temp, text]
    ]
    [MemDelete, ZFU_Mem_Temp]
    , text]

    [RoutineDef, ZFU_LocalizeInfo,
    [If, [MemGetSize, ZFU_Mem_Temp],, [MemCreate, ZFU_Mem_Temp, 256]]
    [If, [FileExecute, [Var, dllPath], GetLocalizedInfo, text,, ZFU_Mem_Temp],,
    [MemReadString, ZFU_Mem_Temp, text]
    ]
    [MemDelete, ZFU_Mem_Temp]
    , text]

    [RoutineDef, ZFU_LocalizeDescr,
    [If, [MemGetSize, ZFU_Mem_Temp],, [MemCreate, ZFU_Mem_Temp, 256]]
    [If, [FileExecute, [Var, dllPath], GetLocalizedDescr, text,, ZFU_Mem_Temp],,
    [MemReadString, ZFU_Mem_Temp, text]
    ]
    [MemDelete, ZFU_Mem_Temp]
    , text]

    [RoutineDef, ZFU_StrReplaceArg,
    [If, [MemGetSize, ZFU_Mem_Temp],, [MemCreate, ZFU_Mem_Temp, 256]]
    [MemWriteString, ZFU_Mem_Temp, text]
    [If, [FileExecute, [Var, dllPath], StrReplaceArg, argText, argIndex, ZFU_Mem_Temp],,
    [MemReadString, ZFU_Mem_Temp, text]
    ]
    [MemDelete, ZFU_Mem_Temp]
    , text, argIndex, argText]



    [RoutineDef, CheckSystem,
    //check ZBrush version
    [VarSet,Zvers,[ZBrushInfo,0]]
    [If,[Val,Zvers] >= 4.8,,
    [Note,"\Cff9923This zscript\Cffffff is not designed for this version of \Cff9923ZBrush\Cffffff.",,3,4737096,,300]
    [Exit]
    ]
    [VarSet,isMac, [ZBrushInfo,6]] //check Mac or PC
    // Make sure we have the dll and set its path
    [If,[ZBrushInfo,16]==64,//64 bit
    [If,isMac,
    //use the path below for testing only
    //[VarSet,dllPath,"zgametoolsData/ZFileUtils.lib"]
    //use the path below for installed plugins
    //[VarSet,dllPath,"ZBRUSH_ZSTARTUP/ZPlugs64/zgametoolsData/ZFileUtils.lib"]
    [VarSet,dllPath,"ztexturerdata/ZFileUtils.lib"]
    ,
    //use the path below for testing only
    //[VarSet,dllPath,"zgametoolsData\ZFileUtils64.dll"]
    //use the path below for installed plugins
    //[VarSet,dllPath,"ZBRUSH_ZSTARTUP\ZPlugs64\zgametool sData\ZFileUtils64.dll"]
    [VarSet,dllPath,"ztexturerdata\ZFileUtils64.dll"]
    ]
    ,//else 32 bit - no longer supported
    [Note,"\Cff9923This zscript\Cffffff is not designed for this version of \Cff9923ZBrush\Cffffff.",,3,4737096,,300]
    [Exit]
    ]
    [If, [FileExists, [Var,dllPath]],
    //check that correct version
    [VarSet, dllVersion, [FileExecute, [Var,dllPath], Version]]
    [If, [Val,dllVersion] >= 4.8,//dll version
    //OK
    ,//else earlier version
    [Note,"\Cff9923Note :\Cc0c0c0 The \Cff9923 ZFileUtils plugin \CffffffDLL\Cc0c0c0 is an earlier version which does not support this plugin. Please install correct version."]
    [Exit]
    ]
    , // else no DLL.
    [Note,"\Cff9923Note :\Cc0c0c0 The \Cff9923 ZFileUtils plugin \CffffffDLL\Cc0c0c0 could not be found at the correct location. Please re-install the plugin, making sure the relevant files and folders are in the \CffffffZStartup/ZPlugs\Cc0c0c0 folder."]
    [Exit]
    ]
    ]//end routine



    //Routine to Initialize ZFUtilsTests, set up a language file
    [RoutineDef, InitZFUtilsTests,
    // Initialize localization
    [RoutineCall, ZFU_RegisterLocalizationFile, [FileNameResolvePath, "zTexturerData/lang/ztexturer_en.xml"]]
    ]
    [RoutineCall, InitZFUtilsTests]

    [RoutineCall, CheckSystem]
    Plugins & Toolsets for Zbrush 4R8 : zCycler Pro | Plugin Manager |Matiere 3d | Twitter | @Facelessmindz

  12. #12
    Senior Member Follow User Gallery
    Join Date
    Feb 2015
    Location
    Paris
    Posts
    263

    Default

    Fixed
    i got to move routines, and ui from one file to a new one, and finally it work this way.
    I have no idea what was the source of the bug, it s a complete mystery.
    Thx you for helping me Marcus, it always a pleasure to receive the help of your part.

    It gonna be a long road to improve and translate all the tooltips in french there is so much to do
    Plugins & Toolsets for Zbrush 4R8 : zCycler Pro | Plugin Manager |Matiere 3d | Twitter | @Facelessmindz

  13. #13
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    That's great!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •