From b7e89ce653fe3677aea7779f65ad126827c94c97 Mon Sep 17 00:00:00 2001 From: Bandie Date: Fri, 21 Sep 2018 22:50:38 +0200 Subject: [PATCH] gettext: pam_panic_pw --- src/pam_panic_pw/pam_panic_pw.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/pam_panic_pw/pam_panic_pw.c b/src/pam_panic_pw/pam_panic_pw.c index 6f54cda..3d2e8eb 100644 --- a/src/pam_panic_pw/pam_panic_pw.c +++ b/src/pam_panic_pw/pam_panic_pw.c @@ -17,13 +17,15 @@ LICENSE : GNU-GPLv3 #include #include #include "config.h" +#include "../../lib/gettext.h" +#define _(String) gettext(String) int writePasswords(char pw[][99]){ FILE *f = fopen(PPASSFILE, "w"); if(f == NULL){ - fprintf(stderr, "ERROR opening file!\n"); + fprintf(stderr, _("ERROR opening file!\n")); return 2; } @@ -39,6 +41,12 @@ int writePasswords(char pw[][99]){ int main(void){ + // gettext + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + + // init time_t t; srand((unsigned) time(&t)); unsigned long seed[2]; @@ -52,12 +60,17 @@ int main(void){ char pw[2][99]; char pwv[2][99]; - char *prompt[4] = {"Key password: ", "Panic password: ", "Retype key password: ","Retype panic password: "}; + char *prompt[4] = { + _("Key password: "), + _("Panic password: "), + _("Retype key password: "), + _("Retype panic password: ") + }; int i; if(getuid() != 0){ - printf("Please run this program under root. Write access to %s is mandatory.\n", PPASSFILE); return 1; + printf(_("Please run this program under root. Write access to %s is mandatory.\n"), PPASSFILE); return 1; } for(int j=0; j<2; j++){ @@ -80,10 +93,10 @@ int main(void){ int ok = strcmp(pw[j], pwv[j]) == 0; if(!ok){ if(k==2){ - printf("Didn't work. Bye.\n"); + printf(_("Didn't work. Bye.\n")); return 1; }else - printf("Password didn't match. Try again.\n"); + printf(_("Password didn't match. Try again.\n")); }else break; } @@ -94,3 +107,4 @@ int main(void){ return writePasswords(pw); } +