Another program for translators

Started by Foren, November 21, 2021, 02:11:24 AM

Previous topic - Next topic

Foren

Rimworld Assistant Translator.

My English is terrible, I write as best I can.

Description:


1. "Current Directory".
The folder from where the program was launched. I don't know why I left it.
2. "Find "TODO"".
How many TODOs are found in subfolders of Current Directory. Subfolders of subfolders are ignored.
3. "Max symbols in file for translate".
Not all programs/sites can translate large files. The character limits are different. Enter as much as you need.
4. "Scan DIR for TODO".
Looks at all *.xml files (in all subfolders of the Current Directory) and counts how many times a TODO was found. If something is found, the file RAT_Find_TODO_in.txt is created, where it is written where and how many TODOs were found.
5. "Create file(s) for translate".
It also scans *.xml files for the presence of a TODO, but does not just read them, copies the English text for this TODO to the RAT_ToTranslate_*.txt file.
6. "Add RAT_ToTranslate_*.txt to *.xml".
Inserts text from RAT_ToTranslate_*.txt into *.xml files after TODO.

Not quite clear? Here's an example.
Let's say there is such a file(rimworld/AbilityDef/1.xml):
<?xml version="1.0" encoding="UTF-8"?>
<LanguageData>
 
  <!-- EN: elite -->
  <RoleElite.label>TODO</RoleElite.label>
 
  <!-- EN: supreme -->
  <RoleSupreme.label>translated: supreme</RoleSupreme.label>
 
    <!-- EN: editing memes -->
  <EditingMemes.label>TODO</EditingMemes.label>
  <!-- EN: You can edit memes by clicking on them. -->
  <EditingMemes.helpText>translated: You can edit memes by clicking on them.</EditingMemes.helpText>

  <!-- EN:
    <li>place_personalWeapon->assault rifle</li>
    <li>place_massWeapon->an archotech mass-inverter</li>
    <li>seismicDevice->a seismic quake-generation device</li>
    <li>anEMPAttack->an EMP strike to the life support systems</li>
  -->
  <PlaceMakerCommon.rulePack.rulesStrings>TODO</PlaceMakerCommon.rulePack.rulesStrings>
 
    <!-- EN: editing precepts -->
  <EditingPrecepts.label>TODO</EditingPrecepts.label>
  <!-- EN: You can edit precepts by clicking on them. -->
  <EditingPrecepts.helpText>TODO</EditingPrecepts.helpText>
 
</LanguageData>

After clicking on "Scan DIR for TODO", the file RAT_Find_TODO_in.txt will be created. With content:
AbilityDef\1.xml: 5 TODO
After clicking on "Create file (s) for translate" the file RAT_ToTranslate_0.txt will be created. With content:
0: elite
1: editing memes
2:     <li>place_personalWeapon->assault rifle</li>
2:     <li>place_massWeapon->an archotech mass-inverter</li>
2:     <li>seismicDevice->a seismic quake-generation device</li>
2:     <li>anEMPAttack->an EMP strike to the life support systems</li>
3: editing precepts
4: You can edit precepts by clicking on them.

Please note that the English text is copied only before the TODO. For example, the text with the line "translated: supreme" was not added.
Let's say "translated the text". RAT_ToTranslate_0.txt is now like this:
0: translated: elite
1: translated: editing memes
2:     <li>translated: place_personalWeapon->assault rifle</li>
2:     <li>translated: place_massWeapon->an archotech mass-inverter</li>
2:     <li>translated: seismicDevice->a seismic quake-generation device</li>
2:     <li>translated: anEMPAttack->an EMP strike to the life support systems</li>
3: translated: editing precepts
4: translated: You can edit precepts by clicking on them.

After clicking on "Add RAT_ToTranslate _*.txt to * .xml" all text in 1.xml will change to:
<?xml version="1.0" encoding="UTF-8"?>
<LanguageData>
 
  <!-- EN: elite -->
  <RoleElite.label>TODO.translated: elite </RoleElite.label>
 
  <!-- EN: supreme -->
  <RoleSupreme.label>translated: supreme</RoleSupreme.label>
 
    <!-- EN: editing memes -->
  <EditingMemes.label>TODO.translated: editing memes </EditingMemes.label>
  <!-- EN: You can edit memes by clicking on them. -->
  <EditingMemes.helpText>translated: You can edit memes by clicking on them.</EditingMemes.helpText>

  <!-- EN:
    <li>place_personalWeapon->assault rifle</li>
    <li>place_massWeapon->an archotech mass-inverter</li>
    <li>seismicDevice->a seismic quake-generation device</li>
    <li>anEMPAttack->an EMP strike to the life support systems</li>
  -->
  <PlaceMakerCommon.rulePack.rulesStrings>TODO
    <li>translated: place_personalWeapon->assault rifle</li>
    <li>translated: place_massWeapon->an archotech mass-inverter</li>
    <li>translated: seismicDevice->a seismic quake-generation device</li>
    <li>translated: anEMPAttack->an EMP strike to the life support systems</li>
</PlaceMakerCommon.rulePack.rulesStrings>
 
    <!-- EN: editing precepts -->
  <EditingPrecepts.label>TODO.translated: editing precepts </EditingPrecepts.label>
  <!-- EN: You can edit precepts by clicking on them. -->
  <EditingPrecepts.helpText>TODO.translated: You can edit precepts by clicking on them. </EditingPrecepts.helpText>
 
</LanguageData>

Yes, TODOs are not deleted, this is done to make it easier to search for text in xml. What happens if you add it again? Another copy of the translation will be added to the TODO, 4 times clicked: <RoleElite.label>TODO.translated: elite .translated: elite .translated: elite .translated: elite </RoleElite.label>. Nothing critical, but it's best not to do this.

And something else:
1. Make backups! Better yet, in a separate folder ... and don't forget to copy it too. After clicking on the buttons, there are dialogs, but you can accidentally lose the entire translation if you create new files for translation.
2. Save files with translation in UTF-8! A standard text editor saves in ANSI, when adding text to xml with such an encoding, some text will be in the form of incomprehensible characters.
3. It is better not to change the numbering in RAT_ToTranslate_*.txt, otherwise the translated strings will be inserted in the wrong place. Also don't remove/add TODO from xml, this will change the order of the lines too.
4. I have not tested all languages, only 2. How the program will work with your language is unknown.
5. The program searches for text using the current xml template: <! - EN:, ->, <li>, </li>, TODO. If this changes, it is unlikely that something will be found.
6. The program was tested and created(Lazarus 2.0.12) on WIN7. It is unknown if this will work on your systems. I will also add that I created the program to fit my needs and have already translated the last 1314 TODOs. Yes, machine translation, but better than none. I spread it here because it may be useful to someone.
7. Perhaps there is an easier way to do all this, but I did not find it. The few programs that I found on this forum either do not work or crash after launch.

Download: https://drive.google.com/file/d/1HMWKiCJFYgtHLlZwdqXW2xfoVHHSsMUq/view?usp=sharing

P.S. <hide> tag where are you?