Looking for ideas to translate a source code file
Thread poster: Shirikka

Shirikka
Local time: 23:06
Spanish to English
+ ...
May 21

Hi people!

I was wondering if there's any way to import the fields of text from a source code file (.h) into some software to allow me to translate it faster. I have a 10.000 lines document which looks like this:

// RESOURCEID=ID_TXT_MENUPKT200
_T("STATISTICS"),
// RESOURCEID=ID_TXT_MENUPKT300
_T("DISPLAY"),
// RESOURCEID=ID_TXT_MENUPKT400
_T("REPORT"),
// RESOURCEID=ID_TXT_MENUPKT500
_T("PRODUCT TYPE"),
// RESOURCEID
... See more
Hi people!

I was wondering if there's any way to import the fields of text from a source code file (.h) into some software to allow me to translate it faster. I have a 10.000 lines document which looks like this:

// RESOURCEID=ID_TXT_MENUPKT200
_T("STATISTICS"),
// RESOURCEID=ID_TXT_MENUPKT300
_T("DISPLAY"),
// RESOURCEID=ID_TXT_MENUPKT400
_T("REPORT"),
// RESOURCEID=ID_TXT_MENUPKT500
_T("PRODUCT TYPE"),
// RESOURCEID=ID_TXT_MENUPKT600
_T("PARAMETERS"),
// RESOURCEID=ID_TXT_MENUPKT700
_T("SERVICE"),

from which I only have to translate the text between "". It would be so much easier if I could copy-paste all of this into a tool such as Deepl or even Google translate and then proofread the result, instead of overwritting the text piece by piece. Maybe it could also help to export the text between "" in Excel, from which in which I can easily copy-paste and translate, but the problem would be re-importing it on the source-code file...

Also, some fields have a limited lenght, which means that sometimes I have to write shorcuts etc.

Any ideas of a software who could help me translate source code easier?

thank you!
Collapse


 

Samuel Murray  Identity Verified
Netherlands
Local time: 23:06
Member (2006)
English to Afrikaans
+ ...
@Shirikka May 22

Shirikka wrote:
// RESOURCEID=ID_TXT_MENUPKT200
_T("STATISTICS"),


How sure are you that the translatable text is *always* preceded by _T(" and *always* followed by "),? Does it always use double quotes, or does it sometimes use single quotes? Does it always have no space between the closing bracket and the comma, or is there sometimes a space or a tab between the closing bracket and the comma? It is my experience that programmers typically write neatly, but sometimes write sloppily in ways that are still acceptable for the compiler but which is not consistent from a human reader perspective (such as using single quotes instead of double quotes in some places, if the compiler doesn't care about single vs double quoting).


Any ideas of a software who could help me translate source code easier?


Well, one thing you can try, is this:

0. Open in a text editor (make sure it opens in the correct text file encoding)
1. Replace all tabs with something temporary, e.g. {{TAB}}
2. Find this: _T("
Replace with this: _T(" plus a TAB
3. Find this: "),
Replace with this: a TAB plus "),
4. Copy all text, and paste it into Excel
5. The translatable text should now be in column B. Insert an extra column next to column B. Copy column B to a text editor, translate it in Google Translate, etc, etc, but make sure that you don't remove any empty lines in the process.
6. Paste the translation back into Excel, in the newly inserted column C. This should put the source and translation side by side, so that you can check the translation.
7. When you're done, delete column B.
8. Copy everything back into a text file. Delete all TABs (i.e. replace TABs with nothing). Replace any {{TAB}} with real tabs again. Save as a .h file. Hope for the best.

[Edited at 2019-05-22 07:35 GMT]


Shirikka
 

Thomas T. Frost  Identity Verified
Member (2014)
Danish to English
+ ...
Regex Tagger May 22

If you use a CAT tool, you may be able to use Samuel's method directly in a Regex Tagger in the CAT tool. That's what I would do in MemoQ, which would insert tags in the source to represent the strings not to be touched. When it exports the translation, it replaces the tags with the original strings.

Shirikka
 

VIP9N
Local time: 00:06
Russian to English
+ ...
Use DejaVuX May 22

Hi, Shirikka

Now, for the 3-rd time

I tried your task in DejaVuX. Firstly, I copied the text that you had provided into a txt file. Then, I changed its extension into .h
In DejaVuX project the filter showed "C, C++, Java". I ticked "Prevent segmentation". When it imported the file, in the translation grid I saw only these 6 words:
STATISTICS
DISPLAY
REPORT
PRODUCT TYPE... See more
Hi, Shirikka

Now, for the 3-rd time

I tried your task in DejaVuX. Firstly, I copied the text that you had provided into a txt file. Then, I changed its extension into .h
In DejaVuX project the filter showed "C, C++, Java". I ticked "Prevent segmentation". When it imported the file, in the translation grid I saw only these 6 words:
STATISTICS
DISPLAY
REPORT
PRODUCT TYPE
PARAMETERS
SERVICE

I didn't go further, but I'm 99% sure that DejaVuX would export the original file. So, no hustle with copy-paste is required.

Good luck.
Collapse


Shirikka
 

Shirikka
Local time: 23:06
Spanish to English
+ ...
TOPIC STARTER
Thanks people! May 23

thanks for your imput! I finally could put everything in Excel, and i also found a software called Poedit who allows you to translate source code, (but only in the Pro version)

However, to copy all in a excel file, i had to download some code reader such as ATOM or Visual Basic.

To find all the text I typed: \_T\(\s*['"](.+)['"]\s*\)
then, "find all"
then copy into a new tab,
then replace all for "$1"
and then I could paste it to Excel.
<
... See more
thanks for your imput! I finally could put everything in Excel, and i also found a software called Poedit who allows you to translate source code, (but only in the Pro version)

However, to copy all in a excel file, i had to download some code reader such as ATOM or Visual Basic.

To find all the text I typed: \_T\(\s*['"](.+)['"]\s*\)
then, "find all"
then copy into a new tab,
then replace all for "$1"
and then I could paste it to Excel.

The drawback of Excel was that I can't add lines that would be re-imported on the source code, since every line is preceded by "_T("blablabla\n") , so my idea is just valid for basic softwares where you only have a line and limited space.

It looks like that I will have to learn a bit of code to be a proper translator.
Thanks again!
Collapse


 


To report site rules violations or get help, contact a site moderator:


You can also contact site staff by submitting a support request »

Looking for ideas to translate a source code file

Advanced search







Wordfast Pro
Translation Memory Software for Any Platform

Exclusive discount for ProZ.com users! Save over 13% when purchasing Wordfast Pro through ProZ.com. Wordfast is the world's #1 provider of platform-independent Translation Memory software. Consistently ranked the most user-friendly and highest value

More info »
Déjà Vu X3
Try it, Love it

Find out why Déjà Vu is today the most flexible, customizable and user-friendly tool on the market. See the brand new features in action: *Completely redesigned user interface *Live Preview *Inline spell checking *Inline

More info »



Forums
  • All of ProZ.com
  • Term search
  • Jobs
  • Forums
  • Multiple search