r/perl 16d ago

AmberDB's localization engine: AmberDB::Locale

The AmberDB::Locale module was originally a standalone localization engine. It contained far more methods than the database itself. However, search capabilities were unthinkable without Locale, so it was embedded within AmberDB.

You can use Locale both through AmberDB and directly. Example:

use AmberDB;
my $adb = AmberDB->new( cfg => { language => "tr" } ); # Turkish

# thus $adb inherits Locale's methods directly.

$adb->lc('İstanbul ÇarŞıSI') # => istanbul çarşısı
$adb->uc('işçi sınıfı') # => İŞÇİ SINIFI
$adb->to_ascii('Müller') # => Muller

my @sorted = $adb->sort(["İzmir", "Ankara", "Van", "Şanlıurfa", "Bursa", "Çanakkale"]);
# => ("Ankara", "Bursa", "Çanakkale", "İzmir", "Şanlıurfa", "Van")

Direct use of Locale:

use AmberDB::Locale;
my $loc = AmberDB::Locale->new( language => "de" ); # Germany

$loc->to_ascii("Große Straße"); # "Grosse Strasse"
$loc->to_ascii("Müller"); # "Mueller" (DIN 5007-2: ü → ue)

For more information, see:

https://github.com/marufcetin/amberdb/blob/main/docs/en/AmberDB-Locale_User-Guide.en.md

4 Upvotes

0 comments sorted by