Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 480
  • Last Modified:

Currency Symbol

Hi Exports,

I have a small question, How do I get all the Regional Options language list and there currency symbols and values?
0
S_Warrior
Asked:
S_Warrior
  • 2
  • 2
1 Solution
 
kretzschmarCommented:
usual there is a bunch of variables in the sysutils-unit,
which are initilazed during app-start

see chapter
Currency and date/time formatting variables
in the delphi-help

meikl ;-)
0
 
S_WarriorAuthor Commented:
no, I need to get the complete list of the languages in the regional settings + currency symbols of every language.
0
 
kretzschmarCommented:
?? in this list are all countries of the world, except maybe some minor countries
0
 
S_WarriorAuthor Commented:
Well I need this list + I want every counter currency symbol.
0
 
Pierre CorneliusCommented:
Here's a demo:

pas:
===

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, DB, Grids, DBGrids, DBClient;

type
  TForm1 = class(TForm)
    rgOption: TRadioGroup;
    Button2: TButton;
    ClientDataSet1: TClientDataSet;
    ClientDataSet1LCID: TIntegerField;
    ClientDataSet1Language: TStringField;
    ClientDataSet1Country: TStringField;
    ClientDataSet1CurrencySymbol: TStringField;
    DBGrid1: TDBGrid;
    DataSource1: TDataSource;
    Label1: TLabel;
    ClientDataSet1currency: TStringField;
    procedure Button2Click(Sender: TObject);
    procedure DBGrid1TitleClick(Column: TColumn);
    procedure FormCreate(Sender: TObject);
  end;

var
  Form1: TForm1;
  LocaleIDs: TStringList;

implementation

{$R *.dfm}

function EnumLCIDs(LCIDStr: pchar): boolean; stdcall;
begin
  LocaleIDs.Add(StrPas(LCIDStr));
  result:= true;
end;

procedure TForm1.Button2Click(Sender: TObject);
var i: integer;
    data: array[0..63] of char;
begin
  LocaleIDs.Clear;
  case rgOption.ItemIndex of
    0: EnumSystemLocales(@EnumLCIDs, LCID_INSTALLED);
    1: EnumSystemLocales(@EnumLCIDs, LCID_SUPPORTED);
  end;

  ClientDataSet1.EmptyDataSet;
  for i:= 0 to LocaleIDs.Count-1 do
  begin
    ClientDataSet1.Append;
    ClientDataSet1LCID.Value:= StrToInt('$'+LocaleIDs[i]);

    GetLocaleInfo(StrToInt('$'+LocaleIDs[i]), LOCALE_SCOUNTRY, data, SizeOf(Data));
    ClientDataSet1Country.Value:= StrPas(data);

    GetLocaleInfo(StrToInt('$'+LocaleIDs[i]), LOCALE_SLANGUAGE, data, SizeOf(Data));
    ClientDataSet1Language.Value:= StrPas(data);

    GetLocaleInfo(StrToInt('$'+LocaleIDs[i]), LOCALE_SCURRENCY, data, SizeOf(Data));
    ClientDataSet1Currency.Value:= StrPas(data);

    GetLocaleInfo(StrToInt('$'+LocaleIDs[i]), LOCALE_SINTLSYMBOL, data, SizeOf(Data));
    ClientDataSet1CurrencySymbol.Value:= StrPas(data);

    ClientDataSet1.Post;
  end;

end;

procedure TForm1.DBGrid1TitleClick(Column: TColumn);
begin
  ClientDataSet1.IndexFieldNames:= Column.FieldName;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  ClientDataSet1.CreateDataSet;
end;

initialization
  LocaleIDs:= TStringList.Create;

finalization
  LocaleIDs.Free;

end.


DFM
===

object Form1: TForm1
  Left = 192
  Top = 114
  Width = 656
  Height = 442
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  DesignSize = (
    648
    408)
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 328
    Top = 16
    Width = 177
    Height = 13
    Caption = 'Click on a heading to sort by that field'
  end
  object rgOption: TRadioGroup
    Left = 112
    Top = 8
    Width = 161
    Height = 35
    Caption = 'LCID option'
    Columns = 2
    ItemIndex = 0
    Items.Strings = (
      'Installed'
      'Supported')
    TabOrder = 0
  end
  object Button2: TButton
    Left = 16
    Top = 8
    Width = 75
    Height = 25
    Caption = 'List/Refresh'
    TabOrder = 1
    OnClick = Button2Click
  end
  object DBGrid1: TDBGrid
    Left = 16
    Top = 48
    Width = 614
    Height = 347
    Anchors = [akLeft, akTop, akRight, akBottom]
    DataSource = DataSource1
    TabOrder = 2
    TitleFont.Charset = DEFAULT_CHARSET
    TitleFont.Color = clWindowText
    TitleFont.Height = -11
    TitleFont.Name = 'MS Sans Serif'
    TitleFont.Style = []
    OnTitleClick = DBGrid1TitleClick
  end
  object ClientDataSet1: TClientDataSet
    Aggregates = <>
    Params = <>
    Left = 240
    Top = 8
    object ClientDataSet1LCID: TIntegerField
      DisplayWidth = 12
      FieldName = 'LCID'
    end
    object ClientDataSet1Country: TStringField
      DisplayWidth = 31
      FieldName = 'Country'
      Size = 50
    end
    object ClientDataSet1Language: TStringField
      DisplayWidth = 25
      FieldName = 'Language'
      Size = 50
    end
    object ClientDataSet1currency: TStringField
      DisplayLabel = 'Currency'
      FieldName = 'currency'
      Size = 10
    end
    object ClientDataSet1CurrencySymbol: TStringField
      DisplayWidth = 15
      FieldName = 'CurrencySymbol'
      Size = 3
    end
  end
  object DataSource1: TDataSource
    DataSet = ClientDataSet1
    Left = 272
    Top = 8
  end
end

Regards
Pierre
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now