]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - src/setup/main.c
captive: Reindent code for better readability
[ipfire-2.x.git] / src / setup / main.c
index d6531bdf083414f021f76d3e10e4d9257c0705c8..33f4d214201b5798e17034883f88122b4ed8742c 100644 (file)
@@ -8,41 +8,27 @@
  *
  */
 
+// 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;
        struct keyvalue *kv;
-       char selectedshortlang[STRING_SIZE] = "en";
+       char lang[STRING_SIZE] = "en_US.utf8";
        char title[STRING_SIZE];
        int langcounter;
        int autook = 0;
@@ -73,37 +59,19 @@ int main(int argc, char *argv[])
                printf("%s is not properly installed.\n", NAME);
                return 1;
        }
-       findkey(kv, "LANGUAGE", selectedshortlang);
-
-       for (langcounter = 0; langtrs[langcounter]; langcounter++)
-       {
-               if (strcmp(selectedshortlang, shortlangnames[langcounter]) == 0)
-               {
-                       ctr = langtrs[langcounter];
-                       break;
-               }
-       }
-
-       if (!ctr)
-       {
-               for (choice = 0; shortlangnames[choice]; choice++)
-               {
-                       if (strcmp(shortlangnames[choice], "en") == 0)
-                               break;
-               }
-               if (!shortlangnames[choice])
-                       goto EXIT;
-               ctr = langtrs[choice];
-       }
-
-       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];
+       findkey(kv, "LANGUAGE", lang);
+
+       setlocale(LC_ALL, lang);
+       setenv("LANGUAGE", lang, 1);
+
+       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();
@@ -116,19 +84,19 @@ int main(int argc, char *argv[])
                title[strlen(title) - 1] = '\0';
            fclose (f_title);
        } else {
-           sprintf (title, "%s %s - %s", NAME, VERSION, SLOGAN);
+           sprintf (title, "%s - %s", NAME, 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 +164,17 @@ int main(int argc, char *argv[])
                autook = 1;
        }
 
-EXIT:  
+EXIT:
        if (automode != 0)
        {
-               sprintf (title, "%s %s - %s", NAME, VERSION, SLOGAN);
+               sprintf (title, "%s - %s", NAME, 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);