Locale — specify locale definitions
The directive specifies the default locale definitions for a number of items:
currency_symbol
- default currency symbol. Can be a simple value like "$
" or " E
", or a more flexible setting such as '<img src="euro.png" />
'.
frac_digits
-
int_curr_symbol
-
int_currency_symbol
- currency symbol for plain text display
int_frac_digits
-
mon_decimal_point
-
mon_grouping
-
price_picture
-
mon_thousands_sep
-
n_cs_precedes
-
negative_sign
-
p_cs_precedes
- whether currency symbol precedes price or vice versa
p_sep_by_space
- number of spaces between currency symbol and price
positive_sign
-
Example: Defining Locale by individual keys
Put the following in interchange.cfg
:
Locale <localedata
The actual file localedata
could be composed
of the keys listed in the section called “DESCRIPTION”.
Example: Price displayed as 1.000,00 EUR
Locale de_DE currency_symbol EUR Locale de_DE p_cs_precedes 0 Locale de_DE mon_decimal_point , Locale de_DE mon_thousands_sep . [currency]1000[/currency]
If two locales are set "default" using Locale
, and no
DefaultLocale
is specified, the behavior is undefined as the first
"default" found will be set as the actual default.
Interchange 5.9.0:
Source: lib/Vend/Config.pm
Line 3071 (context shows lines 3071-3135)
sub parse_locale { my($item,$settings) = @_; return ($settings || '') unless $settings =~ /[^\d.]/; $settings = '' if "\L$settings" eq 'default'; my $name; my ($c, $store); if(defined $C) { $c = $C->{$item} || { }; $C->{$item . "_repository"} = {} unless $C->{$item . "_repository"}; $store = $C->{$item . "_repository"}; } else { no strict 'refs'; $c = ${"Global::$item"} || {}; ${"Global::$item" . "_repository"} = {} unless ${"Global::$item" . "_repository"}; $store = ${"Global::$item" . "_repository"}; } my ($eval, $safe); if ($settings =~ s/^\s*([-\w.@]+)(?:\s+)?//) { $name = $1; undef $eval; $settings =~ /^\s*{/ and $settings =~ /}\s*$/ and $eval = 1; $eval and ! $safe and $safe = new Vend::Safe; if(! defined $store->{$name} and $item eq 'Locale') { my $past = POSIX::setlocale(POSIX::LC_ALL); if(POSIX::setlocale(POSIX::LC_ALL, $name) ) { $store->{$name} = POSIX::localeconv(); } POSIX::setlocale(POSIX::LC_ALL, $past); } my($sethash); if ($eval) { $sethash = $safe->reval($settings) or config_warn("bad Locale setting in %s: %s", $name, $@), $sethash = {}; } else { $settings =~ s/^\s+//; $settings =~ s/\s+$//; $sethash = {}; %{$sethash} = Text::ParseWords::shellwords($settings); } $c = $store->{$name} || {}; my $nodefaults = delete $sethash->{MV_LOCALE_NO_DEFAULTS}; for (keys %{$sethash}) { $c->{$_} = $sethash->{$_}; } } else { config_error("Bad locale setting $settings.\n"); } $C->{LastLocale} = $name if $C and $item eq 'Locale'; $store->{$name} = $c unless $store->{$name}; return $c; }