NAME

Unicode::ICU::Locale - Locale data via ICU

SYNTAX

my $default = Unicode::ICU::Locale::DEFAULT_LOCALE;

# U.S. English in German:
my $dispname = Unicode::ICU::Locale::get_display_name('en-US', 'de');

my $all_locales_ar = Unicode::ICU::Locale::list_locales();

if ( Unicode::ICU::Locale::is_rtl($default) ) {
    # .. the default locale is right-to-left
}

DESCRIPTION

This module exposes parts of ICU’s locale interface.

CONSTANTS

  • DEFAULT_LOCALE - e.g., en

  • LAYOUT_LTR, LAYOUT_RTL, LAYOUT_TTB, and LAYOUT_BTT as from ICU’s uloc.h.

FUNCTIONS

$locales_ar = list_locales()

Returns a reference to an array of the current ICU library’s locales’ IDs (e.g., en).

$display = get_display_name( [$LOCALE_ID [, $DISPLAY_LOCALE_ID]] )

Returns a given locale’s display name.

With 0 arguments this returns the default locale name, in the default locale. With 1 argument it gives the given locale name, in the default locale. With 2 arguments it gives the 1st locale name in the 2nd locale.

undef just means the default locale, so if you want to show the default locale in a specific locale, do:

Unicode::ICU::Locale::get_display_name(undef, 'de');

See the "SYNOPSIS" above for more examples.

$yn = is_rtl( [$LOCALE_ID] )

A convenience function that wraps get_character_orientation() with logic to return truthy/falsy to indicate whether $LOCALE_ID (or, in its absence, ICU’s default locale) is right-to-left.

$orient = get_character_orientation( [$LOCALE_ID] )

Returns the given locale’s character orientation as one of the LAYOUT_* constants described above. If $LOCALE_ID is undef or not given, ICU’s default locale is used. English, for example, is LAYOUT_LTR, while Arabic is LAYOUT_RTL.

This can theoretically accommodate non-LTR, non-RTL locales (e.g., traditional East Asian vertical scripts), but since most applications don’t serve such locales you probably don’t need this function and can instead just call is_rtl() above.

$orient = get_line_orientation( [$LOCALE_ID] )

Like get_character_orientation() but returns the locale’s line orientation. (NB: In the author’s ICU, all locales are LAYOUT_TTB.)

$locale_id = canonicalize( $LOCALE_ID )

Returns $LOCALE_ID in what ICU thinks is its canonical form. (For example, en-US becomes en_US.)

(NB: $LOCALE_ID is required; if you want ICU’s default locale’s canonical form, just get DEFAULT_LOCALE, above.)

1 POD Error

The following errors were encountered while parsing the POD:

Around line 35:

Non-ASCII character seen before =encoding in 'ICU’s'. Assuming UTF-8