2 Language related HII Library implementation.
4 Copyright (c) 2006, Intel Corporation<BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "InternalHiiLib.h"
19 Determine what is the current language setting. The space reserved for Lang
20 must be at least RFC_3066_ENTRY_SIZE bytes;
22 If Lang is NULL, then ASSERT.
24 @param Lang Pointer of system language. Lang will always be filled with
25 a valid RFC 3066 language string. If "PlatformLang" is not
26 set in the system, the default language specifed by PcdUefiVariableDefaultPlatformLang
29 @return EFI_SUCCESS If the EFI Variable with "PlatformLang" is set and return in Lang.
30 @return EFI_NOT_FOUND If the EFI Variable with "PlatformLang" is not set, but a valid default language is return in Lang.
35 HiiLibGetCurrentLanguage (
42 ASSERT (Lang
!= NULL
);
45 // Get current language setting
47 Size
= RFC_3066_ENTRY_SIZE
;
48 Status
= gRT
->GetVariable (
50 &gEfiGlobalVariableGuid
,
56 if (EFI_ERROR (Status
)) {
57 AsciiStrCpy (Lang
, (CHAR8
*) PcdGetPtr (PcdUefiVariableDefaultPlatformLang
));
65 Get next language from language code list (with separator ';').
67 If LangCode is NULL, then ASSERT.
68 If Lang is NULL, then ASSERT.
70 @param LangCode On input: point to first language in the list. On
71 output: point to next language in the list, or
72 NULL if no more language in the list.
73 @param Lang The first language in the list.
78 HiiLibGetNextLanguage (
79 IN OUT CHAR8
**LangCode
,
86 ASSERT (LangCode
!= NULL
);
87 ASSERT (Lang
!= NULL
);
90 StringPtr
= *LangCode
;
91 while (StringPtr
[Index
] != 0 && StringPtr
[Index
] != ';') {
95 CopyMem (Lang
, StringPtr
, Index
);
98 if (StringPtr
[Index
] == ';') {
101 *LangCode
= StringPtr
+ Index
;
106 This function returns the list of supported languages, in the format specified
107 in UEFI specification Appendix M.
109 If HiiHandle is not a valid Handle in the default HII database, then ASSERT.
111 @param HiiHandle The HII package list handle.
113 @retval !NULL The supported languages.
114 @retval NULL If Supported Languages can not be retrived.
119 HiiLibGetSupportedLanguages (
120 IN EFI_HII_HANDLE HiiHandle
125 CHAR8
*LanguageString
;
127 ASSERT (IsHiiHandleRegistered (HiiHandle
));
129 // Collect current supported Languages for given HII handle
132 LanguageString
= AllocateZeroPool (BufferSize
);
133 if (LanguageString
== NULL
) {
137 LocateHiiProtocols ();
139 Status
= mHiiStringProt
->GetLanguages (mHiiStringProt
, HiiHandle
, LanguageString
, &BufferSize
);
141 if (Status
== EFI_BUFFER_TOO_SMALL
) {
142 FreePool (LanguageString
);
143 LanguageString
= AllocateZeroPool (BufferSize
);
144 if (LanguageString
== NULL
) {
148 Status
= mHiiStringProt
->GetLanguages (mHiiStringProt
, HiiHandle
, LanguageString
, &BufferSize
);
151 if (EFI_ERROR (Status
)) {
152 LanguageString
= NULL
;
155 return LanguageString
;
160 This function returns the number of supported languages on HiiHandle.
162 If HiiHandle is not a valid Handle in the default HII database, then ASSERT.
163 If not enough resource to complete the operation, then ASSERT.
165 @param HiiHandle The HII package list handle.
167 @return The number of supported languages.
172 HiiLibGetSupportedLanguageNumber (
173 IN EFI_HII_HANDLE HiiHandle
177 CHAR8
*LanguageString
;
179 CHAR8 Lang
[RFC_3066_ENTRY_SIZE
];
181 Languages
= HiiLibGetSupportedLanguages (HiiHandle
);
182 if (Languages
== NULL
) {
187 LanguageString
= Languages
;
188 while (*LanguageString
!= 0) {
189 HiiLibGetNextLanguage (&LanguageString
, Lang
);
192 FreePool (Languages
);
198 This function returns the list of supported 2nd languages, in the format specified
199 in UEFI specification Appendix M.
201 If HiiHandle is not a valid Handle in the default HII database, then ASSERT.
202 If not enough resource to complete the operation, then ASSERT.
204 @param HiiHandle The HII package list handle.
205 @param FirstLanguage Pointer to language name buffer.
207 @return The supported languages.
212 HiiLibGetSupportedSecondaryLanguages (
213 IN EFI_HII_HANDLE HiiHandle
,
214 IN CONST CHAR8
*FirstLanguage
219 CHAR8
*LanguageString
;
221 ASSERT (HiiHandle
!= NULL
);
222 ASSERT (IsHiiHandleRegistered (HiiHandle
));
224 // Collect current supported 2nd Languages for given HII handle
227 LanguageString
= AllocateZeroPool (BufferSize
);
228 if (LanguageString
== NULL
) {
232 LocateHiiProtocols ();
234 Status
= mHiiStringProt
->GetSecondaryLanguages (mHiiStringProt
, HiiHandle
, FirstLanguage
, LanguageString
, &BufferSize
);
236 if (Status
== EFI_BUFFER_TOO_SMALL
) {
237 FreePool (LanguageString
);
238 LanguageString
= AllocateZeroPool (BufferSize
);
239 if (LanguageString
== NULL
) {
243 Status
= mHiiStringProt
->GetSecondaryLanguages (mHiiStringProt
, HiiHandle
, FirstLanguage
, LanguageString
, &BufferSize
);
246 if (EFI_ERROR (Status
)) {
247 LanguageString
= NULL
;
250 return LanguageString
;