// -*- c++ -*- /* * Jakelib2 - General purpose C++ library * Copyright (C) 2001 Florian Wolff (florian@donuz.de) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: LocaleTest.jlc,v 1.16 2006-02-18 16:12:16 florian Exp $ */ #include "Test.h" #include #include using namespace jakelib::lang; using namespace jakelib::util; using namespace jakelib::text; extern Commandline* params; void printLocaleInfo(Locale* loc) { System::out->println(`"Locale info '"` .. loc .. `":"`); DecimalFormatSyms *decSyms = new DecimalFormatSyms(loc); System::out->println(`" - DecimalFormatSyms"`); System::out->println(`" getCurrencySymbol(): '"` .. decSyms->getCurrencySymbol() .. `"'"`); DateFormatSymbols* dateSyms = new DateFormatSymbols(loc); System::out->println(`" - DateFormatSymbols:"`); System::out->print(`" getMonths(): '"`); for (int idx = 0; idx <= 11; idx++) { System::out->print(dateSyms->getMonths()->get(idx)); if (idx < 11) System::out->print(`", "`); } System::out->println(); System::out->print(`" getWeekdays(): "`); for (int idx = 1; idx <= 7; idx++) { System::out->print(dateSyms->getWeekdays()->get(idx)); if (idx < 7) System::out->print(`", "`); } System::out->println(); } void localeTest() { try { System::out->println(`"LANG="` .. System::getEnv(`"LANG"`)); System::out->println(`"LC_ALL="` .. System::getEnv(`"LC_ALL"`)); Locale* l = Locale::getDefault(); System::out->println(`"l = Locale::getDefault()"`); System::out->println(`" l->getLanguage() = '"` .. l->getLanguage() .. `"'"`); System::out->println(`" l->getCountry() = '"` .. l->getCountry() .. `"'"`); System::out->println(`" l->getVariant() = '"` .. l->getVariant() .. `"'"`); Strings* isoLanguages = Locale::getISOLanguages(); for (int idx = 0; idx < isoLanguages->length(); idx++) { //System::out->println(String().plus(idx)->plus(". ")->plus((*isoLanguages)[idx])); } printLocaleInfo(Locale::getDefault()); printLocaleInfo(Locale::GERMANY); printLocaleInfo(Locale::FRANCE); printLocaleInfo(new Locale(`"es"`)); } catch (Exception *e) { System::out->println(e); } }