How to import an Excel sheet string table into Embedded Wizard

Transcription

How to import an Excel sheet string table into Embedded Wizard
HT-007-Excel String Table Import
Embedded Wizard How-To Document
How to import an Excel sheet string table into Embedded
Wizard
HowTo-No.:
EmWi Version:
Doc. Version:
Date:
Authors:
007
6.10
4.0
17th November 2011
Steffen Hermann,
Rudolf Leberfinger,
Mario Stefanutti,
Manfred Schweyer
Keywords:
Multilingual strings, language variants, string table import, font range
Introduction
Usually Embedded Wizard projects contain more than one user language. Within an
EmWi project the different user languages are represented and identified by different
Language bricks, e.g. “German”, “French” or “Japanese”. During the creation of an
EmWi object, all used resources and constants are evaluated on existing language
variants, in order to realize multilingual content for GUI objects.
Resources and constants can be filled with different values for each language variant. If
the language is switched, the corresponding value of the language variant is loaded. It
should be mentioned that an existing GUI object will not immediately change its
appearance, because the language variants are checked only during the creation of an
object. For those classes who should change their appearance immediately, EmWi
offers the attribute Multilingual. This attribute causes EmWi to generate additional code
to perform an immediate re-initialization for a new user language.
The most common language variant is the string constant. Embedded Wizard expects
the multilingual string constants as part of a certain Embedded Wizard unit (ewu).
During the project development it is quite customary, to collect and store language
variants of the required string (e.g. “Menu” or “Exit”) within an MS Excel sheet for easy
exchange between the developers and the translator’s office.
The following how-to document provides a simple example how to easily transfer a socalled string table, based on an Excel sheet, into an Embedded Wizard unit file.
www.embedded-wizard.de
Copyright TARA Systems GmbH
Page 1
HT-007-Excel String Table Import
String generation
The basic idea of the following example is, to generate a unit file – which is nothing else
than a readable text file with a certain defined syntax – from an Excel sheet, converting
the sheet’s content into EmWi compatible constants thereby.
The directory “projects” of this how-to package contains a small example project, named
“Example.ewp”. Please double-click the ewp-file to load the project in Embedded
Wizard. The project contains 9 different language identifiers and, beside the units of the
class library Mosaic, the units Strings and Example.
Please note, that the provided example project was created by using the Mosaic 1.0
class library. However, all described aspects of language selection and string handling
are also valid for any Mosaic 2.0 based GUI application.
The unit Strings contains 7 string constants with multilingual values, representing the 7
days of the week. Additionally 9 string constants for the supported languages are
present in the table, but only with the value for the Default-language.
The unit Strings – or the file Strings.ewu more precisely – was generated by an Excel
macro. This macro is implemented in Visual Basic Script and stored in the Excel sheet.
You will find the file Strings.xls included in the project directory of this how-to document.
The Excel sheet consists of two pages. The first page is StringTable. It lists in row ‘1’
the language variant identifiers, in column ‘A’ the string IDs and collects all language
variant values for the string IDs. At least the default language must be implemented to
avoid a Chora compiler error. The default name for the generated *.ewu file is always
the name of the Excel file with the extension “ewu” e.g.: Strings.xls becomes
Strings.ewu.
NOTE: Don’t use unit names that can conflict with standard C-libraries (string.h)
because each unit generates a ‘*.c’ and ‘*.h’ module that must be compiled and linked
with your project.
If a string contains the new line characters “\n”, it will cause a new line in a Views::Text
object without displaying the “\n”. If a backslash should be displayed in EmWi, it must be
entered as “\\”.
www.embedded-wizard.de
Copyright TARA Systems GmbH
Page 2
HT-007-Excel String Table Import
Figure 1: The Excel Page ‘StringTable’
In the second page Generator, the user can adapt the value No of Languages (columns
of StringTable) and the value No of Constants (rows of the StringTable). A click on the
Generator button starts the conversion process.
Figure 2 Generator Button for the string generation
The intention of this Excel sheet is to provide a simple example, which can be used as it
is, but also it can easily be copied and/or modified. It is very easy to change e.g. the
formatting of the generated ewu-file or add some functionality. In general this Excel
sheet is not a tool for Embedded Wizard, but a template to make the translation of
strings easier and independent from an Embedded Wizard license. By this way an
external translation office can do the translations totally independent from the
development.
Example Project
The unit Example contains the class Example::Example which is able to display the 7
weekday strings. For demonstration purpose you can navigate with the cursor keys Up /
Down to change the language. The result is displayed immediately on the left side.
www.embedded-wizard.de
Copyright TARA Systems GmbH
Page 3
HT-007-Excel String Table Import
Figure 3 The Example shows the 7 weekday strings in different languages.
Font Range calculation
If you open the Generator page of the Excel sheet Strings.xls, you will see a further
button Generate Font Range.
Figure 4 - Generator Button for the font range generation.
The Excel macro related to this button will convert only the used characters from the
page StringTable. This is very useful to save ROM/Flash resources in case of a big font
range and if only the strings from the string table are used.
In case of dynamically characters, e.g.: from a user input for channel names or an EPG
service (electronic program guide), the font range generation makes only sense if the
range of the dynamic characters is predictable. This range can be specified in the
default range left to the button Generate Font Range. In these cells you can enter a
Default Start and a Default End value in decimal numbers. It defines a fix range of
characters that will be included in the generated font range. If you don’t want to include
a default range, just leave these cells empty.
Another hurdle for the automatic font range generation might be, if you have different
fonts using different font ranges. In this case you have to adapt the Excel macro up to
your requirements or define the different fonts in different copies of the Excel files.
Generating a font range
After a click on the button “Generate Font Range” an Excel macro will calculate the font
range and print the output by default to the text file “FontRange.txt”. The format of this
www.embedded-wizard.de
Copyright TARA Systems GmbH
Page 4
HT-007-Excel String Table Import
file is ready to be included in an EmWi unit file (*.EWU) that contains a font resource.
Another possibility is to copy and paste the range of each language from the text file
into the corresponding language value of the property “Ranges” of the font in the EmWi
Inspector.
Figure 5 – Output of generated font range
Now we want to include the generated font range into our example project:
• Open the file Example.ewu in a text editor.
• Search for <attr fontranges Ranges> in the file Example.ewu.
• Replace the existing font range with the generated font range from
FontRange.txt.
• If the project is already opened, reload the unit in EmWi. To do so, double click
on the warning in Embedded Wizards Log window and confirm the message box
“Do you really want to reload the content of the Unit ‘Example’?” with “Yes”.
• That’s it!
Figure 6 – Integrated font rang in the file ‘Example.ewu’.
www.embedded-wizard.de
Copyright TARA Systems GmbH
Page 5
HT-007-Excel String Table Import
Further Information
For a first start, we recommend to study the Embedded Wizard User Manual including
the “Quick Tour”. The Embedded Wizard User Manual is part of the Embedded Wizard
installation (please see subdirectory \EmbeddedWizard\Doc) and it is available at
http://www.embedded-wizard.de within the section Documentation.
To help you, to get familiar with Embedded Wizard faster, we have created several
tutorials for beginners as well as advanced users including step-by-step example
projects. These tutorials are part of the Embedded Wizard installation (please see
subdirectory \EmbeddedWizard\Tutorial_Mosaic20) and they are also provided at
http://www.embedded-wizard.de as part of the available Documentation.
For specific questions related to your project, please visit the Help & Support page. You
will find a collection of Frequently Asked Questions as well as information to contact our
support team.
www.embedded-wizard.de
Copyright TARA Systems GmbH
Page 6