Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add some debugging regarding language of user messages #2984

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/ui/strings.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

#include "libopensc/internal.h"
#include "libopensc/log.h"
#include "ui/strings.h"
#include <locale.h>
#include <stdlib.h>
Expand Down Expand Up @@ -163,14 +164,22 @@ const char *ui_get_str(struct sc_context *ctx, struct sc_atr *atr,
LANGID langid = GetUserDefaultUILanguage();
if ((langid & LANG_GERMAN) == LANG_GERMAN) {
lang = DE;
sc_log(ctx, "Using the system's language for user messages (German).");
}
#else
const char *language = getenv("LANGUAGE");
/* LANGUAGE supersedes locale */
if (!find_lang_str(getenv("LANGUAGE"), &lang)) {
if (!find_lang_str(language, &lang)) {
/* XXX Should we use LC_MESSAGES instead? */
find_lang_str(setlocale(LC_ALL, ""), &lang);
language = setlocale(LC_ALL, "");
if (find_lang_str(language, &lang))
sc_log(ctx, "Using the system's native environment locale for user messages (%s).", language);
} else {
sc_log(ctx, "Using the system's LANGUAGE for user messages (%s).", language);
}
#endif
} else {
sc_log(ctx, "Using the token's preferred language for user messages (%s).", p15card->tokeninfo->preferred_language);
}

/* load default strings */
Expand Down
Loading