Hedgewars LUA Translation Tool

6 replies [Last post]
KoBeWi
KoBeWi's picture
User offline. Last seen 8 hours 22 min ago. Offline
Joined: 2010-12-25
Posts: 508

Heh. I randomly decided to finally catch up with translating HW 0.9.24 and while doing LUA translation again, I thought: "hey, it could be easier". So I made this tool. It's not yet finished, but since it happened so suddenly, I won't probably be finishing it now (unless I randomly decide so XD), so I'm just showing current progress (it's usable tho).

The main idea is that each line in LUA translation file has a comment that gives a clue where it comes from. So I used to group them and also added some indicators which group has untranslated strings and how many of them is left. There's even a button that jumps to next untranslated string and a button that automatically copies the original text for you. It's bothersome to do this in text editor, so my tool aims to make it as efficient as possible. Here's how it looks right now:

The tool is right now in beta state. If no one finds a bug in a month, I will consider it stable :v

Here's download:
Windows Version
Linux Version
Source Code (MIT license)

Shortcut list for easy navigation:
[ALT] + [Left] - previous line
[ALT] + [Right] - next line
[ALT] + [Down] - next untranslated line
[CTRL] + [E] - fetch original text
[CTRL] + [S] - save changes to current line
[CTRL] + [SHIFT] + [S] - save translation file

Oh, right. The app is made using Godot game engine. It's so cool that I recently switched to it as my game making tool and now I even started using it for applications. I'm thinking about remaking my theme editor for the second time XD

UltiMaxKom
UltiMaxKom's picture
User offline. Last seen 1 year 6 weeks ago. Offline
Joined: 2016-06-26
Posts: 363

KoBeWi allegedly wrote:

... I'm thinking about remaking my theme editor for the second time XD

I'm leaking fourth wall 4 dish (what an abomination, sorry, I'll get out now xD)

( 'ಠ_ಠ)▄︻̷̿┻̿═━一 ̿̿ ̿̿ ̿̿ ̿'̿'\̵͇̿̿\з= ( ▀ ͜͞ʖ▀) =ε/̵͇̿̿/’̿’̿ ̿ ̿̿ ̿̿ ̿̿ ᕙ(⇀‸↼‶ )ᕗ

KoBeWi
KoBeWi's picture
User offline. Last seen 8 hours 22 min ago. Offline
Joined: 2010-12-25
Posts: 508

OMFG, I just added keyboard shortcuts and translating is now infinitely easier D: I updated the source (not builds, because I'm lazy) with them added and you can now use the tool and it's actually helpful. But I focused on efficiency, not usability, so it's still rough until I finish it properly.

The new shortcuts are:
[ALT] + [Left] - previous line
[ALT] + [Right] - next line
[ALT] + [Down] - next untranslated line
[CTRL] + [E] - fetch original text
[CTRL] + [S] - save changes to current line
[CTRL] + [SHIFT] + [S] - save translation file

I also fixed a bug, where saving current line multiple times would count as continuous progress.

Wuzzy
Wuzzy's picture
User offline. Last seen 9 hours 46 min ago. Offline
Joined: 2012-06-20
Posts: 1113

Woah, nice.

But the real solution is when we switch to Gettext (at least for the Lua stuff), its the superior format anyway. So I consider this a temporary solution. It's still better than nothing.
We use several obscure file formats for our translations, this really should change.

When your program is more or less stable, I think it could be added into the Hedgewars repository.

Hi, I am a Hedgewars developer. Smile I accept personal donations in bitcoin. Heart 17fsUywHxeMHKG41UFfu34F1rAxZcrVoqH

KoBeWi
KoBeWi's picture
User offline. Last seen 8 hours 22 min ago. Offline
Joined: 2010-12-25
Posts: 508

Wuzzy allegedly wrote:
But the real solution is when we switch to Gettext (at least for the Lua stuff), its the superior format anyway. So I consider this a temporary solution.
Huh, suddenly I felt less motivated to finish it Sad Smiley

Wuzzy allegedly wrote:
When your program is more or less stable, I think it could be added into the Hedgewars repository.
I glued some code together in few hours and it got more official support than my theme editor in months, nice XD

btw, it's actually quite stable right now, because I was able to translate 200+ lines without any problem. Though it needs some cleanup.

Wuzzy
Wuzzy's picture
User offline. Last seen 9 hours 46 min ago. Offline
Joined: 2012-06-20
Posts: 1113

Just a word of warning, Uploadfiles.io tells me your files are going to “expire” after 3 weeks. Sad Smiley

Hi, I am a Hedgewars developer. Smile I accept personal donations in bitcoin. Heart 17fsUywHxeMHKG41UFfu34F1rAxZcrVoqH

KoBeWi
KoBeWi's picture
User offline. Last seen 8 hours 22 min ago. Offline
Joined: 2010-12-25
Posts: 508

Wuzzy allegedly wrote:

Just a word of warning, Uploadfiles.io tells me your files are going to “expire” after 3 weeks. :-(
Heh, but at least it's not MediaFire, and they are honest too Wink Smiley

I know they keep files for only a month, I was planning to update the tool before it expires.

EDIT: (ha! the bump feature is useful, as I don't need to make another post)

Translation tool has been UPDATED. Rough changelog:

-there's a file open dialog available when you run the tool
-tool remembers last edited file and directory
-the file you load will be briefly validated
-there's a (disablable, is that even a word?) warning when you change line and move to another one, but don't save changes
-ah, since there's this warning now, the tool will ofc detect if you changed anything in line
-red icons on group list now disappear when all texts in group are translated (not sure how it interacts with multiple groups at once)
-some texting changes
-if you can't save file, there's an error popup instead of crash (not that it changes anything, as you can't change name mid-editing (oops...))
-there's a visual warning if you have unsaved file-wide changes
-organized project files
-finally didn't forget to put LICENSE file

There's one problem though. de.lua seems to have different indentation from other translation files. It won't load into the tool, because the tool expects a strict formatting (lack of regex support + laziness).

Anyways, as said in updated first post, this is a beta release. If no one finds any bug, it could be considered stable (it's like rc, but without previous testing) and I will upload it to Mediafire for permanentity.

EDIT:
Translation tool got an update.
-fixed a bug where total progress was incorrect
-text field font is slightly bigger
-Windows release now has an executable icon
-upgraded used Godot version to the newest master branch, which brings some UI improvements like you can now undo fetching the English text or there's better support for unicode text navigation

EDIT:
HOTFIX!
There was a bug where LUA files could be saved with improperly escaped quotations. Now LTT will automatically detect and unescape them on load and escape them on save.

btw, this is one of more weird lines I had to write:

Source code allegedly wrote:
line.translated.replace("\"", "\\\"")

Copyright © 2004-2017 Hedgewars Project. All rights reserved. [ contact ]