From 0332e042d8d8730da8185349598427570d0b85bf Mon Sep 17 00:00:00 2001 From: trifonnt Date: Mon, 30 Apr 2007 14:23:01 +0000 Subject: [PATCH] Contribution from Jordi Luna - recavap 1709787 New & Old (fixed) Localizations for Spain & Catalonia https://sourceforge.net/tracker/index.php?func=detail&aid=1709787&group_id=176962&atid=883808 --- dbPort/src/org/compiere/db/DBRes_ca.java | 26 +- dbPort/src/org/compiere/db/DBRes_es.java | 26 +- .../src/org/compiere/util/AmtInWords_CA.java | 233 ++++++++++++++++++ .../src/org/compiere/util/AmtInWords_ES.java | 12 +- 4 files changed, 268 insertions(+), 29 deletions(-) create mode 100644 dbPort/src/org/compiere/util/AmtInWords_CA.java diff --git a/dbPort/src/org/compiere/db/DBRes_ca.java b/dbPort/src/org/compiere/db/DBRes_ca.java index 86fa6f6c25..f83128007c 100644 --- a/dbPort/src/org/compiere/db/DBRes_ca.java +++ b/dbPort/src/org/compiere/db/DBRes_ca.java @@ -22,36 +22,36 @@ import java.util.*; * Connection Resource Strings * * @author Jaume Teixi + * @author Jordi Luna * @version $Id: DBRes_ca.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $ */ public class DBRes_ca extends ListResourceBundle { /** Data */ - static final Object[][] contents = new String[][] - { - { "CConnectionDialog", "Connexi� Adempiere" }, + static final Object[][] contents = new String[][]{ + { "CConnectionDialog", "Connexi\u00f3 Adempiere" }, { "Name", "Nom" }, - { "AppsHost", "Servidor Aplicaci�" }, - { "AppsPort", "Port Aplicaci�" }, - { "TestApps", "Provar Aplicaci�" }, + { "AppsHost", "Servidor Aplicaci\u00f3" }, + { "AppsPort", "Port Aplicaci\u00f3" }, + { "TestApps", "Provar Servidor Aplicaci\u00f3" }, { "DBHost", "Servidor Base de Dades" }, { "DBPort", "Port Base de Dades" }, { "DBName", "Nom Base de Dades" }, { "DBUidPwd", "Usuari / Contrasenya" }, - { "ViaFirewall", "via Tallafocs" }, - { "FWHost", "Servidor Tallafocs" }, - { "FWPort", "Port Tallafocs" }, + { "ViaFirewall", "via Firewall" }, + { "FWHost", "Servidor Firewall" }, + { "FWPort", "Port Firewall" }, { "TestConnection", "Provar Base de Dades" }, { "Type", "Tipus Base de Dades" }, - { "BequeathConnection", "Delegar Connexi�" }, + { "BequeathConnection", "Delegar Connexi\u00f3" }, { "Overwrite", "Sobrescriure" }, - { "ConnectionProfile", "Connection" }, + { "ConnectionProfile", "Connexi\u00f3" }, { "LAN", "LAN" }, { "TerminalServer", "Terminal Server" }, { "VPN", "VPN" }, { "WAN", "WAN" }, - { "ConnectionError", "Error Connexi�" }, - { "ServerNotActive", "Servidor No Actiu" } + { "ConnectionError", "Error Connexi\u00f3" }, + { "ServerNotActive", "Servidor no Actiu" } }; /** diff --git a/dbPort/src/org/compiere/db/DBRes_es.java b/dbPort/src/org/compiere/db/DBRes_es.java index 5263f15685..f1c446567a 100644 --- a/dbPort/src/org/compiere/db/DBRes_es.java +++ b/dbPort/src/org/compiere/db/DBRes_es.java @@ -22,31 +22,37 @@ import java.util.*; * Connection Resource Strings * * @author Erwin Cortes + * @author Jordi Luna * @version $Id: DBRes_es.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $ */ public class DBRes_es extends ListResourceBundle { /** Data */ static final Object[][] contents = new String[][]{ - { "CConnectionDialog", "Conexión ADempiere" }, + { "CConnectionDialog", "Conexi\u00f3n ADempiere" }, { "Name", "Nombre" }, - { "AppsHost", "Servidor de Aplicación" }, - { "AppsPort", "Puerto de Aplicación" }, - { "TestApps", "Test de Aplicación" }, + { "AppsHost", "Servidor de Aplicaci\u00f3n" }, + { "AppsPort", "Puerto de Aplicaci\u00f3n" }, + { "TestApps", "Test de Aplicaci\u00f3n" }, { "DBHost", "Host de Base de Datos" }, { "DBPort", "Puerto de Base de Datos" }, { "DBName", "Nombre de Base de datos" }, - { "DBUidPwd", "Usuario / Contraseña" }, - { "ViaFirewall", "vía Firewall" }, + { "DBUidPwd", "Usuario / Contrase\u00f1a" }, + { "ViaFirewall", "v\u00eda Firewall" }, { "FWHost", "Servidor de Firewall" }, { "FWPort", "Puerto del Firewall" }, { "TestConnection", "Test de Base de datos" }, { "Type", "Tipo de Base de Datos" }, - { "BequeathConnection", "Conexión Heredada" }, + { "BequeathConnection", "Delegar Conexi\u00f3n" }, { "Overwrite", "Sobreescribir" }, - { "RMIoverHTTP", "Tunelizar Objetos vía HTTP" }, - { "ConnectionError", "Error en conexión" }, - { "ServerNotActive", "Servidor inactivo" }}; + { "ConnectionProfile", "Conexi\u00f3n" }, + { "LAN", "LAN" }, + { "TerminalServer", "Terminal Server" }, + { "VPN", "VPN" }, + { "WAN", "WAN" }, + { "ConnectionError", "Error Conexi\u00f3n" }, + { "ServerNotActive", "Servidor no Activo" } + }; /** * Get Contsnts diff --git a/dbPort/src/org/compiere/util/AmtInWords_CA.java b/dbPort/src/org/compiere/util/AmtInWords_CA.java new file mode 100644 index 0000000000..42cbd03238 --- /dev/null +++ b/dbPort/src/org/compiere/util/AmtInWords_CA.java @@ -0,0 +1,233 @@ +/****************************************************************************** + * Product: Adempiere ERP & CRM Smart Business Solution * + * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. 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 Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + * For the text or an alternative of this public license, you may reach us * + * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * + * or via info@compiere.org or http://www.compiere.org/license.html * + *****************************************************************************/ +package org.compiere.util; + +/** + * Spanish Amount in Words + * + * @author Jordi Luna + * @version $Id: AmtInWords_CA.java,v 1.3 2006/07/30 00:54:36 jjanke Exp $ + */ +public class AmtInWords_CA implements AmtInWords +{ + /** + * AmtInWords_CA + */ + public AmtInWords_CA () + { + super (); + } // AmtInWords_CA + + private static final String[] majorNames = { + "", + " MIL", + " MILI\u00d3", + " BILI\u00d3", + " TRILI\u00d3", + " QUATRILI\u00d3", + " QUINTILI\u00d3N" + }; + + private static final String[] tensNames = { + "", + " DEU", + " VINT", + " TRENTA", + " QUARANTA", + " CINQUANTA", + " SEIXANTA", + " SETANTA", + " VUITANTA", + " NORANTA" + }; + + private static final String[] numNames = { + "", + " UN", + " DOS", + " TRES", + " QUATRE", + " CINC", + " SIS", + " SET", + " VUIT", + " NOU", + " DEU", + " ONCE", + " DOTZE", + " TRETZE", + " CATORZE", + " QUINZE", + " SETZE", + " DISSET", + " DIVUIT", + " DINOU" + }; + + /** + * Convert Less Than One Thousand + * @param number + * @return amt + */ + private String convertLessThanOneThousand (int number) + { + String soFar; + // Esta dentro de los 1os. diecinueve?? ISCAP + if (number % 100 < 20) + { + soFar = numNames[number % 100]; + number /= 100; + } + else + { + soFar = numNames[number % 10]; + number /= 10; + String s = Integer.toString (number); + if (s.endsWith ("2") && !soFar.equals("")) + soFar = " VINT-I-" + soFar.trim (); + else if (soFar.equals("")) + soFar = tensNames[number % 10] + soFar; + else + soFar = tensNames[number % 10] + "-" + soFar; + number /= 10; + } + if (number == 0) + //return soFar; + // Begin e-Evolution ogi-cd + return tensNames[number % 10] + soFar; // e-Evolution ogi-cd + // End e-Evolution ogi-cd + if (number > 1) + soFar = "S" + soFar; + if (number == 1 && !soFar.equals("")) + number = 0; + return numNames[number] + " CENT" + soFar; + } // convertLessThanOneThousand + + /** + * Convert + * @param number + * @return amt + */ + private String convert (int number) + { + /* special case */ + if (number == 0) + return "ZERO"; + String prefix = ""; + if (number < 0) + { + number = -number; + prefix = "MENYS"; + } + String soFar = ""; + int place = 0; + do + { + int n = number % 1000; + if (n != 0) + { + String s = convertLessThanOneThousand (n); + if (s.startsWith ("DOS CENTS", 1)) + { + s = s.replaceFirst ("DOS CENTS", "DOS-CENTS"); + } + if (s.startsWith ("TRES CENTS", 1)) + { + s = s.replaceFirst ("TRES CENTS", "TRES-CENTS"); + } + if (s.startsWith ("QUATRE CENTS", 1)) + { + s = s.replaceFirst ("QUATRE CENTS", "QUATRE-CENTS"); + } + if (s.startsWith ("CINC CENTS", 1)) + { + s = s.replaceFirst ("CINC CENTS", "CINC-CENTS"); + } + if (s.startsWith ("SIS CENTS", 1)) + { + s = s.replaceFirst ("SIS CENTS", "SIS-CENTS"); + } + if (s.startsWith ("SET CENTS", 1)) + { + s = s.replaceFirst ("SET CENTS", "SET-CENTS"); + } + if (s.startsWith ("VUIT CENTS", 1)) + { + s = s.replaceFirst ("VUIT CENTS", "VUIT-CENTS"); + } + if (s.startsWith ("NOU CENTS", 1)) + { + s = s.replaceFirst ("NOU CENTS", "NOU-CENTS"); + } + if (s.equals(" UN")) + { + soFar = majorNames[place] + soFar; + } + else + soFar = s + majorNames[place] + soFar; + } + place++; + number /= 1000; + } + while (number > 0); + return (prefix + soFar).trim (); + } // convert + + + /************************************************************************** + * Get Amount in Words + * @param amount numeric amount (352.80) + * @return amount in words (three*five*two 80/100) + * @throws Exception + */ + public String getAmtInWords (String amount) throws Exception + { + if (amount == null) + return amount; + // + StringBuffer sb = new StringBuffer (); + // int pos = amount.lastIndexOf ('.'); // Old + int pos = amount.lastIndexOf (','); + // int pos2 = amount.lastIndexOf (','); // Old + int pos2 = amount.lastIndexOf ('.'); + if (pos2 > pos) + pos = pos2; + String oldamt = amount; + + // amount = amount.replaceAll (",", ""); // Old + amount = amount.replaceAll( "\\.",""); + + // int newpos = amount.lastIndexOf ('.'); // Old + int newpos = amount.lastIndexOf (','); + int pesos = Integer.parseInt (amount.substring (0, newpos)); + sb.append (convert (pesos)); + for (int i = 0; i < oldamt.length (); i++) + { + if (pos == i) // we are done + { + String cents = oldamt.substring (i + 1); + sb.append (' ') + .append (cents) + .append ("/100"); + // .append ("/100 EUROS"); + break; + } + } + return sb.toString (); + } // getAmtInWords + +} // AmtInWords_CA diff --git a/dbPort/src/org/compiere/util/AmtInWords_ES.java b/dbPort/src/org/compiere/util/AmtInWords_ES.java index 7fd25cdcf7..9587246678 100644 --- a/dbPort/src/org/compiere/util/AmtInWords_ES.java +++ b/dbPort/src/org/compiere/util/AmtInWords_ES.java @@ -35,11 +35,11 @@ public class AmtInWords_ES implements AmtInWords private static final String[] majorNames = { "", " MIL", - " MILLON", - " BILLON", - " TRILLON", - " CUATRILLON", - " QUINTILLON" + " MILL\u00d3N", + " BILL\u00d3N", + " TRILL\u00d3N", + " CUATRILL\u00d3N", + " QUINTILL\u00d3N" }; private static final String[] tensNames = { @@ -72,7 +72,7 @@ public class AmtInWords_ES implements AmtInWords " TRECE", " CATORCE", " QUINCE", - " DIECISEIS", + " DIECIS\u00c9IS", " DIECISIETE", " DIECIOCHO", " DIECINUEVE"