joshbduncan / AiCommandPalette

Adobe Illustrator Command Palette
https://joshbduncan.com/software.html
MIT License
37 stars 4 forks source link

Unicode char in menu #12

Closed krasnovpro closed 1 year ago

krasnovpro commented 1 year ago

image image

joshbduncan commented 1 year ago

Nice catch. I'll get that fixed soon. Thanks for the heads up!

creold commented 1 year ago

I see an extra slash "Effect > Sketch > Cont\\u00E9 Crayon..." -> "Effect > Sketch > Cont\u00E9 Crayon..." 👍

joshbduncan commented 1 year ago

✅ Fixed faf9bb3

creold commented 1 year ago

@joshbduncan, you replaced the English caption in the German and Russian version 🤭

Your Python script inserts an extra slash before the Unicode character. You need to replace the "é" with unicode, but so that there is no extra slash when building the script. Unicode must have one slash.

RU Effect > Sketch > Cont\u00E9 Crayon... Эффект > Эскиз > Волшебный карандаш… DE Effect > Sketch > Cont\u00E9 Crayon... "Effekt > Zeichenfilter > Cont\u00E9-Stifte …"

https://user-images.githubusercontent.com/32217031/190963100-29a732e2-b023-4ff6-81dd-cbcfdaa3356d.mp4

joshbduncan commented 1 year ago

I just did a search and replace on everything since I was in a hurry. I'll get this fixed today,

I think the Python script is escaping the Unicode string and causing the issue. I'm actually rewriting the whole script to utilize the ExtendScript localize() function so there will only be one .jsx file that includes all translations and Ai will use the appropriate text for the system language.

I'm close to being done with it so I would love if you could test it out for me on your system. I can temporarily change the language on my system but I don't have the correct Russian letters so it looks weird.

creold commented 1 year ago

Yes. I use in my scripts localization through variables in a single file. It's a good idea to test it.

Unfortunately, there is an inexplicable problem with Russian in localized scripts, where JS comments break the Cyrillic encoding in the ScriptUI dialog. There is no solution and I have to simply delete the comments in the code until the dialog window displays the correct encoding.

joshbduncan commented 1 year ago

Ok, I think it's right now as Cont\u00E9 Crayon. That sucks about the localization. When I get it done, we'll see if it works on your machine or not. Thanks!

joshbduncan commented 1 year ago

@creold, I made this test dialog script (GitHub Gist) utilizing the localization() function. It seems to be working on my system even with comments in the file. To test, I've been changing the $.local variable to either "de" or "ru". Can you give it a test and let me know if it works for you? Thanks!

creold commented 1 year ago

@joshbduncan Oh, creating a temporary Github Gist is even easier 👍 I checked on Mac and Windows all three localizations. So far everything is displaying correctly.

For the Russian localization only need to change the caption Cancel button: Cancel > Отмена.

I also translated the caption for the new "Corner Widget" command:

loc: { 
  en: "View > Show / Hide Corner Widget", 
  de: "Ansicht > Ecken-Widget einblenden / ausblenden", 
  ru: "Просмотр > Показать / скрыть виджет углов" },
},

I'll wait for the next version to test.

joshbduncan commented 1 year ago

Awesome. I'll be in touch when I've got everything completed. Thanks again for your help!

joshbduncan commented 1 year ago

@creold, I've been working hard to figure out the best way to have all localization happen in one file using the ExtendScript localize() function. After two failed attempts, I started over and completely rewrote the entire script from the ground up.

Now, I've got a much cleaner script that builds all menus (in localized form) at run-time with basically the same performance as before.

I also changed how the project is laid out as you'll see in my latest pr #13 so there is a binary 'AiCommandPalette.jsx' in the base of the folder that combines everything into one file. If you want to dig around the actual code, everything is inside the 'src' folder.

I still have a few things to clean up and need to add some docstrings but everything seems to be working on my end.

Please give it a try when you have time and let me know what you think...

P.S. I removed some strings and modified a few so I'll need you and Kurt to check the translations.

Cheers 🍻🍻

creold commented 1 year ago

Oh no, @joshbduncan , you forgot the function simulateKeypress(k, n) 🤪 When I run it on Windows, I get the error "simulateKeypress is not a function".

Why build "AiCommandPalette.jsx" as a binary? I know it removes comments and minifies code. But does it give a performance boost or just reduces the file size? What would happen if all the libraries in the build were embedded in the original JS in "AiCommandPalette.jsx"?

joshbduncan commented 1 year ago

Haha. I cleaned it up too ouch I guess 🤦‍♂️.

The only reason I am compiling it to binary is so that all of the code gets dumped into one big file. There are so many lines of code it is hard to keep up with where everything is when I had it all in one file before. Obviously I could copy everything by hand into a single file every time I upload but I'm certain I would miss something. I'm just trying to make it as easy as possible to work on going forward. If you know a better way please let me know.

And, I'll let you know when I have it updated with the fixes.

Thanks!

joshbduncan commented 1 year ago

@creold, the missing functions were added back in. 👍

creold commented 1 year ago

@joshbduncan dataFolder is undefined. var f = setupFileObject(dataFolder, "SimulateKeypress.vbs"); I think that in the simulateKeypress() function you should copy from config.jsxinc

var settingsFolderName = "JBD";
var folder = setupFolderObject(Folder.userData + "/" + settingsFolderName);

About the binary file "AiCommandPalette.jsx". So you have it automatically built from libraries? I thought you manually copy it to the final file and convert it to jsxbin

joshbduncan commented 1 year ago

@creold, so I fixed the settings folder part. And yes, when I use the "Export as Binary" menu option on the base script file that imports everything it combines all of those imports into one file. I have attached a video showing how it works.

Export as Binary video

creold commented 1 year ago

@joshbduncan now it runs on Windows without errors. Checked the localization in the English and Russian interface of Adobe Illustrator.

joshbduncan commented 1 year ago

Thanks! Also, I'm going to try and write a little bash script that will compile everything into a single jsx file kind-of like the export to binary option does, except it won't be a binary file so it's human readable.

joshbduncan commented 1 year ago

@creold, so I figured out a way to read through the base script, extract the //@include statement file paths, and compile everything into a single human readable (non-binary) .jsx file. Funny thing is, it's actually smaller than the .jsxbin file 🤷‍♂️ exported by VSCode.

I never really liked the jsxbin binary file since people couldn't see what they were running so I definitely prefer this method.

All seems to work fine on my machine.

Let me know what you think? Thanks!

creold commented 1 year ago

@joshbduncan fu**g Adobe. Bug of corrupted RU locale encoding appeared. To fix it, I had to move var locStrings to the top of the code. I am attaching the JSX file.

Screenshot 2022-09-26 at 09 46 15

AiCommandPalette-fixed-locale-bug.zip

I don't like JSXBIN either. But I use it in paid scripts, for protection. But it's better to use JS obfuscation and then encode to JSXBIN.

Can you share a way to compile everything into one file? I have a script with libraries that I wanted to be automatically merged.

joshbduncan commented 1 year ago

@creold, great catch! I just had to move the include statement for the 'data.jsxbin' to the top of the includes and everything seems to work just fine for all languages now. Can you please check on your end too with the latest push to PR #13.

And, since you asked about the compile script, I tried to build it out today to better match the include specs of the ExtendScript engine. You can find it in the tools folder of the latest PR and I also created a new git repo for it.

Now, I'm not great at bash scripting but it seems to work pretty well from my testing.

The new repo includes a sample JSX project folder with different types of include statements so you can get a feel for how it works. There are more details in the README.md in the new repo. Try it out and let me know if you have any feedback. Thanks!

creold commented 1 year ago

@joshbduncan I checked the fix in PR13. Yes, now the encoding of RU localization is correct.

joshbduncan commented 1 year ago

@creold, I simplified the workflow needs attention warning so instead of trying to hack together what you have already translated, I was wondering if you could translate this new string as is for me. Thanks!

"Workflow needs attention.\nThe following action steps from your workflow are are no longer available.\n\nDeleted Actions:\n%1\n\nIncompatible Actions:\n%2"

creold commented 1 year ago

@joshbduncan, you have two repeats "are are no longer". =)

Translation: 1) "Набор требует внимания\nУказанные шаги в вашем наборе команд больше недоступны.\n\nУдаленные команды:\n%1\n\nНесовместимые команды:\n%2"

2) "Shaper Tool" - "Инструмент: Произвольная кривая"

And how come that in the RU locale of tool names instead of Инструмент: <ru_name> (CSV table) became <ru_name> Инструмент =) The word "Инструмент" (Tool) with a whitespace at the end of the name line.

joshbduncan commented 1 year ago

Hmmm, I was doing some weird things with Google Sheets and Regex to build a new spreadsheet to track all of the commands. I may have messed something up. I will go back and compare to see what went wrong and get those fixed.

Thanks for the translation and catching the extra "are"!

joshbduncan commented 1 year ago

Ok, I got them back correctly like they were before. I'll get this merged in as soon as I get the same translation from Kurt. Thanks again!