Application for creating JUCE translation files


#1

Hey All.
I couldn’t seem to find any kind of tool or application that can automatically create a Juce translation file, based on your source code, for use with the LocalisedStrings class, so I made one myself! Its a very simple application, but I found it very useful so I thought I’d share it incase it could be useful for anyone else.

Its a very simple GUI app that searches through a directory or a single file for instances of the TRANS("") macro or translate("") function, extracts the String within the quotes that needs translating, and adds them to a correctly formatted LocalisedStrings translation file all ready to have translations added. It also allows Strings to be added to existing translation files without adding duplicates of strings already within the file.

However it only works for quoted text wrapped with the translate macro or function, not variables - not sure of the best way to handle this. Any suggestions? Maybe if any TRANS() or translate() instances with non-quoted text are found, it makes a note of the file and line number so you can manually add the String to the translation file afterwards.

Below is a link to the GitHub repo for the project which currently only has an Xcode build and an OS X binary of the application. I’m sure the more advanced programmers of you will find many flaws and inefficiencies in the code, but if it could be useful please take it and do as you will! Any feedback would be appreciated though.

Juce translation file generator - https://github.com/liamlacey/JUCE-Translation-File-Generator


#2

:slight_smile:


#3

Just updated this project/application and put it into a GitHub repository.
A link to the repo has been added to my original post.
Will add a VS 2010 build and a Windows binary soon.


#4

[quote=“millenliam”]Just updated this project/application and put it into a GitHub repository.
A link to the repo has been added to my original post.
Will add a VS 2010 build and a Windows binary soon.[/quote]

Add this to your signature!


#5

Thanks a lot for this tool! :slight_smile: I downloaded it and created a Visual Studio 2010 export without any major problems. The AppComponent .cpp and .h files were missing in the Introjucer project, and “dontSendChangeNotification” was undefined (I didn’t quite understand how that can work with GCC either…). I changed the latter to “false” and it compiled fine.

Jules, it would be great with an extension of the translation classes with some kind of optional context or variation ID. Sometimes the same word or sentence might need to be translated differently within the same application. Apart from that JUCE is truly a joy to work with… :slight_smile:


#6

This has been asked before, but there’s no need to change anything to do it. The string that goes inside TRANS() can be anything you want, so you can use whatever special symbol or number you want in there, it doesn’t have to be an english string.


#7

OK, thanks, see your point, Jules. I’ll skip the TRANS macros, and use the translate methods with fallback translations in those cases. That seems a bit tidier to me than having a language file for the original language.