From: "Konstantin Aladyshev" <aladyshev22@gmail.com>
To: devel@edk2.groups.io
Subject: Ways to add a string package of different language at runtime
Date: Sat, 30 Oct 2021 14:01:03 +0300 [thread overview]
Message-ID: <CACSj6VUCmGff7Ncv6_BbEW6bhdYLis8y5F2AcO1kU0d-MEvx4w@mail.gmail.com> (raw)
Hello!
I was investigating the possibility of adding localization strings at
runtime. I've noticed that
https://github.com/tianocore/edk2/blob/master/OvmfPkg/PlatformDxe/Platform.uni
has strings only for the `en-US` language. So I've decided to use it
as an example, and create an application that would add translations
for some other supported system language (in this case `fr-FR`):
```
EFI_STATUS
EFIAPI
UefiMain (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_GUID PackageGuid = {0xD9DCC5DF, 0x4007, 0x435E, {0x90, 0x98,
0x89, 0x70, 0x93, 0x55, 0x04, 0xb2 }};
EFI_HII_HANDLE* Handle = HiiGetHiiHandles(&PackageGuid);
CHAR16* FrenchStrings[] = {
L"Configuration de la OVMF plateforme",
L"Modifier divers paramètres de la plateforme OVMF",
L"Paramètres OVMF",
L"Résolution préférée au prochain démarrage",
...
L"2560x1600",
};
for (UINTN i=0; i<(sizeof(FrenchStrings)/sizeof(FrenchStrings[0])); i++) {
EFI_STRING_ID StringId;
if (i==0) {
Status = gHiiString->NewString(gHiiString, *Handle, &StringId,
"fr-FR", L"French", L"", NULL);
Print(L"Added ID=%d, Status = %r\n", StringId, Status);
}
StringId = i+2;
Status = gHiiString->SetString(gHiiString, *Handle, StringId,
"fr-FR", FrenchStrings[i], NULL);
Print(L"Added ID=%d, Status = %r\n", StringId, Status);
}
return EFI_SUCCESS;
}
```
This works well, but I'm a little concerned about the approach that
I've used to initially create the 'fr-FR' string package. Here I've
used:
```
gHiiString->NewString(gHiiString, *Handle, &StringId, "fr-FR",
L"French", L"", NULL);
```
Initially the `en-US` string package has 40 strings, so this code
would create a 'fr-FR' string package with one string of ID=41, which
has a "" value. Because of this hack in the end the 'en-US' package
would have 40 strings and the 'fr-FR' package would have 41 strings.
This is really not a problem of any kind, but maybe there is a library
function to create a string package of a different language?
Best regards,
Konstantin Aladyshev
reply other threads:[~2021-10-30 11:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CACSj6VUCmGff7Ncv6_BbEW6bhdYLis8y5F2AcO1kU0d-MEvx4w@mail.gmail.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox