By Andy Preston, Apollo Developments, andy@anorak.org.uk, Commercial: andy@apollod.omnia.co.uk
the demo program, a good place to start.
the main unit of the demo program.
By default NumWord's will use the local language and country information obtained from Windows.
In:
Procedure TForm1.FormShow (Sender : TObject);You can un-comment this line:
InWords.SelectLocale (CTRY_AUSTRIA, LANG_GERMAN, useEuro);and experiment with other countries / languages, if you leave this line commented out, numwords will work in the user's default locale.
This is the code that set's up the local language / currency information
This is where
Procedure TNumWords.SelectLocale (CountryCode, LanguageCode : Integer; EuroMode : Boolean);can be found. If you want to add new languages you'll need to add another
LANG_XXXXX : LanguageDriver:=TNumWordsXXXXX.Create (CountryCode, EuroMode);line to this procedure
If you want to add a language driver you'll also have to add your language driver's unit name to the Implementation section's Uses clause, as with NumW_Eng, NumW_Deu, NumW_Esp, NumW_Ita in the current unit.
The base class for the language drivers.
To add support for a new country, you will need to look at:
Constructor TNumWordsLangDriver.Create (CountryCode : Integer; EuroMode : Boolean);and add some new code to the switch statement like:
CTRY_UNITED_KINGDOM : Begin CurrencyGender := genNeuter; // No gender in English BigSing := 'Pound'; BigPlural := 'Pounds'; SmallSing := 'Penny'; SmallPlural := 'Pence'; End;These variables are part of the TNumWordsLangDriver class and are used to return a currency value in words.
Function TNumWordsLangDriver.EMoneyInWords (TheAmount : Extended) : String;Isn't very well written, I'd be much happier using Marco Bianchini's code in his original bVerbose component, what do you think Marco?
These are the actual language driver classes
TNumWordsEnglish, TNumWordsDeutch, TNumWordsEspanol, TNumWordsItaliano, TNumWordsFrancais, & TNumWordsTurkish are dervied from TNumWordsLangDriver (in Numw.pas). They are the language-specific parts on NumWords
These classes override the virtual functions:
Function NumberInWords (TheNumber : Integer) : String; Function IMoneyInWords (Major, Minor : Integer) : String;These functions do the actual conversion work.
In the original source code for the non-English language drivers that has been borrowed from other programmers, there is no code for :
Function IMoneyInWords (Major, Minor : Integer) : String;this still needs to be added to NumW_Esp.pas for full Espanõl support.
Andreas Schmidt has a good idea in:
Function TNumWordsDeutch.NumberInWords (TheNumber : Integer) : String;The first line of his version of this function is:
If TheNumber<0 Then Result:='minus '+NumberInWords (-TheNumber)The same 'easy way to get negative numbers' works in English too. Can it be added to Espanõl, Français & Italiano?
Author information
User Documentation
User Licenses
This file is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This file 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 Library General Public License for more details.
You should have received a copy of the GNU Library 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.