Groups | Search | Server Info | Login | Register
Groups > comp.arch.embedded > #32331
| From | pozz <pozzugno@gmail.com> |
|---|---|
| Newsgroups | comp.arch.embedded |
| Subject | How to add the second (or other) languages |
| Date | 2025-02-12 17:26 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <voii3i$28jmm$1@dont-email.me> (permalink) |
I have an embedded project that runs on a platform without a fully OS
(bare metal). The application can interact with humans with italian
messages. These messages are displayed on a touch screen, sent in the
payload of SMS or push notifications.
I used a very stupid approach: sprintf() with hard-coded constant
strings. For example:
void
display_event(Event *ev)
{
if (ev->type == EVENT_TYPE_ON) {
display_printf("Evento %d: accensione", ev->idx);
} else ...
...
}
Now I want to add a new language.
I could create a new build that replaces the constant strings at
preprocessor time:
#if LANGUAGE_ITALIAN
# define STRING123 "Evento %d: accensione"
#elif LANGUAGE_ENGLISH
# define STRING123 "Event %d: power up"
#endif
void
display_event(Event *ev)
{
if (ev->type == EVENT_TYPE_ON) {
display_printf(STRING123, ev->idx);
} else ...
...
}
This way I can save some space in memory, but I will have two completely
different production binary for the two languages.
Another approach is giving the user the possibility to change the
language at runtime, maybe with an option on the display. In some cases,
I have enough memory to store all the strings in all languages.
I know there are many possible solutions, but I'd like to know some
suggestions from you. For example, it could be nice if there was some
tool that automatically extracts all the strings used in the source code
and helps managing more languages.
Back to comp.arch.embedded | Previous | Next — Next in thread | Find similar
How to add the second (or other) languages pozz <pozzugno@gmail.com> - 2025-02-12 17:26 +0100
Re: How to add the second (or other) languages Stefan Reuther <stefan.news@arcor.de> - 2025-02-12 18:14 +0100
Re: How to add the second (or other) languages David Brown <david.brown@hesbynett.no> - 2025-02-12 20:50 +0100
Re: How to add the second (or other) languages pozz <pozzugno@gmail.com> - 2025-02-16 19:59 +0100
Re: How to add the second (or other) languages David Brown <david.brown@hesbynett.no> - 2025-02-17 09:51 +0100
Re: How to add the second (or other) languages pozz <pozzugno@gmail.com> - 2025-02-17 16:05 +0100
Re: How to add the second (or other) languages David Brown <david.brown@hesbynett.no> - 2025-02-17 19:09 +0100
Re: How to add the second (or other) languages pozz <pozzugno@gmail.com> - 2025-02-16 22:56 +0100
Re: How to add the second (or other) languages David Brown <david.brown@hesbynett.no> - 2025-02-17 09:57 +0100
Re: How to add the second (or other) languages pozz <pozzugno@gmail.com> - 2025-02-16 23:15 +0100
Re: How to add the second (or other) languages David Brown <david.brown@hesbynett.no> - 2025-02-17 09:59 +0100
Re: How to add the second (or other) languages Stefan Reuther <stefan.news@arcor.de> - 2025-02-17 19:00 +0100
Re: How to add the second (or other) languages "Niocláiſín Cóilín de Ġloſtéir" <Master_Fontaine_is_dishonest@Strand_in_London.Gov.UK> - 2025-02-13 22:51 +0100
csiph-web