https://www.proz.com/forum/cat_tools_technical_help/334855-looking_for_ideas_to_translate_a_source_code_file.html&phpv_redirected=1

Looking for ideas to translate a source code file
Thread poster: Shirikka
Shirikka
Shirikka
Local time: 05:20
Spanish to English
+ ...
May 21, 2019

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
Samuel Murray  Identity Verified
Netherlands
Local time: 05:20
Member (2006)
English to Afrikaans
+ ...
@Shirikka May 22, 2019

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
Thomas T. Frost  Identity Verified
Portugal
Local time: 04:20
Danish to English
+ ...
Regex Tagger May 22, 2019

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
VIP9N
Local time: 06:20
Russian to English
+ ...
Use DejaVuX May 22, 2019

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
Shirikka
Local time: 05:20
Spanish to English
+ ...
TOPIC STARTER
Thanks people! May 23, 2019

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


Translation news related to CAT tools





Protemos translation business management system
Create your account in minutes, and start working! 3-month trial for agencies, and free for freelancers!

The system lets you keep client/vendor database, with contacts and rates, manage projects and assign jobs to vendors, issue invoices, track payments, store and manage project files, generate business reports on turnover profit per client/manager etc.

More info »
CafeTran Espresso
You've never met a CAT tool this clever!

Translate faster & easier, using a sophisticated CAT tool built by a translator / developer. Accept jobs from clients who use Trados, MemoQ, Wordfast & major CAT tools. Download and start using CafeTran Espresso -- for free

Buy now! »