コード例 #1
0
//shows locale setup for language selection
void COsdLangSetup::showLanguageSetup(CMenuWidget *osdl_setup)
{
	struct dirent **namelist;
	int n;
	const char *pfad[] = { LOCALEDIR, LOCALEDIR_VAR };

	osdl_setup->addIntroItems();

	for (int p = 0; p < 2; p++)
	{
		n = scandir(pfad[p], &namelist, 0, alphasort);
		if (n < 0)
		{
			perror("loading locales: scandir");
		}
		else
		{
			for (int count=0; count<n; count++)
			{
				char * locale = namelist[count]->d_name;
				char * pos = strstr(locale, ".locale");
				if (pos != NULL)
				{
					*pos = '\0';
					std::string loc(locale);
					loc.at(0) = toupper(loc.at(0));

					CMenuForwarder *mf = new CMenuForwarder(loc, true, NULL, this, locale);
					mf->iconName = mf->getActionKey();
					osdl_setup->addItem(mf, !strcmp(locale, g_settings.language.c_str()));
				}
				free(namelist[count]);
			}
			free(namelist);
		}
	}
}