NAME

PersonName::Format::Compiled - Precompiled CLDR person name formatter

SYNOPSIS

use PersonName::Format;

my $formatter = PersonName::Format->new(
    locale => 'en-US',
);

my $compiled = $formatter->compile(
    nameLocale => 'ja-JP',
    nameScript => 'Jpan',
);

my $string = $compiled->format(
    {
    given   => '太郎',
    surname => '山田',
    }
);

DESCRIPTION

This class represents a precompiled formatter created by "compile" in PersonName::Format. It freezes the locale, script, order, CLDR pattern group, space replacement rules, and field modifier resolver. Pattern selection still occurs per name because CLDR chooses the best pattern according to the fields actually populated in that name.

A compiled formatter freezes all formatting decisions that depend only on the formatter configuration and the characteristics of the names being formatted, such as the formatting locale, the name locale, the script, the preferred name order, the selected CLDR pattern group and the applicable field modifiers.

The final CLDR pattern is still selected for each formatted name, since it depends on which fields are actually present.

Compiled formatters are intended for high-throughput applications that format many names sharing the same locale and script characteristics.

Objects of this class are created by "compile" in PersonName::Format; they should not normally be instantiated directly.

METHODS

format

my $string = $compiled->format( $name );

Formats a name and returns the resulting string.

This method behaves identically to "format" in PersonName::Format, but avoids repeating the context derivation performed during normal formatting.

formatToParts

my $parts = $compiled->formatToParts( $name );

my $parts = $compiled->format_to_parts( $name );

Formats a name and returns an array reference describing the generated parts.

The returned structure is identical to that returned by "formatToParts" in PersonName::Format.

resolvedOptions

my $options = $compiled->resolvedOptions;

my $options = $compiled->resolved_options;

Returns a hash reference describing the effective formatting options frozen into this compiled formatter.

SEE ALSO

PersonName::Format, PersonName::Format::Name, https://www.unicode.org/reports/tr35/tr35-personNames.html

AUTHOR

Jacques Deguest <jack@deguest.jp>

COPYRIGHT & LICENSE

Copyright(c) 2026 DEGUEST Pte. Ltd.

All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.