home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * $Id: inst_language.ycp,v 1.17.4.4 2000/03/22 16:43:01 kkaempf Exp $
- *
- * Module: inst_language.ycp
- *
- * Author: Klaus KΣmpf
- * Michael Hager
- * Stefan Hundhammer
- *
- * Purpose: Let the user choose the language.
- *
- * user_settings:
- *
- * rw: "language" the language for the installation and
- * for target machine
- *
- * "rw" read/write
- * "wr" write only
- *
- * Reads:
- * language.ycp: a map with all supported languages
- *
- */
- {
- map lang2yast1 =
- $[
- "en_GB" : "english",
- "en_US" : "english",
- "en" : "english",
- "de_DE" : "german",
- "de_CH" : "german",
- "de" : "german",
- "br_FR" : "french",
- "fr_FR" : "french",
- "fr_CH" : "french",
- "it_IT" : "italian",
- "es_ES" : "spanish",
- "nl_NL" : "dutch",
- "pt_PT" : "portuguese",
- "pt_BR" : "brazilian",
- "hu_HU" : "hungarian",
- "pl_PL" : "polish",
- "el_GR" : "greek",
- "ru" : "russian",
- "ru_RU" : "russian",
- "ru_RU.KOI8-R" : "russian",
- "cs_CZ" : "czech"
- ];
-
- define SetConsoleFont(map consolefonts, string language) ``{
- list | void consolefont = lookup(consolefonts, language);
- if (consolefont== nil && size(language) > 2)
- consolefont = lookup(consolefonts, substring(language, 0, 2));
- if (consolefont != nil)
- {
- string console_font = select(consolefont, 0);
- string unicode_map = select(consolefont, 1);
- string screen_map = select(consolefont, 2);
- string console_magic = select(consolefont, 3);
-
- user_settings = add(user_settings, "console_font", console_font);
- user_settings = add(user_settings, "console_unicodemap", unicode_map);
- user_settings = add(user_settings, "console_screenmap", screen_map);
- user_settings = add(user_settings, "console_magic", console_magic);
-
- UI(`SetConsoleFont (console_magic, console_font, screen_map, unicode_map));
- }
- };
-
- // Build the contents of the dialog.
-
- /* ----------------------------------------------------------------------
- * Language
- * ----------------------------------------------------------------------*/
- map languages = ReadY2("language.ycp");
-
- // build up language selection box
- // with the default selection according to user_settings
-
- string language = UI(`GetLanguage());
- if (language == "") language = "en";
- language = lookup(user_settings, "language", language);
-
- // If we don't have that language, try omitting the country part,
- // leaving just the language part ("de_DE" -> "de")
-
- if ( lookup(languages, language) == nil && size(language) > 2 )
- language=substring(language, 0, 2);
-
- UI(`SetLanguage(language));
-
- /*
- * Set default console font
- */
-
- map consolefonts = ReadY2("consolefonts.ycp");
- SetConsoleFont(consolefonts, language);
-
- term languagesel =
- `SelectionBox(`id(`language), `opt(`notify), "",
- maplist(`lang_code, `lang_name, languages,
- `` `item(`id(lang_code), lang_name, language == lang_code)));
-
-
- /* ----------------------------------------------------------------------
- * Build dialog
- * ----------------------------------------------------------------------*/
-
- term contents = `VBox(
- `Heading ( _(
- "Welcome to YaST2 - the SuSE Linux
- installation / system administration program."
- ) ),
- `VWeight( 5, `VStretch() ),
- `VWeight( 80, `HBox(
- `HWeight( 25, `HStretch() ),
- `HWeight( 50,
- `VBox (
- `Left( `Label ( _( "Select your language:" ) ) ),
- languagesel
- )
- ),
- `HWeight( 25, `HStretch() )
- )
- ),
- `VWeight( 10, `VStretch() ),
-
- // This button quits the installation in the first dialog
- // where the user has a chance to click at anything.
- // The ID `cancel will be handled automatically by the UI -
- // no further action necessary.
- `PushButton( `id(`cancel), _("&Quit YaST2") ),
- `VWeight( 5, `VStretch() )
- );
-
- // Show a Wizardwindow with that contents. Don't use the Id `next,
- // `back, and `help
-
- // helptext for language,keyboard,timezone screen
- string help_text = UI(_("\
- <p>
- Choose the <b>language</b> to be used during installation and later in
- the installed system.
- </p>" ) );
-
- help_text = help_text + UI(_("\
- <p>
- Select <b>next</b> to continue with the next dialog. If you wish to
- change your selections in a later dialog, you can use the <b>back</b>
- and <b>next</b> buttons to switch back and forth between the
- installation dialogs.
- </p>" ) );
-
- help_text = help_text + UI(_("\
- <p>
- <b><i>Nothing will happen</i></b> to your computer until you confirm
- all your selections in the last installation dialog.
- </p>
-
- <p>
- Select <b>Quit YaST2</b> to abort the installation now.
- </p>
- <br>
- ") );
-
- // Screen title for the first interactive dialog
- any dlg = UI(`SetWizardContents( "", contents,
- help_text,
- Args(0), Args(1)));
-
- any ret = nil;
-
- repeat
- {
- ret= UI(`UserInput());
-
- if (ret == `next || ret == `language || ret == `back)
- {
- language = UI(`QueryWidget(`id(`language), `CurrentItem));
- user_settings = add(user_settings, "language", language);
-
- if ( ret != `back )
- {
- UI(`SetLanguage(language));
- SetConsoleFont(consolefonts, language);
-
- string yast1_language = lookup (lang2yast1, language, language);
- user_settings = add (user_settings, "yast1_language", yast1_language);
-
- // replace Language and Locale in /etc/install.inf
- // remove Keytable from /etc/install.inf
-
- Shell ("grep -v ^Language /etc/install.inf | grep -v ^Keytable | grep -v ^Locale > /tmp/install.inf");
- WriteString ("/tmp/yast2.inf",
- "Language: "+yast1_language+"\n"
- + "Locale: "+language+"\n");
- Shell ("cat /tmp/yast2.inf /tmp/install.inf > /etc/install.inf");
-
- _debug("Lang: ", language);
-
- if (ret == `language) return (`again);
- }
-
- if ( ret == `next )
- {
- integer mem_total_with_swap = 0;
- map|void mem_map = SCR(`Read(.proc.meminfo));
-
- _debug ( "MemMap", mem_map );
-
- if ( mem_map != nil )
- {
- // default 256 MB if the amount can not be read
- mem_total_with_swap = lookup(lookup( mem_map, "mem" ), "total", 256 * 1024 * 1024 )
- + lookup(lookup( mem_map, "swap"), "total", 0);
-
- _debug( "Total Mem:", mem_total_with_swap );
-
- if ( mem_total_with_swap < (48 * 1024 * 1024) )
- {
- UI(`DisplayMessage(_("YaST2 needs at least 48 MB of memory to run.\n
- Please use the text based YaST1 for the
- installation of SuSE Linux on your PC.
- A detailed description of the installation
- procedure can be found in the manual." ) ) );
-
- return `again;
- }
- }
- }
-
- }
- } until (ret == `next || ret == `back || ret == `cancel);
-
- return ret;
- }
-