I expect this issue doesn't have any great solution, but I'm hoping for some tips and tricks. I often have to deliver manufacturing drawings from SW in several different languages (English and Polish). This means that drawing title blocks, component custom properties, sheet metal/weldment descriptions, hole callouts, Toolbox components, and everything else has to be fully translated.
It is very well possible to translate everything, but problem is maintaining it. For example, if I translate a Sheet Format, I have to save it as a separate, non-parametric copy. Meaning that now if I have to maintain two files; if I change anything in one, I have to repeat the change in another. Specific project file custom properties can be filled in desired language, no problem, but if I use Weldments, I can't use my profiles as they are, since their properties (Cut-List Properties) have to be translated as well, which essentially means duplicating the library and translating those properties. Or, having to have duplicate properties (for example DescriptionEN and DescriptionPL) in every file.
Same with hole wizard, sheet metal callouts, etc. Nearly every translation has to be saved as a new file, which doubles the maintenance work if I need to change something.
I really wish I could avoid having to work in two languages, but it's out of my control. Any tips to make this easier, to solve these issues without having to keep duplicate files for everything, or at least somehow connect them parametrically so that I can make changes in one without having to manually update the other?
Another idea I've been entertaining, is to keep everything in SW in one language (EN), and then translate drawing PDFs after exporting them. Either automatically or manually (find-replace for every word) would be fine. But so far, I haven't been able to find a translator app/online service/editing app that would allow me to do this while preserving custom fonts, positions, allow to manually fix mistakes, etc. Maybe someone found something that is compatible with PDFs exported from SW?
Maintaining projects in multiple languages
Re: Maintaining projects in multiple languages
Okay, so while waiting for a reply, I tested my PDF translation idea. Tried a dozen PDF editors, found that only LibreOffice Draw has Replace All functionality and API to use it. So I threw together a macro to do the translations, attaching it to this post if anyone needs it.
How to use it:
1. Export drawing PDF from SW.
2. Open it up in LibreOffice.
3. Create a text file to hold translations. It should look like this:
...etc. Basically separate translations with "=", and end the line with "\". Don't add "\" to the last line. I know this is weird, but I couldn't find a better alternative to ADODB.Stream to import UTF-8 text files, and it just refuses to acknowledge new line characters, so I needed some symbol to make text parsing easier. You can of course modify the macro and swap it out for some other symbol.
4. Save this dictionary txt file somewhere. VERY IMPORTANT: the path name must contain no spaces. Again this is for that ADODB.Stream, for whatever reason it hates spaces and I can't find how to fix it. So for example "D:\SOLIDWORKS\PDF translation\EN PL dictionary.txt" is no good, you need to replace spaces with underscore or something, like "D:\SOLIDWORKS\PDF_translation\EN_PL_dictionary.txt".
5. Create a new macro in LO, and paste the code from the text file I attached. Modify the DICTPATH global variable at the top to the path where you saved your dictionary txt file.
6. Run the macro (F5) from the Main sub. It should translate your PDF, using Replace All function. If something is not translated, edit the dictionary and add missing translations. You can re-run the macro straight away.
7. You will still need to adjust the text box positions manually, since some of them may be thrown off.
Note: add long translations at the beginning of the dictionary file, and short ones to the end. This is to avoid a scenario where Replace All would, for example, replace the word "BOX", and later fail to replace "BOUNDING BOX" because "BOX" is already replaced.
Note 2: unfortunately during exporting to PDF, SW breaks down multi-line notes into separate text fields. Meaning that anything that doesn't fit into one line, won't be caught by Replace All function. So either define your translations by splitting them in the dictionary file as well, or try to avoid multi-line notes in SW drawings.
Pro tip: since preparing that dictionary file with all that special formatting ("=" and "\") at first might be a hassle, ask ChatGPT to make rough translations with proper formatting for you, that will save a lot of time. Use the following prompt:
Feels weird to be posting a LO macro in SW forum... But I hope this helps someone. It's a dirty trick, but I think this is still way less work than having to create and maintain multi-language production environment in SW.
P.S. Pictures of a sample test, before and after:
Took about 10 mins to set up dictionary and translations (multi-line stuff took the longest), instant translation, and then about 1 minute to move stuff back into positions. So, not an ideal solution, but it's something.
How to use it:
1. Export drawing PDF from SW.
2. Open it up in LibreOffice.
3. Create a text file to hold translations. It should look like this:
Code: Select all
BOM=ZW\
PART NO.=N. CZĘŚCI\
MATERIAL=TWORZYWO\
SHEET=ARKUSZ
4. Save this dictionary txt file somewhere. VERY IMPORTANT: the path name must contain no spaces. Again this is for that ADODB.Stream, for whatever reason it hates spaces and I can't find how to fix it. So for example "D:\SOLIDWORKS\PDF translation\EN PL dictionary.txt" is no good, you need to replace spaces with underscore or something, like "D:\SOLIDWORKS\PDF_translation\EN_PL_dictionary.txt".
5. Create a new macro in LO, and paste the code from the text file I attached. Modify the DICTPATH global variable at the top to the path where you saved your dictionary txt file.
6. Run the macro (F5) from the Main sub. It should translate your PDF, using Replace All function. If something is not translated, edit the dictionary and add missing translations. You can re-run the macro straight away.
7. You will still need to adjust the text box positions manually, since some of them may be thrown off.
Note: add long translations at the beginning of the dictionary file, and short ones to the end. This is to avoid a scenario where Replace All would, for example, replace the word "BOX", and later fail to replace "BOUNDING BOX" because "BOX" is already replaced.
Note 2: unfortunately during exporting to PDF, SW breaks down multi-line notes into separate text fields. Meaning that anything that doesn't fit into one line, won't be caught by Replace All function. So either define your translations by splitting them in the dictionary file as well, or try to avoid multi-line notes in SW drawings.
Pro tip: since preparing that dictionary file with all that special formatting ("=" and "\") at first might be a hassle, ask ChatGPT to make rough translations with proper formatting for you, that will save a lot of time. Use the following prompt:
Nice thing is that this dictionary will be reusable for further drawings, so the more PDFs you translate, the more it will fill up, and the less work it will be each time.Hey ChatGPT. I need to you to make translations of the following bits of text from English to Polish. If any of them are unclear or ambiguous, remember that they are from an engineering drawing.
NOTES
TOLERANCES
Sample drawing. Not for production use
0.5 mm., unless specified otherwise
MATERIAL
See BOM
BOUNDING BOX
Format your translations with "=" sign between translated words. Add "\" symbol at the end of every line. For example:
NOTES=NOTATKI\
TOLERANCES=TOLERANCJE\
...etc.
Maintain uppercase/lowercase logic. When translating abbreviations, abbreviate translation result as well.
Feels weird to be posting a LO macro in SW forum... But I hope this helps someone. It's a dirty trick, but I think this is still way less work than having to create and maintain multi-language production environment in SW.
P.S. Pictures of a sample test, before and after:
Took about 10 mins to set up dictionary and translations (multi-line stuff took the longest), instant translation, and then about 1 minute to move stuff back into positions. So, not an ideal solution, but it's something.
- Attachments
-
- Translate PDF macro.txt
- (1.81 KiB) Downloaded 68 times
Re: Maintaining projects in multiple languages
Unrelated question... I've noticed on many of my posts people downloading my attached files like crazy (like, this one already has 28 downloads), but not a single reply, so I'm just wondering, do we have some bots here that keep downloading everything? Or is it real users that hoard every macro just in case? Just curious
Re: Maintaining projects in multiple languages
It's the actual people/user downloading the macro. And since it is a weekend, may be we did not bothered to reply.
And glad to know that you have found a solution, I was thinking to link to a Chinese to English macro for ideas
https://forum.solidworks.com/thread/240672
And glad to know that you have found a solution, I was thinking to link to a Chinese to English macro for ideas
https://forum.solidworks.com/thread/240672
Deepak Gupta
SOLIDWORKS Consultant/Blogger
SOLIDWORKS Consultant/Blogger
Re: Maintaining projects in multiple languages
I'm not complaining, I was just suspicious about the downloads, because I didn't think that many people could potentially find this useful
Great link! While it's a bit different from what I need, it is still useful, I often have to deal with non-English parts downloaded from GrabCad.
As for my solution, well, it's far from ideal, so I still hope someone will suggest something better
-
- Posts: 321
- Joined: Thu Mar 11, 2021 8:38 am
- x 48
- x 390
Re: Maintaining projects in multiple languages
For things like Title Blocks and annotations you could make life easier in your drawing by using layers; have one for the English version, one for the Polish version, then show/hide as appropriate.
BOM tables could be achieved by having the component description in both languages as two different fields in the part, then have the English BOM use the English description column, and the Polish BOM use the Polish description column.
Should be possible to have everything contained in one SW file, but then run a macro to show/hide the relevant layer/s to switch language.
BOM tables could be achieved by having the component description in both languages as two different fields in the part, then have the English BOM use the English description column, and the Polish BOM use the Polish description column.
Should be possible to have everything contained in one SW file, but then run a macro to show/hide the relevant layer/s to switch language.