6dd7c5a085224e39ce2763d78ab2e66b27d7bb4a
[freeside.git] / FS / FS / Locales.pm
1 package FS::Locales;
2
3 use strict;
4 use Tie::IxHash;
5
6 =head1 NAME
7
8 FS::Locales - Supported locales
9
10 =head1 SYNOPSIS
11
12   use FS::Locales;
13
14   my @locales = FS::Locales->locales;
15
16 =head1 DESCRIPTION
17
18 FS::Locales provides a list of supported locales.
19
20 =head1 CLASS METHODS
21
22 =over 4
23
24 =item locales
25
26 Returns a list of the available locales.
27
28 =cut
29
30 tie our %locales, 'Tie::IxHash',
31   'en_US', { name => 'English',        country => 'United States', },
32   'en_CA', { name => 'English',        country => 'Canada', },
33   'fr_CA', { name => 'French',         country => 'Canada', },
34   'fr_FR', { name => 'French',         country => 'France', },
35   'fr_HT', { name => 'French',         country => 'Haiti', },
36   'ht_HT', { name => 'Haitian Creole', country => 'Haiti', },
37   'iw_IL', { name => 'Hebrew',         country => 'Israel', rtl=>1, },
38 ;
39
40 $_->{label} = $_->{name} . ' (' . $_->{country} . ')'
41   foreach values %locales;
42
43 sub locales {
44   keys %locales;
45 }
46
47 =item locale_info LOCALE
48
49 Returns a hash of information about a locale.
50
51 =cut
52
53 sub locale_info {
54   my($class, $locale) = @_;
55   if (!$locale) {
56     return ();
57   } elsif (exists $locales{$locale}) {
58     return %{ $locales{$locale} };
59   } else {
60     die "unsupported locale '$locale'\n";
61   }
62 }
63
64 =item description LOCALE
65
66 Returns "Language (Country)" for a locale.
67
68 =cut
69
70 sub description {
71   my($class, $locale) = @_;
72   $locales{$locale}->{'name'} . ' (' . $locales{$locale}->{'country'} . ')';
73 }
74
75 =back
76
77 =head1 BUGS
78
79 =head1 SEE ALSO
80
81 L<FS::Msgcat>
82
83 =cut
84
85 1;
86