4 Replies Latest reply on Mar 26, 2012 4:22 AM by MSSDedalus

    How to localize Photoshop layer names


      I'm trying to get the default layer names for background, group, etc used by Photoshop depending on users local language.


      As I haven't found a direct way I decided to use javascript instead:


      I have a jsx code like

      function GetBackground()


      var message = localize( "$$$/LayerName/Background=Background");

      return message;



      and in the extension I use

      var result:SyncRequestResult = CSXSInterface.instance.evalScript("GetBackground");



      but result value is undefined.


      Any help would be appreciated.

        • 1. Re: How to localize Photoshop layer names
          emerasoft.srl Level 1

          Hello MSSDedalus,


          the returned result from the called extend is in form of a object; so you should add this code to the extendscript (just a example):


          var xml = '<object>';

          var xml = xml += '<property id="strMessage"><string>'+message+'</string></property>';

          var xml = xml += '</object>';


          and then return the xml variable instead of the message one.


          Then, you should have to modify the actionscript code as well:


          var result:SyncRequestResult = CSXSInterface.instance.evalScript("GetBackground");

          var oResult:Object;

              if((SyncRequestResult.COMPLETE == result.status) && result.data)


               oResult = result.data as Object;

               //Make sure oResult has the property you are expecting



                  var localizedString:String = oResult.strMessage;




          This can be found on the official documentation too.




          • 2. Re: How to localize Photoshop layer names
            MSSDedalus Level 1

            Thanks so much, Luca


            I believe I have to look more carefully at the samples, had tried almost anything except the correct way.

            • 3. Re: How to localize Photoshop layer names
              Harbs. Level 6

              Have you tried this? (no separate jsx required)


              var message:String = HostObject.getRoot(HostObject.extensions[0]).localize( "$$$/LayerName/Background=Background");
              1 person found this helpful
              • 4. Re: How to localize Photoshop layer names
                MSSDedalus Level 1

                Just tried and works fine, thanks.


                May be even better for my purpose as I don't need to add jsx.