Second example: extract text for translation
Want a Microsoft Excel file that contains all the texts in your prototype to, say, be able to send it to a translator? In this tutorial, we’re going to build an example to do exactly that. We will extract all the texts from labels, buttons, links and so on from a prototype and create a MS Excel file with all that information.
- First, create a plugin project like the one you did in the first example. Name it ‘Translator’ and create a main class inside the src folder.
Place this code inside the main method:
Select that class, then right click on it and choose the ‘run as java application’ option. You will be requested to select a .vp file and where do you want to save the .csv file with all the texts in the selected prototype. How is this code doing that?
The first piece of code loads the information of a .vp file in the IPrototype class. Then there’s another piece of code that browse the elements of each screen, template or master. When it finds a text, it adds it to a String which will be used to create the resulting .csv file.
As you can see, it’s easy to read the information of a .vp file. You could even generate your own HTML code if you wanted to!