Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Displaying code in multiple languages

Status
Not open for further replies.

rawbus

Member level 1
Joined
Jun 18, 2010
Messages
33
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,641
I've never had to do this before and I'm having troubles finding some good references on this topic. What I have is an embedded system with a GUI that is displayed in English. What I want to do is allow for the user to go into settings and pick their language of choice from a list and then have the GUI update accordingly, like most electronics today allow.

I'd appreciate any help you can offer.

EDIT: I'm using a TFT RGB565 color display and the Keil RealMDK development suite, if that makes a difference.
 

The messages are probably of varying lengths in all languages.

You probably hope you don't have to waste a lot of bytes.

You want a flexible system that will permit revising any message in any language. And you probably don't want to recalculate new lookup tables after each revision.

This method assumes that you assign an ID number to each message. And an ID number to each language.

This method assumes your machine is fast enough that there will be no perceptible delay as searches through memory.

Messages can be stored in any order, any mix of languages.

Each message begins with a '00' null byte. Then two identification bytes.

The first ID byte is the language ID number (example, '01' for English, '02' for French, etc.). You can have up to 255 languages.

The second ID byte is your message ID number. You can have up to 255 messages. If you have more messages then you'll need to use two bytes which will allow 65,535 messages.

Then for instance to display message #5 in language #3, you'll start searching through memory for the first occurence of any byte containing '00'.

Then peek the next byte of memory. If it doesn't contain '03', it isn't in language #3. Resume searching for the next null byte.

When you find a '03', peek the following byte to see if it contains '05'. Etc.

When you find '05' start reading bytes, building the message. Continue until you find a byte containing '00'. Display the message.

If speed bogs down with this method, then you'll have to create shortcuts in the form of (a) lookup tables, (b) putting all messages with the same ID number in a contiguous block of memory, or (c) using a contiguous block of memory for all messages in the same language, etc.
 
  • Like
Reactions: rawbus

    rawbus

    Points: 2
    Helpful Answer Positive Rating
I have an SD card hooked up through SPI, which is like 1 GB. I figured I could store text files, one per a language, that has all the text blocks per a line, in the SD card. This is as far as I got.

I was thinking then, I would have the text blocks mapped to specific locations in memory. Each text block would be given space equal to the longest message out of all the languages so there are no size issues. This could waste a lot of space potentially, but I have roughly 8 MBytes of RAM and I'm currently only using roughly 40% of it, so it's not a big deal. Upon selecting the language, a routine would populate this memory location with the text blocks from the correct language text file. This seems like it should work and is similar to what you suggested.

I'm not sure about the most efficient way to do this. I was thinking mapping the text blocks to positions in a double char array. So, if the first message was Main Menu. Then, the text Main Menu would be copied from the english.txt line 0 and would be put into the double char array starting at [0][0]. The next message would then be in the next row and so forth.

Is there a better terminology I should be using when trying to find resources about this topic? Using the terms "multiple languages" and "code" in the same search string is giving me headaches.
 

Sounds like you're in business. By using a fixed length for all messages, you can calculate where to extract message #5 simply by multiplying 5 times the fixed message length.

That way you save cpu cycles. My method is time consuming.

It's still a good idea to attach a unique identifier code to each message.

You'll have adequate space to lengthen any message. However will it be easy for you to add and subtract messages?

Will any change cause you to have to (a) perform one or more sorts, or (b) relocate one or more blocks of memory, or (c) recalculate lookup tables?

Will it be easy for you to add an additional language?

Can you make changes without the risk of messages getting out of sync across the language database?

These are major considerations, since you'll probably continue revising your program.

---------- Post added at 14:14 ---------- Previous post was at 14:04 ----------

=================

As for what terminology...

With PC machines a program often has a lot of DLL files in its install folder.

With the Macintosh OS you create Resources.

Possible search terms:

"language dll"

"language resource"

"select language"

"choose language"

"install language"

"language database"
 
  • Like
Reactions: rawbus

    rawbus

    Points: 2
    Helpful Answer Positive Rating
Yea, I can add an identifier, shouldn't be too bad. As far as adding and subtracting messages, I do not plan on letting it be run-time configurable. It should be all set up before hand and all that happens at run-time is the mapping of the messages in the selected language to the message array.

Well this looks like a good start, thanks for the help.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top