From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by mx.groups.io with SMTP id smtpd.web09.17732.1635591678603906568 for ; Sat, 30 Oct 2021 04:01:19 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=CtFJIKu7; spf=pass (domain: gmail.com, ip: 209.85.167.44, mailfrom: aladyshev22@gmail.com) Received: by mail-lf1-f44.google.com with SMTP id bi35so26202097lfb.9 for ; Sat, 30 Oct 2021 04:01:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=crfL0ob6iZHrn7QK2X5cI+HFxyRaGBI+p6QTNfsSUnQ=; b=CtFJIKu7xyQNGiAPeB5Dr2ncqwZ2v5y5rL/1m1qu+1LLcFmjFRXIGO+qvoairyiHOB 1gDBGWQfme1g4DjVubxhCg+cAmqkdwNuLWizoER0Vu9aX1FntVJ1mwrrTfpRttz1n8cL ZklD5jLCKLy+UhY+E5igKA0XkEEDCy4SVaJdcZQ/Fb1HQMJSdrk/mlDsR9/YEJTcsqJi bAGWcYWdiY/lMiJGQ76TGl4vesY7MqdUYclsi2YCJlgpJFr0vbmhfHuUSulTRwgrlGKl wFkD5MLrwkEb8mlLrXv1fIKsG4Rrv8nbfDEFAH6kOGG9K9aC8Xp17LzU19dMOs6IVcps BbqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=crfL0ob6iZHrn7QK2X5cI+HFxyRaGBI+p6QTNfsSUnQ=; b=a++ZF6Xor/oU0qdQ3Hij/QaQqPgU3e+Pny6SSuBghOiYzhkzlVZs09hnXFUSVE8Ndp A8R9evHLW2uZdKJ0ORuXECsEfpV4nnEBUTUgcW0eAuEWCbJhiaKanJtxD7GIHeSviNWr wknsBlmpmfEauO/FV55MSm0Ve6kUs9mFeZouBb08wS1RJOB6k0/3JgsU7V2mPZnGWgHD MNezfgDwPjnwevtj7V4fc1fM1AGgPyoW++4gV+W0KNkYcQa0E/hB7oM6o0xy6nzT5JWf p0rmjKn9Os5Z2MDMW1IzXAfHLIbfcytiCc8/rsgbbjZdb2uaEVh1Sb5laE/+HCMrXlLv 0aXw== X-Gm-Message-State: AOAM532KyUFLDg2yq7bhCGvY9YT44LWE+hmNqIPN+82y19P7aIB3dT2W o7kLOMDEJLEqCiLYjfNgk/SXl/Zim0UVZzLRk8YrslewScs= X-Google-Smtp-Source: ABdhPJyWZespAwvnqftpOIZWW29caL63P0zS7uhwSmKBwOFqDPlaZK/XiETV90jSvZs1W8NHMN4taqMAD5ki7vf+9Vc= X-Received: by 2002:ac2:5d4b:: with SMTP id w11mr15656121lfd.676.1635591674844; Sat, 30 Oct 2021 04:01:14 -0700 (PDT) MIME-Version: 1.0 From: "Konstantin Aladyshev" Date: Sat, 30 Oct 2021 14:01:03 +0300 Message-ID: Subject: Ways to add a string package of different language at runtime To: devel@edk2.groups.io Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 =3D {0xD9DCC5DF, 0x4007, 0x435E, {0x90, 0x98, 0x89, 0x70, 0x93, 0x55, 0x04, 0xb2 }}; EFI_HII_HANDLE* Handle =3D HiiGetHiiHandles(&PackageGuid); CHAR16* FrenchStrings[] =3D { L"Configuration de la OVMF plateforme", L"Modifier divers param=C3=A8tres de la plateforme OVMF", L"Param=C3=A8tres OVMF", L"R=C3=A9solution pr=C3=A9f=C3=A9r=C3=A9e au prochain d=C3=A9marrage", ... L"2560x1600", }; for (UINTN i=3D0; i<(sizeof(FrenchStrings)/sizeof(FrenchStrings[0])); i++= ) { EFI_STRING_ID StringId; if (i=3D=3D0) { Status =3D gHiiString->NewString(gHiiString, *Handle, &StringId, "fr-FR", L"French", L"", NULL); Print(L"Added ID=3D%d, Status =3D %r\n", StringId, Status); } StringId =3D i+2; Status =3D gHiiString->SetString(gHiiString, *Handle, StringId, "fr-FR", FrenchStrings[i], NULL); Print(L"Added ID=3D%d, Status =3D %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=3D41, 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