[Lutinutil-commits] r1544 - in nuitonutil/trunk: . src/main/java/org src/main/java/org/codelutin/i18n src/main/java/org/codelutin/util src/main/resources/i18n src/test/java/org src/test/java/org/codelutin/i18n/bundle src/test/java/org/codelutin/util
Author: tchemit Date: 2009-05-14 05:19:13 +0000 (Thu, 14 May 2009) New Revision: 1544 Added: nuitonutil/trunk/src/main/java/org/nuiton/ nuitonutil/trunk/src/main/resources/i18n/nuitonutil-en_GB.properties nuitonutil/trunk/src/main/resources/i18n/nuitonutil-fr_FR.properties nuitonutil/trunk/src/test/java/org/nuiton/ Removed: nuitonutil/trunk/src/main/java/org/codelutin/i18n/CountryEnum.java nuitonutil/trunk/src/main/java/org/codelutin/i18n/I18nDefaultTooltipFilter.java nuitonutil/trunk/src/main/java/org/codelutin/i18n/I18nFileReader.java nuitonutil/trunk/src/main/java/org/codelutin/i18n/I18nFilter.java nuitonutil/trunk/src/main/java/org/codelutin/i18n/LanguageEnum.java nuitonutil/trunk/src/main/java/org/codelutin/util/LocaleConverter.java nuitonutil/trunk/src/main/resources/i18n/lutinutil-en_GB.properties nuitonutil/trunk/src/main/resources/i18n/lutinutil-fr_FR.properties nuitonutil/trunk/src/test/java/org/codelutin/i18n/bundle/I18nBunsleScopeTest.java nuitonutil/trunk/src/test/java/org/codelutin/util/LocaleConverterTest.java Modified: nuitonutil/trunk/pom.xml nuitonutil/trunk/src/main/java/org/codelutin/i18n/I18nLoader.java nuitonutil/trunk/src/main/java/org/codelutin/i18n/Language.java nuitonutil/trunk/src/main/java/org/codelutin/i18n/LocaleEditor.java nuitonutil/trunk/src/test/java/org/codelutin/i18n/bundle/I18nBundleManagerTest.java Log: utilisation nuiton-i18n-api Modified: nuitonutil/trunk/pom.xml =================================================================== --- nuitonutil/trunk/pom.xml 2009-05-14 05:18:40 UTC (rev 1543) +++ nuitonutil/trunk/pom.xml 2009-05-14 05:19:13 UTC (rev 1544) @@ -11,10 +11,17 @@ <groupId>org.codelutin</groupId> <artifactId>lutinproject</artifactId> <version>3.5.4</version> + <!--groupId>org.nuiton</groupId> + <artifactId>mavenpom</artifactId> + <version>1.0.0-SNAPSHOT</version--> </parent> - <artifactId>lutinutil</artifactId> + <!-- assuprimer du de l'utilisation de mavenpom --> + <groupId>org.nuiton</groupId> + + <artifactId>nuitonutil</artifactId> + <version>1.1.0-SNAPSHOT</version> <dependencies> @@ -27,6 +34,12 @@ </dependency> <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + <version>1.1.1</version> + </dependency> + + <dependency> <groupId>commons-primitives</groupId> <artifactId>commons-primitives</artifactId> <version>1.0</version> @@ -46,7 +59,7 @@ <version>1.8.0</version> <scope>compile</scope> </dependency> - + <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-compress</artifactId> @@ -54,6 +67,20 @@ <scope>compile</scope> </dependency> + <dependency> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-i18n-api</artifactId> + <version>1.0.0-SNAPSHOT</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.6</version> + <scope>test</scope> + </dependency> + </dependencies> @@ -61,7 +88,7 @@ <!-- *** Project Information ************************************* --> <!-- ************************************************************* --> - <name>Lutin utilities library</name> + <name>Nuiton utilities library</name> <description>Library of usefull class to be used in any project.</description> <inceptionYear>2004</inceptionYear> @@ -73,9 +100,16 @@ <properties> + <redmine.project>nuitonprocessor</redmine.project> + + <!-- assuprimer du de l'utilisation de mavenpom --> <labs.id>12</labs.id> <labs.project>lutinutil</labs.project> - + <helper.version>1.0.0-SNAPSHOT</helper.version> + <helper.licenseName>lgpl_v3</helper.licenseName> + <site.home.url>http://lutinutil.labs.libre-entreprise.org</site.home.url> + <repository.home.url>http://lutinbuilder.labs.libre-entreprise.org/maven2</repository.home.url> + </properties> <build> @@ -86,9 +120,9 @@ <!-- plugin i18n --> <plugin> - <groupId>org.codelutin</groupId> + <groupId>org.nuiton</groupId> <artifactId>maven-i18n-plugin</artifactId> - <version>0.11</version> + <version>1.0.0-SNAPSHOT</version> <executions> <execution> <goals> @@ -114,7 +148,7 @@ </dependency> </dependencies> </plugin> - + <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.1</version> @@ -135,7 +169,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> - <version>2.5</version> + <!--version>2.5</version--> <configuration> <quiet>true</quiet> <links> @@ -151,6 +185,7 @@ <!-- ************************************************************* --> <!--Source control management--> + <!-- a supprimer --> <scm> <url>${maven.scm.url}</url> <connection>${maven.scm.connection}</connection> @@ -173,7 +208,7 @@ </releases> </repository> </repositories> - + <profiles> <profile> <id>release-profile</id> @@ -186,22 +221,6 @@ <build> <plugins> - <!-- always add license and third-party files to classpath --> - <plugin> - <groupId>org.codelutin</groupId> - <artifactId>maven-license-switcher-plugin</artifactId> - <version>0.8</version> - <executions> - <execution> - <id>attach-licenses</id> - <goals> - <goal>license</goal> - <goal>third-party</goal> - </goals> - </execution> - </executions> - </plugin> - <!-- launch in a release the assembly automaticly --> <plugin> <artifactId>maven-assembly-plugin</artifactId> Deleted: nuitonutil/trunk/src/main/java/org/codelutin/i18n/CountryEnum.java =================================================================== --- nuitonutil/trunk/src/main/java/org/codelutin/i18n/CountryEnum.java 2009-05-14 05:18:40 UTC (rev 1543) +++ nuitonutil/trunk/src/main/java/org/codelutin/i18n/CountryEnum.java 2009-05-14 05:19:13 UTC (rev 1544) @@ -1,286 +0,0 @@ -/* -* *##% Lutin utilities library - * Copyright (C) 2004 - 2008 CodeLutin - * - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */ -package org.codelutin.i18n; - -import static org.codelutin.i18n.I18n._; - -/** - * Une énumération pour représenter le pays d'une locale - * <p/> - * <a href="http://www.iso.org/iso/country_codes"><code>ISO 3166-1:1998 (ICS n° 01.140.20)</code></a>. - * <p/> - * <a href="http://www.iso.org/iso/french_country_names_and_code_elements">la liste des codes</a> - * <p/> - * Chaque pays est repésenté ainsi : - * <pre>A2, // A3 Number Country name</pre> - * - * @author chemit - */ - -public enum CountryEnum { - AF, // AFG 004 AFGHANISTAN - AL, // ALB 008 ALBANIA - DZ, // DZA 012 ALGERIA - AS, // ASM 016 AMERICAN SAMOA - AD, // AND 020 ANDORRA - AO, // AGO 024 ANGOLA - AI, // AIA 660 ANGUILLA - AQ, // ATA 010 ANTARCTICA - AG, // ATG 028 ANTIGUA AND BARBUDA - AR, // ARG 032 ARGENTINA - AM, // ARM 051 ARMENIA - AW, // ABW 533 ARUBA - AU, // AUS 036 AUSTRALIA - AT, // AUT 040 AUSTRIA - AZ, // AZE 031 AZERBAIJAN - BS, // BHS 044 BAHAMAS - BH, // BHR 048 BAHRAIN - BD, // BGD 050 BANGLADESH - BB, // BRB 052 BARBADOS - BY, // BLR 112 BELARUS - BE, // BEL 056 BELGIUM - BZ, // BLZ 084 BELIZE - BJ, // BEN 204 BENIN - BM, // BMU 060 BERMUDA - BT, // BTN 064 BHUTAN - BO, // BOL 068 BOLIVIA - BA, // BIH 070 BOSNIA AND HERZEGOWINA - BW, // BWA 072 BOTSWANA - BV, // BVT 074 BOUVET ISLAND - BR, // BRA 076 BRAZIL - IO, // IOT 086 BRITISH INDIAN OCEAN TERRITORY - BN, // BRN 096 BRUNEI DARUSSALAM - BG, // BGR 100 BULGARIA - BF, // BFA 854 BURKINA FASO - BI, // BDI 108 BURUNDI - KH, // KHM 116 CAMBODIA - CM, // CMR 120 CAMEROON - CA, // CAN 124 CANADA - CV, // CPV 132 CAPE VERDE - KY, // CYM 136 CAYMAN ISLANDS - CF, // CAF 140 CENTRAL AFRICAN REPUBLIC - TD, // TCD 148 CHAD - CL, // CHL 152 CHILE - CN, // CHN 156 CHINA - CX, // CXR 162 CHRISTMAS ISLAND - CC, // CCK 166 COCOS (KEELING) ISLANDS - CO, // COL 170 COLOMBIA - KM, // COM 174 COMOROS - CG, // COG 178 CONGO - CK, // COK 184 COOK ISLANDS - CR, // CRI 188 COSTA RICA - CI, // CIV 384 COTE D'IVOIRE - HR, // HRV 191 CROATIA (local name: Hrvatska) - CU, // CUB 192 CUBA - CY, // CYP 196 CYPRUS - CZ, // CZE 203 CZECH REPUBLIC - DK, // DNK 208 DENMARK - DJ, // DJI 262 DJIBOUTI - DM, // DMA 212 DOMINICA - DO, // DOM 214 DOMINICAN REPUBLIC - TP, // TMP 626 EAST TIMOR - EC, // ECU 218 ECUADOR - EG, // EGY 818 EGYPT - SV, // SLV 222 EL SALVADOR - GQ, // GNQ 226 EQUATORIAL GUINEA - ER, // ERI 232 ERITREA - EE, // EST 233 ESTONIA - ET, // ETH 210 ETHIOPIA - FK, // FLK 238 FALKLAND ISLANDS (MALVINAS) - FO, // FRO 234 FAROE ISLANDS - FJ, // FJI 242 FIJI - FI, // FIN 246 FINLAND - FR, // FRA 250 FRANCE - FX, // FXX 249 FRANCE, METROPOLITAN - GF, // GUF 254 FRENCH GUIANA - PF, // PYF 258 FRENCH POLYNESIA - TF, // ATF 260 FRENCH SOUTHERN TERRITORIES - GA, // GAB 266 GABON - GM, // GMB 270 GAMBIA - GE, // GEO 268 GEORGIA - DE, // DEU 276 GERMANY - GH, // GHA 288 GHANA - GI, // GIB 292 GIBRALTAR - GR, // GRC 300 GREECE - GL, // GRL 304 GREENLAND - GD, // GRD 308 GRENADA - GP, // GLP 312 GUADELOUPE - GU, // GUM 316 GUAM - GT, // GTM 320 GUATEMALA - GN, // GIN 324 GUINEA - GW, // GNB 624 GUINEA-BISSAU - GY, // GUY 328 GUYANA - HT, // HTI 332 HAITI - HM, // HMD 334 HEARD AND MC DONALD ISLANDS - HN, // HND 340 HONDURAS - HK, // HKG 344 HONG KONG - HU, // HUN 348 HUNGARY - IS, // ISL 352 ICELAND - IN, // IND 356 INDIA - ID, // IDN 360 INDONESIA - IR, // IRN 364 IRAN (ISLAMIC REPUBLIC OF) - IQ, // IRQ 368 IRAQ - IE, // IRL 372 IRELAND - IL, // ISR 376 ISRAEL - IT, // ITA 380 ITALY - JM, // JAM 388 JAMAICA - JP, // JPN 392 JAPAN - JO, // JOR 400 JORDAN - KZ, // KAZ 398 KAZAKHSTAN - KE, // KEN 404 KENYA - KI, // KIR 296 KIRIBATI - KP, // PRK 408 KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF - KR, // KOR 410 KOREA, REPUBLIC OF - KW, // KWT 414 KUWAIT - KG, // KGZ 417 KYRGYZSTAN - LA, // LAO 418 LAO PEOPLE'S DEMOCRATIC REPUBLIC - LV, // LVA 428 LATVIA - LB, // LBN 422 LEBANON - LS, // LSO 426 LESOTHO - LR, // LBR 430 LIBERIA - LY, // LBY 434 LIBYAN ARAB JAMAHIRIYA - LI, // LIE 438 LIECHTENSTEIN - LT, // LTU 440 LITHUANIA - LU, // LUX 442 LUXEMBOURG - MO, // MAC 446 MACAU - MK, // MKD 807 (provis) MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF - MG, // MDG 450 MADAGASCAR - MW, // MWI 454 MALAWI - MY, // MYS 458 MALAYSIA - MV, // MDV 462 MALDIVES - ML, // MLI 466 MALI - MT, // MLT 470 MALTA - MH, // MHL 584 MARSHALL ISLANDS - MQ, // MTQ 474 MARTINIQUE - MR, // MRT 478 MAURITANIA - MU, // MUS 480 MAURITIUS - YT, // MYT 175 MAYOTTE - MX, // MEX 484 MEXICO - FM, // FSM 583 MICRONESIA, FEDERATED STATES OF - MD, // MDA 498 MOLDOVA, REPUBLIC OF - MC, // MCO 492 MONACO - MN, // MNG 496 MONGOLIA - MS, // MSR 500 MONTSERRAT - MA, // MAR 504 MOROCCO - MZ, // MOZ 508 MOZAMBIQUE - MM, // MMR 104 MYANMAR - NA, // NAM 516 NAMIBIA - NR, // NRU 520 NAURU - NP, // NPL 524 NEPAL - NL, // NLD 528 NETHERLANDS - AN, // ANT 530 NETHERLANDS ANTILLES - NC, // NCL 540 NEW CALEDONIA - NZ, // NZL 554 NEW ZEALAND - NI, // NIC 558 NICARAGUA - NE, // NER 562 NIGER - NG, // NGA 566 NIGERIA - NU, // NIU 570 NIUE - NF, // NFK 574 NORFOLK ISLAND - MP, // MNP 580 NORTHERN MARIANA ISLANDS - NO, // NOR 578 NORWAY - OM, // OMN 512 OMAN - PK, // PAK 586 PAKISTAN - PW, // PLW 585 PALAU - PA, // PAN 591 PANAMA - PG, // PNG 598 PAPUA NEW GUINEA - PY, // PRY 600 PARAGUAY - PE, // PER 604 PERU - PH, // PHL 608 PHILIPPINES - PN, // PCN 612 PITCAIRN - PL, // POL 616 POLAND - PT, // PRT 620 PORTUGAL - PR, // PRI 630 PUERTO RICO - QA, // QAT 634 QATAR - RE, // REU 638 REUNION - RO, // ROM 642 ROMANIA - RU, // RUS 643 RUSSIAN FEDERATION - RW, // RWA 646 RWANDA - KN, // KNA 659 SAINT KITTS AND NEVIS - LC, // LCA 662 SAINT LUCIA - VC, // VCT 670 SAINT VINCENT AND THE GRENADINES - WS, // WSM 882 SAMOA - SM, // SMR 674 SAN MARINO - ST, // STP 678 SAO TOME AND PRINCIPE - SA, // SAU 682 SAUDI ARABIA - SN, // SEN 686 SENEGAL - SC, // SYC 690 SEYCHELLES - SL, // SLE 694 SIERRA LEONE - SG, // SGP 702 SINGAPORE - SK, // SVK 703 SLOVAKIA (Slovak Republic) - SI, // SVN 705 SLOVENIA - SB, // SLB 090 SOLOMON ISLANDS - SO, // SOM 706 SOMALIA - ZA, // ZAF 710 SOUTH AFRICA - ES, // ESP 724 SPAIN - LK, // LKA 144 SRI LANKA - SH, // SHN 654 ST. HELENA - PM, // SPM 666 ST. PIERRE AND MIQUELON - SD, // SDN 736 SUDAN - SR, // SUR 740 SURINAME - SJ, // SJM 744 SVALBARD AND JAN MAYEN ISLANDS - SZ, // SWZ 748 SWAZILAND - SE, // SWE 752 SWEDEN - CH, // CHE 756 SWITZERLAND - SY, // SYR 760 SYRIAN ARAB REPUBLIC - TW, // TWN 158 TAIWAN, PROVINCE OF CHINA - TJ, // TJK 762 TAJIKISTAN - TZ, // TZA 834 TANZANIA, UNITED REPUBLIC OF - TH, // THA 764 THAILAND - TG, // TGO 768 TOGO - TK, // TKL 772 TOKELAU - TO, // TON 776 TONGA - TT, // TTO 780 TRINIDAD AND TOBAGO - TN, // TUN 788 TUNISIA - TR, // TUR 792 TURKEY - TM, // TKM 795 TURKMENISTAN - TC, // TCA 796 TURKS AND CAICOS ISLANDS - TV, // TUV 798 TUVALU - UG, // UGA 800 UGANDA - UA, // UKR 804 UKRAINE - AE, // ARE 784 UNITED ARAB EMIRATES - GB, // GBR 826 UNITED KINGDOM - US, // USA 840 UNITED STATES - UM, // UMI 581 UNITED STATES MINOR OUTLYING ISLANDS - UY, // URY 858 URUGUAY - UZ, // UZB 860 UZBEKISTAN - VU, // VUT 548 VANUATU - VA, // VAT 336 VATICAN CITY STATE (HOLY SEE) - VE, // VEN 862 VENEZUELA - VN, // VNM 704 VIET NAM - VG, // VGB 092 VIRGIN ISLANDS (BRITISH) - VI, // VIR 850 VIRGIN ISLANDS (U.S.) - WF, // WLF 876 WALLIS AND FUTUNA ISLANDS - EH, // ESH 732 WESTERN SAHARA - YE, // YEM 887 YEMEN - YU, // YUG 891 YUGOSLAVIA - ZR, // ZAR 180 ZAIRE - ZM, // ZMB 894 ZAMBIA - ZW; // ZWE 716 ZIMBABWE - - public static CountryEnum valueOf(String country, CountryEnum defaultValue) { - CountryEnum countryValue = null; - try { - countryValue = CountryEnum.valueOf(country.toUpperCase()); - } catch (IllegalArgumentException e) { - System.err.println(_("lutinutil.error.i18n.unfound.country", country, defaultValue)); - } catch (NullPointerException e) { - System.err.println(_("lutinutil.error.i18n.unfound.country", country, defaultValue)); - } - return countryValue == null ? defaultValue : countryValue; - } -} Deleted: nuitonutil/trunk/src/main/java/org/codelutin/i18n/I18nDefaultTooltipFilter.java =================================================================== --- nuitonutil/trunk/src/main/java/org/codelutin/i18n/I18nDefaultTooltipFilter.java 2009-05-14 05:18:40 UTC (rev 1543) +++ nuitonutil/trunk/src/main/java/org/codelutin/i18n/I18nDefaultTooltipFilter.java 2009-05-14 05:19:13 UTC (rev 1544) @@ -1,41 +0,0 @@ -/* *##% Lutin utilities library - * Copyright (C) 2004 - 2008 CodeLutin - * - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */ - -/* * - * i18nDefaultTooltipFilter.java - * - * Created: 2 déc. 2003 - * - * @author Benjamin Poussin <poussin@codelutin.com> - * Copyright Code Lutin - * @version $Revision$ - * - * Mise a jour: $Date$ - * par : $Author$ - */ - -package org.codelutin.i18n; - -public class I18nDefaultTooltipFilter implements I18nFilter { // I18nDefaultTooltipFilter - - public String applyFilter(String message) { - if (message != null && message.startsWith("defaultToolTip-")) - return null; - return message; - } -} // I18nDefaultTooltipFilter - Deleted: nuitonutil/trunk/src/main/java/org/codelutin/i18n/I18nFileReader.java =================================================================== --- nuitonutil/trunk/src/main/java/org/codelutin/i18n/I18nFileReader.java 2009-05-14 05:18:40 UTC (rev 1543) +++ nuitonutil/trunk/src/main/java/org/codelutin/i18n/I18nFileReader.java 2009-05-14 05:19:13 UTC (rev 1544) @@ -1,131 +0,0 @@ -/* *##% Lutin utilities library - * Copyright (C) 2004 - 2008 CodeLutin - * - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */ - -/* * - * I18nFileReader.java - * - * Created: Nov 22, 2004 - * - * @author Cédric Pineau <pineau@codelutin.com> - * @version $Revision$ - * - * Last update : $Date$ - * by : $Author$ - */ - -package org.codelutin.i18n; - -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.nio.charset.Charset; -import java.util.Properties; -import java.util.regex.Pattern; - -/** Classe assurant la lecture et les possibles traitement nécessaires à I18n. */ -public class I18nFileReader extends Properties { - - protected static final Pattern commentPattern = Pattern.compile("[^\\\\]#"); - - protected static final Pattern splitPattern = Pattern.compile("[^\\\\]="); - private static final long serialVersionUID = 3611718334066783394L; - - public void load(InputStream inStream, String encodingTo) throws IOException { - Charset charsetTo = Charset.forName(encodingTo); - BufferedReader readerFile; - readerFile = new BufferedReader(new InputStreamReader(inStream, charsetTo)); - String lineFile; - StringBuilder builderFile; - builderFile = new StringBuilder(); - while ((lineFile = readerFile.readLine()) != null) { - builderFile.append(lineFile).append('\n'); - } - readerFile.close(); - super.load(new ByteArrayInputStream(builderFile.toString().getBytes())); - } - - protected String interpretBackslashes(String message) { - int backslashIndex = -1; - while ((backslashIndex = message.indexOf("\\", backslashIndex + 1)) != -1) { - if (message.length() >= backslashIndex + 1) { - char charNextToBackslash = message.charAt(backslashIndex + 1); - char replacementChar; - switch (charNextToBackslash) { - case '\\': - replacementChar = '\\'; - break; - case 't': - replacementChar = '\t'; - break; - case 'n': - replacementChar = '\n'; - break; - case ' ': - replacementChar = ' '; - break; - case '=': - replacementChar = '='; - break; - case ':': - replacementChar = ':'; - break; - default: - replacementChar = '\\'; - break; - } - message = message.substring(0, backslashIndex) + replacementChar + message.substring(backslashIndex + 2); - } - } - return message; - } - - private static char[] chars = {'\\', '\n', '\t', ' ', '=', ':'}; - - protected String serializeBackslashes(String message) { - for (char c : chars) { - int charIndex = -1; - while ((charIndex = message.indexOf(c, charIndex + 2)) != -1) { - String replacementString = "" + c; - switch (c) { - case '\\': - replacementString = "\\\\"; - break; - case '\t': - replacementString = "\\t"; - break; - case '\n': - replacementString = "\\n"; - break; - case ' ': - replacementString = "\\ "; - break; - case '=': - replacementString = "\\="; - break; - case ':': - replacementString = "\\:"; - break; - } - message = message.substring(0, charIndex) + replacementString + message.substring(charIndex + 1); - } - } - return message; - } - -} //I18nFileReader Deleted: nuitonutil/trunk/src/main/java/org/codelutin/i18n/I18nFilter.java =================================================================== --- nuitonutil/trunk/src/main/java/org/codelutin/i18n/I18nFilter.java 2009-05-14 05:18:40 UTC (rev 1543) +++ nuitonutil/trunk/src/main/java/org/codelutin/i18n/I18nFilter.java 2009-05-14 05:19:13 UTC (rev 1544) @@ -1,37 +0,0 @@ -/* *##% Lutin utilities library - * Copyright (C) 2004 - 2008 CodeLutin - * - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */ - -/* * - * i18nFilter.java - * - * Created: 2 déc. 2003 - * - * @author Benjamin Poussin <poussin@codelutin.com> - * Copyright Code Lutin - * @version $Revision$ - * - * Mise a jour: $Date$ - * par : $Author$ - */ - -package org.codelutin.i18n; - -public interface I18nFilter { // I18nFilter - - public String applyFilter(String message); -} // I18nFilter - Modified: nuitonutil/trunk/src/main/java/org/codelutin/i18n/I18nLoader.java =================================================================== --- nuitonutil/trunk/src/main/java/org/codelutin/i18n/I18nLoader.java 2009-05-14 05:18:40 UTC (rev 1543) +++ nuitonutil/trunk/src/main/java/org/codelutin/i18n/I18nLoader.java 2009-05-14 05:19:13 UTC (rev 1544) @@ -19,15 +19,20 @@ package org.codelutin.i18n; import java.net.URL; +import java.net.URLClassLoader; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; import java.util.List; import java.util.Locale; import org.codelutin.i18n.bundle.I18nBundle; import org.codelutin.i18n.bundle.I18nBundleEntry; import org.codelutin.i18n.bundle.I18nBundleFactory; +import org.codelutin.util.ClassLoaderUtil; +import org.codelutin.util.Resource; import org.codelutin.util.StringUtil; /** @@ -142,7 +147,7 @@ if (urls == null) { // on utilise le mecanisme de recherche des bundles dans toutes // les entrees du classloader - urls = I18nBundleFactory.getURLs(Language.getLoader(), I18n.getExtraURL()); + urls = getURLs(Language.getLoader(), I18n.getExtraURL()); } } @@ -236,4 +241,105 @@ throw new IllegalStateException("should call init method on " + I18nLoader.class); } } + + /** + * Detecte les urls de toutes les entrees de bunbles sur tout un classLoader. + * + * Il s'agit du mode initialie de detection des entréés de bundles, i.e des + * fichiers de traductions. + * + * <b>Note: </b> Cette methode devient couteuse des que le classLoader + * contient de nombreuses entrées. Il est meiux d'utiliser le second type + * de chargement qui n'utilise qu'un seul fichier de traduction unifié. + * + * @param loader le classloader a utiliser pour trouver les resources. + * @return les urls des entrees de bundles + */ + public static URL[] getURLs(URLClassLoader loader) { + try { + // on calcule toutes les urls utilisable dans le classloader donnee + List<URL> urlToSeek = new ArrayList<URL>(); + urlToSeek.addAll(Arrays.asList(ClassLoaderUtil.getDeepURLs(loader))); + + // on va maintenant supprimer toutes les urls qui ne respectent pas + // le pattern i18n : il faut que la resource contienne un repertoire i18n + // ce simple test permet de restreindre la recherche des resources + // i18n qui est tres couteuse + int size = urlToSeek.size(); + for (Iterator<URL> it = urlToSeek.iterator(); it.hasNext();) { + URL url = it.next(); + if (!Resource.containsDirectDirectory(url, I18nBundleFactory.DIRECTORY_SEARCH_BUNDLE_PATTERN)) { + if (log.isDebugEnabled()) { + log.debug("skip url with no " + I18nBundleFactory.DIRECTORY_SEARCH_BUNDLE_PATTERN + " directory : " + url); + } + it.remove(); + } + } + if (log.isDebugEnabled()) { + log.debug("detect " + urlToSeek.size() + " i18n capable url (out of " + size + ")"); + } + // on effectue la recherche des urls des resources i18n (tous les + // fichiers de traductions) sur toutes les urls precedemment calculees) + List<URL> result = Resource.getURLs(I18nBundleFactory.SEARCH_BUNDLE_PATTERN, urlToSeek.toArray(new URL[urlToSeek.size()])); + if (log.isDebugEnabled()) { + for (URL url : result) { + log.debug(url.toString()); + } + } + return result.toArray(new URL[result.size()]); + } catch (Exception eee) { + log.warn("Unable to find urls for loader : " + loader + " for reason " + eee.getMessage(), eee); + return new URL[0]; + } + } + + /** + * Recherche la liste des url de toutes les resources i18n, i.e les urls + * des fichiers de traduction. + * + * @param loader le classLoader où trouver les bundles + * @param extraUrl des urls de resources i18n deja calcule, à ajouter au resultat sans traitement particulier + * @return la liste des urls de bundle i18n pour la langue donné + */ + public static URL[] getURLs(URLClassLoader loader, URL... extraUrl) { + + try { + // on calcule toutes les urls utilisable dans le classloader donnee + List<URL> urlToSeek = new ArrayList<URL>(); + urlToSeek.addAll(Arrays.asList(ClassLoaderUtil.getDeepURLs(loader))); + // on ajoute les urls de resources i18n donnes + if (extraUrl.length > 0) { + urlToSeek.addAll(Arrays.asList(extraUrl)); + } + // on va maintenant supprimer toutes les urls qui ne respectent pas + // le pattern i18n : il faut que la resource contienne un repertoire i18n + // ce simple test permet de restreindre la recherche des resources + // i18n qui est tres couteuse + int size = urlToSeek.size(); + for (Iterator<URL> it = urlToSeek.iterator(); it.hasNext();) { + URL url = it.next(); + if (!Resource.containsDirectDirectory(url, I18nBundleFactory.DIRECTORY_SEARCH_BUNDLE_PATTERN)) { + if (log.isDebugEnabled()) { + log.debug("skip url with no " + I18nBundleFactory.DIRECTORY_SEARCH_BUNDLE_PATTERN + " directory : " + url); + } + it.remove(); + } + } + if (log.isDebugEnabled()) { + log.debug("detect " + urlToSeek.size() + " i18n capable url (out of " + size + ")"); + } + // on effectue la recherche des urls des resources i18n (tous les + // fichiers de traductions) sur toutes les urls precedemment calculees) + List<URL> result = Resource.getURLs(I18nBundleFactory.SEARCH_BUNDLE_PATTERN, urlToSeek.toArray(new URL[urlToSeek.size()])); + if (log.isDebugEnabled()) { + for (URL url : result) { + log.debug(url.toString()); + } + } + return result.toArray(new URL[result.size()]); + } catch (Exception eee) { + log.warn("Unable to find urls for loader : " + loader + " for reason " + eee.getMessage(), eee); + return new URL[0]; + } + } } Modified: nuitonutil/trunk/src/main/java/org/codelutin/i18n/Language.java =================================================================== --- nuitonutil/trunk/src/main/java/org/codelutin/i18n/Language.java 2009-05-14 05:18:40 UTC (rev 1543) +++ nuitonutil/trunk/src/main/java/org/codelutin/i18n/Language.java 2009-05-14 05:19:13 UTC (rev 1544) @@ -35,7 +35,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.codelutin.i18n.bundle.I18nBundleEntry; -import org.codelutin.i18n.bundle.I18nBundleManager; import org.codelutin.util.RecursiveProperties; /** @@ -70,27 +69,6 @@ } /** - * charge les traductions de la langue. - * <p/> - * recherche dans un premier temps, les urls des bundles puis les charge. - * - * @param bundleManager the used bundle manager - */ - @Deprecated - public void load(I18nBundleManager bundleManager) { - // make sure the bundlemanager is init - bundleManager.init(); - // load resources from bundles - resource = new RecursiveProperties(); - // get bundles for this locale - try { - bundleManager.load(this, resource); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - /** * charge les traductions de la languea partir d'une liste donnee de * fichiers de traduction. * Deleted: nuitonutil/trunk/src/main/java/org/codelutin/i18n/LanguageEnum.java =================================================================== --- nuitonutil/trunk/src/main/java/org/codelutin/i18n/LanguageEnum.java 2009-05-14 05:18:40 UTC (rev 1543) +++ nuitonutil/trunk/src/main/java/org/codelutin/i18n/LanguageEnum.java 2009-05-14 05:19:13 UTC (rev 1544) @@ -1,185 +0,0 @@ -/* -* *##% Lutin utilities library - * Copyright (C) 2004 - 2008 CodeLutin - * - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */ -package org.codelutin.i18n; - -import static org.codelutin.i18n.I18n._; - -/** - * Une énumération pour représenter le langue d'une locale définie dans la norme - * <a href="http://www.iso.org/iso/iso_catalogue/catalogue_ics/catalogue_detail_ics.htm?csnumber=22109&ICS1=1&ICS2=140&ICS3=20"><code>ISO 639-1:1998 (ICS n° 01.140.20)</code></a>. - * <p/> - * <a href="http://www.loc.gov/standards/iso639-2/php/French_list.php">la liste des codes</a> - * - * @author chemit - */ - -public enum LanguageEnum { - aa, // Afar - ab, // Abkhazian - af, // Afrikaans - am, // Amharic - ar, // Arabic - as, // Assamese - ay, // Aymara - az, // Azerbaijani - ba, // Bashkir - be, // Byelorussian - bg, // Bulgarian - bh, // Bihari - bi, // Bislama - bn, // Bengali; Bangla - bo, // Tibetan - br, // Breton - ca, // Catalan - co, // Corsican - cs, // Czech - cy, // Welsh - da, // Danish - de, // German - dz, // Bhutani - el, // Greek - en, // English - eo, // Esperanto - es, // Spanish - et, // Estonian - eu, // Basque - fa, // Persian - fi, // Finnish - fj, // Fiji - fo, // Faroese - fr, // French - fy, // Frisian - ga, // Irish - gd, // Scots Gaelic - gl, // Galician - gn, // Guarani - gu, // Gujarati - ha, // Hausa - he, // Hebrew (formerly iw) - hi, // Hindi - hr, // Croatian - hu, // Hungarian - hy, // Armenian - ia, // Interlingua - id, // Indonesian (formerly in) - ie, // Interlingue - ik, // Inupiak - is, // Icelandic - it, // Italian - iu, // Inuktitut - ja, // Japanese - jw, // Javanese - ka, // Georgian - kk, // Kazakh - kl, // Greenlandic - km, // Cambodian - kn, // Kannada - ko, // Korean - ks, // Kashmiri - ku, // Kurdish - ky, // Kirghiz - la, // Latin - ln, // Lingala - lo, // Laothian - lt, // Lithuanian - lv, // Latvian, Lettish - mg, // Malagasy - mi, // Maori - mk, // Macedonian - ml, // Malayalam - mn, // Mongolian - mo, // Moldavian - mr, // Marathi - ms, // Malay - mt, // Maltese - my, // Burmese - na, // Nauru - ne, // Nepali - nl, // Dutch - no, // Norwegian - oc, // Occitan - om, // (Afan) Oromo - or, // Oriya - pa, // Punjabi - pl, // Polish - ps, // Pashto, Pushto - pt, // Portuguese - qu, // Quechua - rm, // Rhaeto-Romance - rn, // Kirundi - ro, // Romanian - ru, // Russian - rw, // Kinyarwanda - sa, // Sanskrit - sd, // Sindhi - sg, // Sangho - sh, // Serbo-Croatian - si, // Sinhalese - sk, // Slovak - sl, // Slovenian - sm, // Samoan - sn, // Shona - so, // Somali - sq, // Albanian - sr, // Serbian - ss, // Siswati - st, // Sesotho - su, // Sundanese - sv, // Swedish - sw, // Swahili - ta, // Tamil - te, // Telugu - tg, // Tajik - th, // Thai - ti, // Tigrinya - tk, // Turkmen - tl, // Tagalog - tn, // Setswana - to, // Tonga - tr, // Turkish - ts, // Tsonga - tt, // Tatar - tw, // Twi - ug, // Uighur - uk, // Ukrainian - ur, // Urdu - uz, // Uzbek - vi, // Vietnamese - vo, // Volapuk - wo, // Wolof - xh, // Xhosa - yi, // Yiddish (formerly ji) - yo, // Yoruba - za, // Zhuang - zh, // Chinese - zu; // Zulu - - public static LanguageEnum valueOf(String language, LanguageEnum defaultValue) { - LanguageEnum languageValue = null; - try { - languageValue = LanguageEnum.valueOf(language.toLowerCase()); - } catch (IllegalArgumentException e) { - System.err.println(_("lutinutil.error.i18n.unfound.language", language, defaultValue)); - } catch (NullPointerException e) { - System.err.println(_("lutinutil.error.i18n.unfound.language", language, defaultValue)); - } - return languageValue == null ? defaultValue : languageValue; - } - - -} Modified: nuitonutil/trunk/src/main/java/org/codelutin/i18n/LocaleEditor.java =================================================================== --- nuitonutil/trunk/src/main/java/org/codelutin/i18n/LocaleEditor.java 2009-05-14 05:18:40 UTC (rev 1543) +++ nuitonutil/trunk/src/main/java/org/codelutin/i18n/LocaleEditor.java 2009-05-14 05:19:13 UTC (rev 1544) @@ -26,7 +26,7 @@ * use the static method to have an instance of editor {@link #newEditor(java.util.Locale[])} * <p/> * If no locale is given to this method, it will go and seek via - * {@link org.codelutin.i18n.bundle.I18nBundleManager#getLocales()} all loaded locales in i18n system + * {@link org.codelutin.i18n.I18nLoader#getLocales()} all loaded locales in i18n system * * @author chemit */ Deleted: nuitonutil/trunk/src/main/java/org/codelutin/util/LocaleConverter.java =================================================================== --- nuitonutil/trunk/src/main/java/org/codelutin/util/LocaleConverter.java 2009-05-14 05:18:40 UTC (rev 1543) +++ nuitonutil/trunk/src/main/java/org/codelutin/util/LocaleConverter.java 2009-05-14 05:19:13 UTC (rev 1544) @@ -1,122 +0,0 @@ -/* - * *##% Lutin utilities library - * Copyright (C) 2004 - 2009 CodeLutin - * - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */ - -package org.codelutin.util; - -import org.apache.commons.beanutils.ConversionException; -import org.apache.commons.beanutils.Converter; -import static org.apache.commons.logging.LogFactory.getLog; -import org.codelutin.i18n.CountryEnum; -import org.codelutin.i18n.LanguageEnum; - -import java.util.Locale; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * classe pour convertir une chaine en un objet {@link java.util.Locale}. - * - * @author chemit - */ -public class LocaleConverter implements Converter { - - private static final Pattern FULL_SCOPE_PATTERN = Pattern.compile("([a-zA-Z]{2})_([a-zA-Z]{2})"); - - private static final Pattern MEDIUM_SCOPE_PATTERN = Pattern.compile("([a-zA-Z]{2})"); - - /** to use log facility, just put in your code: log.info(\"...\"); */ - static org.apache.commons.logging.Log log = getLog(LocaleConverter.class); - - public Object convert(Class aClass, Object value) { - if (value == null) { - throw new ConversionException("can not convert null value in " + this + " convertor"); - } - if (isEnabled(aClass)) { - Object result; - if (isEnabled(value.getClass())) { - result = value; - return result; - } - if (value instanceof String) { - result = valueOf(((String) value).trim()); - return result; - } - } - throw new ConversionException("could not find a convertor for type " + aClass.getName() + " and value : " + value); - } - - protected Locale valueOf(String value) { - try { - Locale result = convertFullScope(value); - - if (result == null) { - result = convertMediumScope(value); - } - - if (result == null) { - throw new ConversionException("could not convert locale " + value); - } - - return result; - } catch (Exception e) { - throw new ConversionException("could not convert locale " + value + " for reason " + e.getMessage()); - } - } - - private Locale convertFullScope(String value) { - Matcher m = FULL_SCOPE_PATTERN.matcher(value); - if (m.matches()) { - // found a full scope pattern (language + country) - LanguageEnum language = LanguageEnum.valueOf(m.group(1).toLowerCase()); - CountryEnum country = CountryEnum.valueOf(m.group(2).toUpperCase()); - if (language == null || country == null) { - // not safe - throw new ConversionException("could not convert locale " + value); - } - return new Locale(language.name(), country.name()); - } - return null; - } - - private Locale convertMediumScope(String value) { - Matcher m = MEDIUM_SCOPE_PATTERN.matcher(value); - if (m.matches()) { - // found a medium scope pattern (only language) - LanguageEnum language = LanguageEnum.valueOf(m.group(1).toLowerCase()); - - if (language == null) { - // not safe - throw new ConversionException("could not convert locale " + value); - } - return new Locale(language.name()); - } - return null; - } - - - public LocaleConverter() { - if (log.isDebugEnabled()) { - log.debug(this); - } - } - - protected boolean isEnabled(Class aClass) { - return aClass == Locale.class; - } - -} Deleted: nuitonutil/trunk/src/main/resources/i18n/lutinutil-en_GB.properties =================================================================== --- nuitonutil/trunk/src/main/resources/i18n/lutinutil-en_GB.properties 2009-05-14 05:18:40 UTC (rev 1543) +++ nuitonutil/trunk/src/main/resources/i18n/lutinutil-en_GB.properties 2009-05-14 05:19:13 UTC (rev 1544) @@ -1,34 +0,0 @@ -hello\ you\ \!=hello you \! -lutinutil.debug.objectutil.create=Try to create %s with %s -lutinutil.debug.objectutil.instantiate=Can't instantiate %s with params %s -lutinutil.debug.objectutil.invoke=Invoke %s with %s -lutinutil.error.add.url.in.classloader=Can't add url in classloader %1$s for reason %2$s -lutinutil.error.applicationconfig.save=Can't save config in file %s -lutinutil.error.convert.file.to.url=Can't convert %s for reason %s -lutinutil.error.convertor.noValue=No value specified for converter %s -lutinutil.error.get.url.from.zip=Error while reading %s \: %s -lutinutil.error.i18n.unformated.message=Message can't be formatted\: '%s' with arguments %s -lutinutil.error.i18n.unfound.country=could not find country from '%s', use default country '%s' -lutinutil.error.i18n.unfound.language=could not find language from '%s', use default language '%s' -lutinutil.error.i18n.untranslated.message=Message can't be translated\: '%s' -lutinutil.error.no.convertor=no convertor found for type %2$s and objet '%1$s' -lutinutil.error.resource.not.found=Can't find resource \: %s -lutinutil.error.unfound.month=could not found month from '%s', use default month '%s' -lutinutil.error.unknown.url.type=could not treate unknown type of url %1$s -lutinutil.error.url.convertor=a problem occurs while converting value '%s' with url convertor %s for reason %s -lutinutil.fileCompletion.cancel=.. to cancel or return to parent directory -lutinutil.fileCompletion.enter=Enter to display file list, or to complete path -lutinutil.fileCompletion.exit=Enter "\!q" to exit -lutinutil.fileCompletion.save=Enter "\!s" in the end of the file name to save -lutinutil.month.april=april -lutinutil.month.august=august -lutinutil.month.december=december -lutinutil.month.february=february -lutinutil.month.january=january -lutinutil.month.july=july -lutinutil.month.june=june -lutinutil.month.march=march -lutinutil.month.may=may -lutinutil.month.november=november -lutinutil.month.october=october -lutinutil.month.september=september Deleted: nuitonutil/trunk/src/main/resources/i18n/lutinutil-fr_FR.properties =================================================================== --- nuitonutil/trunk/src/main/resources/i18n/lutinutil-fr_FR.properties 2009-05-14 05:18:40 UTC (rev 1543) +++ nuitonutil/trunk/src/main/resources/i18n/lutinutil-fr_FR.properties 2009-05-14 05:19:13 UTC (rev 1544) @@ -1,34 +0,0 @@ -hello\ you\ \!= -lutinutil.debug.objectutil.create=Essaye de cr\u00E9er %s avec %s -lutinutil.debug.objectutil.instantiate=Ne peut pas instancier %s avec les param\u00EAtres %s -lutinutil.debug.objectutil.invoke=Invocation de %s avec %s -lutinutil.error.add.url.in.classloader=Impossible d'ajouter une url dans le classloader %s pour la raison \: %s -lutinutil.error.applicationconfig.save=Impossible de sauvegarder le fichier de configuration dans %s -lutinutil.error.convert.file.to.url=Le fichier '%1$s' n'a pas pu \u00EAtre converti en URL pour la raison suivante \: %2$S -lutinutil.error.convertor.noValue=Aucune valeur \u00E0 convertir pour le convertisseur %s -lutinutil.error.get.url.from.zip=Erreur lors de la lecture du fichier compress\u00E9 %1$s \: %2$s -lutinutil.error.i18n.unformated.message=Le message suivant n''a pas pu \u00EAtre format\u00E9 \: '%s' avec les arguments %s -lutinutil.error.i18n.unfound.country=n'a pas pu trouver le pays \u00E0 partir de '%s', utilise le pays par d\u00E9faut '%s' -lutinutil.error.i18n.unfound.language=n'a pas pu trouver la langue \u00E0 partir de '%s', utilise la langue par d\u00E9faut '%s' -lutinutil.error.i18n.untranslated.message=Le message suivant n'a pas pu \u00EAtre traduit \: '%s' -lutinutil.error.no.convertor=Aucun convertisseur trouv\u00E9 pour le type %2$s et l''objet '%1$s' -lutinutil.error.resource.not.found=Impossible de trouver la ressource \: %s -lutinutil.error.unfound.month=n'a pas pu trouv\u00E9 le mois \u00E0 partir de '%s', utilise le mois par d\u00E9faut '%s' -lutinutil.error.unknown.url.type=could not treate unknown type of url %1$s -lutinutil.error.url.convertor=Un probl\u00E8me est apparu lors de la convertion en url de '%s' avec le convertisseur %s pour la raison suivante \: %s -lutinutil.fileCompletion.cancel=.. pour annuler ou pour revenir au repertoire pr\u00E9c\u00E9dent -lutinutil.fileCompletion.enter=Entrer pour afficher la liste des fichiers, ou pour compl\u00E9ter le chemin -lutinutil.fileCompletion.exit=Saisir "\!q" pour quitter -lutinutil.fileCompletion.save=Saisir "\!s" a la fin du nom de fichier pour l'enregistrer -lutinutil.month.april=avril -lutinutil.month.august=ao\u00FBt -lutinutil.month.december=d\u00E9cembre -lutinutil.month.february=f\u00E9vrier -lutinutil.month.january=janvier -lutinutil.month.july=juillet -lutinutil.month.june=juin -lutinutil.month.march=mars -lutinutil.month.may=mai -lutinutil.month.november=novembre -lutinutil.month.october=octobre -lutinutil.month.september=septembre Copied: nuitonutil/trunk/src/main/resources/i18n/nuitonutil-en_GB.properties (from rev 1537, nuitonutil/trunk/src/main/resources/i18n/lutinutil-en_GB.properties) =================================================================== --- nuitonutil/trunk/src/main/resources/i18n/nuitonutil-en_GB.properties (rev 0) +++ nuitonutil/trunk/src/main/resources/i18n/nuitonutil-en_GB.properties 2009-05-14 05:19:13 UTC (rev 1544) @@ -0,0 +1,34 @@ +hello\ you\ \!=hello you \! +lutinutil.debug.objectutil.create=Try to create %s with %s +lutinutil.debug.objectutil.instantiate=Can't instantiate %s with params %s +lutinutil.debug.objectutil.invoke=Invoke %s with %s +lutinutil.error.add.url.in.classloader=Can't add url in classloader %1$s for reason %2$s +lutinutil.error.applicationconfig.save=Can't save config in file %s +lutinutil.error.convert.file.to.url=Can't convert %s for reason %s +lutinutil.error.convertor.noValue=No value specified for converter %s +lutinutil.error.get.url.from.zip=Error while reading %s \: %s +lutinutil.error.i18n.unformated.message=Message can't be formatted\: '%s' with arguments %s +lutinutil.error.i18n.unfound.country=could not find country from '%s', use default country '%s' +lutinutil.error.i18n.unfound.language=could not find language from '%s', use default language '%s' +lutinutil.error.i18n.untranslated.message=Message can't be translated\: '%s' +lutinutil.error.no.convertor=no convertor found for type %2$s and objet '%1$s' +lutinutil.error.resource.not.found=Can't find resource \: %s +lutinutil.error.unfound.month=could not found month from '%s', use default month '%s' +lutinutil.error.unknown.url.type=could not treate unknown type of url %1$s +lutinutil.error.url.convertor=a problem occurs while converting value '%s' with url convertor %s for reason %s +lutinutil.fileCompletion.cancel=.. to cancel or return to parent directory +lutinutil.fileCompletion.enter=Enter to display file list, or to complete path +lutinutil.fileCompletion.exit=Enter "\!q" to exit +lutinutil.fileCompletion.save=Enter "\!s" in the end of the file name to save +lutinutil.month.april=april +lutinutil.month.august=august +lutinutil.month.december=december +lutinutil.month.february=february +lutinutil.month.january=january +lutinutil.month.july=july +lutinutil.month.june=june +lutinutil.month.march=march +lutinutil.month.may=may +lutinutil.month.november=november +lutinutil.month.october=october +lutinutil.month.september=september Property changes on: nuitonutil/trunk/src/main/resources/i18n/nuitonutil-en_GB.properties ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:mergeinfo + Name: svn:eol-style + native Copied: nuitonutil/trunk/src/main/resources/i18n/nuitonutil-fr_FR.properties (from rev 1537, nuitonutil/trunk/src/main/resources/i18n/lutinutil-fr_FR.properties) =================================================================== --- nuitonutil/trunk/src/main/resources/i18n/nuitonutil-fr_FR.properties (rev 0) +++ nuitonutil/trunk/src/main/resources/i18n/nuitonutil-fr_FR.properties 2009-05-14 05:19:13 UTC (rev 1544) @@ -0,0 +1,34 @@ +hello\ you\ \!= +lutinutil.debug.objectutil.create=Essaye de cr\u00E9er %s avec %s +lutinutil.debug.objectutil.instantiate=Ne peut pas instancier %s avec les param\u00EAtres %s +lutinutil.debug.objectutil.invoke=Invocation de %s avec %s +lutinutil.error.add.url.in.classloader=Impossible d'ajouter une url dans le classloader %s pour la raison \: %s +lutinutil.error.applicationconfig.save=Impossible de sauvegarder le fichier de configuration dans %s +lutinutil.error.convert.file.to.url=Le fichier '%1$s' n'a pas pu \u00EAtre converti en URL pour la raison suivante \: %2$S +lutinutil.error.convertor.noValue=Aucune valeur \u00E0 convertir pour le convertisseur %s +lutinutil.error.get.url.from.zip=Erreur lors de la lecture du fichier compress\u00E9 %1$s \: %2$s +lutinutil.error.i18n.unformated.message=Le message suivant n''a pas pu \u00EAtre format\u00E9 \: '%s' avec les arguments %s +lutinutil.error.i18n.unfound.country=n'a pas pu trouver le pays \u00E0 partir de '%s', utilise le pays par d\u00E9faut '%s' +lutinutil.error.i18n.unfound.language=n'a pas pu trouver la langue \u00E0 partir de '%s', utilise la langue par d\u00E9faut '%s' +lutinutil.error.i18n.untranslated.message=Le message suivant n'a pas pu \u00EAtre traduit \: '%s' +lutinutil.error.no.convertor=Aucun convertisseur trouv\u00E9 pour le type %2$s et l''objet '%1$s' +lutinutil.error.resource.not.found=Impossible de trouver la ressource \: %s +lutinutil.error.unfound.month=n'a pas pu trouv\u00E9 le mois \u00E0 partir de '%s', utilise le mois par d\u00E9faut '%s' +lutinutil.error.unknown.url.type=could not treate unknown type of url %1$s +lutinutil.error.url.convertor=Un probl\u00E8me est apparu lors de la convertion en url de '%s' avec le convertisseur %s pour la raison suivante \: %s +lutinutil.fileCompletion.cancel=.. pour annuler ou pour revenir au repertoire pr\u00E9c\u00E9dent +lutinutil.fileCompletion.enter=Entrer pour afficher la liste des fichiers, ou pour compl\u00E9ter le chemin +lutinutil.fileCompletion.exit=Saisir "\!q" pour quitter +lutinutil.fileCompletion.save=Saisir "\!s" a la fin du nom de fichier pour l'enregistrer +lutinutil.month.april=avril +lutinutil.month.august=ao\u00FBt +lutinutil.month.december=d\u00E9cembre +lutinutil.month.february=f\u00E9vrier +lutinutil.month.january=janvier +lutinutil.month.july=juillet +lutinutil.month.june=juin +lutinutil.month.march=mars +lutinutil.month.may=mai +lutinutil.month.november=novembre +lutinutil.month.october=octobre +lutinutil.month.september=septembre Property changes on: nuitonutil/trunk/src/main/resources/i18n/nuitonutil-fr_FR.properties ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:mergeinfo + Name: svn:eol-style + native Modified: nuitonutil/trunk/src/test/java/org/codelutin/i18n/bundle/I18nBundleManagerTest.java =================================================================== --- nuitonutil/trunk/src/test/java/org/codelutin/i18n/bundle/I18nBundleManagerTest.java 2009-05-14 05:18:40 UTC (rev 1543) +++ nuitonutil/trunk/src/test/java/org/codelutin/i18n/bundle/I18nBundleManagerTest.java 2009-05-14 05:19:13 UTC (rev 1544) @@ -210,12 +210,12 @@ @Test public void testGetURLs() throws Exception { - Assert.assertEquals(getNbURLs(), I18nBundleFactory.getURLs(loader).length); + Assert.assertEquals(getNbURLs(), I18nLoader.getURLs(loader).length); } @Test public void testDetectBundles() throws Exception { - URL[] urls = I18nBundleFactory.getURLs(loader); + URL[] urls = I18nLoader.getURLs(loader); Assert.assertEquals(BundleTest.values().length, I18nBundleFactory.detectBundles(urls).size()); } Deleted: nuitonutil/trunk/src/test/java/org/codelutin/i18n/bundle/I18nBunsleScopeTest.java =================================================================== --- nuitonutil/trunk/src/test/java/org/codelutin/i18n/bundle/I18nBunsleScopeTest.java 2009-05-14 05:18:40 UTC (rev 1543) +++ nuitonutil/trunk/src/test/java/org/codelutin/i18n/bundle/I18nBunsleScopeTest.java 2009-05-14 05:19:13 UTC (rev 1544) @@ -1,63 +0,0 @@ -/** - * *##% Lutin utilities library - * Copyright (C) 2004 - 2008 CodeLutin - * - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* - */ -package org.codelutin.i18n.bundle; - -import org.junit.Assert; -import org.junit.Test; - -import java.util.Locale; - -/** @author chemit */ -public class I18nBunsleScopeTest { - - Locale locale; - I18nBundleScope excepted; - - @Test - public void testFullScope() { - excepted = I18nBundleScope.FULL; - - locale = new Locale("fr", "FR"); - Assert.assertEquals(excepted, I18nBundleScope.valueOf(locale)); - } - - @Test - public void testLanguageScope() { - excepted = I18nBundleScope.LANGUAGE; - - locale = new Locale("fr"); - Assert.assertEquals(excepted, I18nBundleScope.valueOf(locale)); - - locale = new Locale("fr", ""); - Assert.assertEquals(excepted, I18nBundleScope.valueOf(locale)); - } - - @Test - public void testGeneralScope() { - - excepted = I18nBundleScope.GENERAL; - - locale = null; - Assert.assertEquals(excepted, I18nBundleScope.valueOf(locale)); - - locale = new Locale(""); - Assert.assertEquals(excepted, I18nBundleScope.valueOf(locale)); - } - -} Deleted: nuitonutil/trunk/src/test/java/org/codelutin/util/LocaleConverterTest.java =================================================================== --- nuitonutil/trunk/src/test/java/org/codelutin/util/LocaleConverterTest.java 2009-05-14 05:18:40 UTC (rev 1543) +++ nuitonutil/trunk/src/test/java/org/codelutin/util/LocaleConverterTest.java 2009-05-14 05:19:13 UTC (rev 1544) @@ -1,124 +0,0 @@ -/** - * *##% Lutin utilities library - * Copyright (C) 2004 - 2008 CodeLutin - * - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* - */ -package org.codelutin.util; - -import junit.framework.TestCase; -import org.apache.commons.beanutils.Converter; - -import java.util.Locale; - -/** @author chemit */ -public class LocaleConverterTest extends TestCase { - - String toConvert; - Locale excepted; - Converter converter; - - @Override - protected void setUp() throws Exception { - super.setUp(); - converter = ConverterUtil.getConverter(Locale.class); - } - - public void testConvertFull() throws Exception { - toConvert = "fr_FR"; - excepted = Locale.FRANCE; - assertEquals(toConvert, excepted); - - toConvert = "fr_fr"; - assertEquals(toConvert, excepted); - - toConvert = "FR_fr"; - assertEquals(toConvert, excepted); - - toConvert = "FR_FR"; - assertEquals(toConvert, excepted); - - toConvert = "\n\tFr_fR "; - assertEquals(toConvert, excepted); - - toConvert = "en_GB"; - excepted = Locale.UK; - assertEquals(toConvert, excepted); - - toConvert = "en_US"; - excepted = Locale.US; - assertEquals(toConvert, excepted); - - //TODO Arch, we must also check coherence ! - toConvert = "fr_GB"; - excepted = new Locale("fr","GB"); - assertEquals(toConvert, excepted); - } - - public void testConvertMedium() throws Exception { - toConvert = "fr"; - excepted = new Locale("fr"); - assertEquals(toConvert, excepted); - - toConvert = "fR"; - assertEquals(toConvert, excepted); - - toConvert = "FR"; - assertEquals(toConvert, excepted); - - toConvert = " fR \t"; - assertEquals(toConvert, excepted); - - toConvert = "en"; - excepted = new Locale("en"); - assertEquals(toConvert, excepted); - - toConvert = "es"; - excepted = new Locale("es"); - assertEquals(toConvert, excepted); - - } - - public void testConvertFailed() throws Exception { - - toConvert = null; - assertConvertFailed(toConvert); - - toConvert = ""; - assertConvertFailed(toConvert); - - toConvert = "fr_"; - assertConvertFailed(toConvert); - - toConvert = "_FR"; - assertConvertFailed(toConvert); - - } - - protected void assertEquals(String toConvert, Locale expected) { - Object result = converter.convert(Locale.class, toConvert); - assertEquals(expected, result); - } - - protected void assertConvertFailed(String toConvert) { - try { - converter.convert(Locale.class, toConvert); - fail(); - } catch (Exception e) { - assertTrue(true); - } - - } -}
participants (1)
-
tchemit@users.labs.libre-entreprise.org