Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DFHumanize

Delphi License: MIT Author

English | Türkçe

Make strings, dates, numbers, bytes and lists human-readable in Delphi

Author DelphiFan
Email adsdelphi@gmail.com
Version 1.0.0
Target Delphi 10.3 Rio and later (VCL)
License MIT

Features

  • Relative dates: 3 hours ago, yesterday, 2 days from now
  • String humanize: OrderStatusCodeOrder status code
  • Numbers to words (English / Turkish)
  • Byte sizes: 15360001.5 MB
  • Lists: A, B and C / A, B ve C
  • Non-visual + visual components on the DF Humanize palette
  • Cultures: hcAuto, hcEnglish, hcTurkish

Install

  1. Open Packages\DFHumanize.groupproj in Delphi.
  2. Build DFHumanize (runtime package).
  3. Build dclDFHumanize (design package).
  4. Component → Install Packages → Add
    select: Lib\Win32\Release\dclDFHumanize.bpl
  5. (Recommended) Add to Library path:
    ...\DelphiHumanizer\Lib\Win32\Release

Components appear under palette group DF Humanize.

Optional demo: Demo\DFHumanizeDemo.dproj


Components

Non-visual

Component Description
TDFHumanizer Central culture / helpers / About
TDFHumanizeDate Relative date as Text
TDFHumanizeNumber Number → words / ordinal
TDFHumanizeBytes File size text

Visual

Component Description
TDFHumanizeLabel Label with auto-refresh (dates)
TDFHumanizeStatusPanel Status strip: Last update: 12 minutes ago

Code API examples

uses
  System.SysUtils,
  System.DateUtils,
  DFHumanize,
  DFHumanize.Types;

Dates

// English
ShowMessage(Humanize.DateTime(IncHour(Now, -3), hcEnglish));
// -> 3 hours ago

ShowMessage(Humanize.DateTime(IncDay(Now, 1), hcEnglish));
// -> tomorrow

// Turkish
ShowMessage(Humanize.DateTime(IncHour(Now, -3), hcTurkish));
// -> 3 saat önce

ShowMessage(Humanize.DateTime(IncDay(Now, -1), hcTurkish));
// -> dün

// Auto = OS UI language
ShowMessage(Humanize.DateTime(IncMinute(Now, -12), hcAuto));

Strings

ShowMessage(Humanize.StringValue('OrderStatusCode'));
// -> Order status code

ShowMessage(Humanize.StringValue('dash-separated-name', lcTitleCase));
// -> Dash Separated Name

ShowMessage(Humanize.Dehumanize('order status code'));
// -> OrderStatusCode

ShowMessage(Humanize.Truncate('Long text to truncate', 10));
// -> Long text…

Numbers

ShowMessage(Humanize.Number(1234, hcEnglish));
// -> one thousand two hundred thirty-four

ShowMessage(Humanize.Number(1234, hcTurkish));
// -> bin iki yüz otuz dört

ShowMessage(Humanize.Ordinal(21, hcEnglish));
// -> 21st

ShowMessage(Humanize.Ordinal(21, hcTurkish));
// -> 21.

ShowMessage(Humanize.Quantity(3, 'file', 'files', hcEnglish));
// -> 3 files

ShowMessage(Humanize.Quantity(3, 'dosya', '', hcTurkish));
// -> 3 dosya

Bytes & lists

ShowMessage(Humanize.Bytes(1536000));
// -> 1.5 MB

ShowMessage(Humanize.List(['Ankara', 'Izmir', 'Bursa'], hcEnglish));
// -> Ankara, Izmir and Bursa

ShowMessage(Humanize.List(['Ankara', 'Izmir', 'Bursa'], hcTurkish));
// -> Ankara, Izmir ve Bursa

About

ShowMessage(Humanize.Version);
// -> 1.0.0

ShowMessage(Humanize.AboutText);
// -> DFHumanize 1.0.0 - DelphiFan <adsdelphi@gmail.com> - https://delphifan.com

Folder layout

DelphiHumanizer/
  Source/      Core units + components
  Packages/    Runtime + design packages (.groupproj)
  Demo/        VCL sample application
  Lib/         Build output (BPL / DCP / DCU)
  README.md
  README.tr.md
  LICENSE

Requirements

  • Embarcadero Delphi 10.3 Rio or newer
  • VCL (Win32 design package)

License

MIT — see LICENSE.

Copyright (c) DelphiFan — delphifan.comadsdelphi@gmail.com

About

Make strings, dates, numbers, bytes and lists **human-readable** in Delphi

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages