setup: Migrate to autotool and use gettext.

This commit is contained in:
Michael Tremer
2014-08-12 12:19:10 +02:00
parent 56774f9ed2
commit e1457ba014
23 changed files with 1474 additions and 253 deletions

View File

@@ -8,36 +8,22 @@
*
*/
// Translation
#include <libintl.h>
#define _(x) dgettext("setup", x)
#include "setup.h"
FILE *flog = NULL;
char *mylog;
char **ctr = NULL;
int automode = 0;
struct nic nics[20] = { { "" , "" , "" , "" } };
struct knic knics[20] = { { "" , "" , "" , "" } };
extern char *en_tr[];
extern char *de_tr[];
extern char *fr_tr[];
extern char *es_tr[];
extern char *pl_tr[];
extern char *ru_tr[];
extern char *nl_tr[];
extern char *tr_tr[];
int main(int argc, char *argv[])
{
#ifdef LANG_EN_ONLY
char *shortlangnames[] = { "en", NULL };
char **langtrs[] = { en_tr, NULL };
#else
char *shortlangnames[] = { "de", "en", "fr", "es", "nl", "pl", "ru", "tr", NULL };
char **langtrs[] = { de_tr, en_tr, fr_tr, es_tr, nl_tr, pl_tr, ru_tr, tr_tr, NULL };
#endif
int choice;
char *sections[11]; /* need to fill this out AFTER knowning lang */
int rc;
@@ -67,6 +53,7 @@ int main(int argc, char *argv[])
if (!setlocale(LC_CTYPE,""))
fprintf(flog, "Locale not spezified. Check LANG, LC_CTYPE, RC_ALL.");
#if 0
kv = initkeyvalues();
if (!(readkeyvalues(kv, CONFIG_ROOT "/main/settings")))
{
@@ -95,15 +82,16 @@ int main(int argc, char *argv[])
goto EXIT;
ctr = langtrs[choice];
}
#endif
sections[0] = ctr[TR_KEYBOARD_MAPPING];
sections[1] = ctr[TR_TIMEZONE];
sections[2] = ctr[TR_HOSTNAME];
sections[3] = ctr[TR_DOMAINNAME];
sections[4] = ctr[TR_NETWORKING];
sections[5] = ctr[TR_ISDN];
sections[6] = ctr[TR_ROOT_PASSWORD];
sections[7] = ctr[TR_ADMIN_PASSWORD];
sections[0] = _("Keyboard mapping");
sections[1] = _("Timezone");
sections[2] = _("Hostname");
sections[3] = _("Domain name");
sections[4] = _("Networking");
sections[5] = _("ISDN");
sections[6] = _("'root' password");
sections[7] = _("'admin' password");
sections[8] = NULL;
newtInit();
@@ -119,16 +107,16 @@ int main(int argc, char *argv[])
sprintf (title, "%s %s - %s", NAME, VERSION, SLOGAN);
}
newtDrawRootText(14, 0, title);
newtPushHelpLine(ctr[TR_HELPLINE]);
newtPushHelpLine(_(" <Tab>/<Alt-Tab> between elements | <Space> selects"));
if (automode == 0)
{
choice = 0;
for (;;)
{
rc = newtWinMenu(ctr[TR_SECTION_MENU],
ctr[TR_SELECT_THE_ITEM], 50, 5, 5, 11,
sections, &choice, ctr[TR_OK], ctr[TR_QUIT], NULL);
rc = newtWinMenu(_("Section menu"),
_("Select the item you wish to configure."), 50, 5, 5, 11,
sections, &choice, _("OK"), _("Quit"), NULL);
if (rc == 2)
break;
@@ -196,15 +184,17 @@ int main(int argc, char *argv[])
autook = 1;
}
EXIT:
EXIT:
if (automode != 0)
{
sprintf (title, "%s %s - %s", NAME, VERSION, SLOGAN);
if (autook)
newtWinMessage(title, ctr[TR_OK], ctr[TR_SETUP_FINISHED]);
else
{
newtWinMessage(ctr[TR_WARNING], ctr[TR_OK], ctr[TR_SETUP_NOT_COMPLETE]);
newtWinMessage(title, _("OK"), _("Setup is complete."));
else {
newtWinMessage(_("Warning"), _("OK"),
_("Initial setup was not entirely complete. "
"You must ensure that Setup is properly finished by running "
"setup again at the shell."));
fprintf(flog, "Setup program has not finished.\n");
fflush(flog);