File Coverage

blib/lib/Locale/Framework/wxLocale.pm
Criterion Covered Total %
statement 4 6 66.6
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 6 8 75.0


line stmt bran cond sub pod time code
1             package Locale::Framework::wxLocale;
2              
3 1     1   62060 use strict;
  1         3  
  1         54  
4 1     1   629 use Wx qw(:locale);
  0            
  0            
5             use Wx::Locale qw(:default);
6              
7             our $VERSION='0.05';
8              
9             sub new {
10             my $class=shift;
11             my $locale_path_prefix=shift or die "You need to specify a locale path prefix";;
12             my $catalog=shift or die "You need to specify a catalog to use";
13             my $self;
14              
15             $self->{"wxlocale"}=new Wx::Locale(wxLANGUAGE_DEFAULT);
16             $self->{"path"}=$locale_path_prefix;
17             $self->{"catalog"}=$catalog;
18             $self->{"lang"}="default";
19              
20             bless $self,$class;
21             return $self;
22             }
23              
24             sub translate {
25             my ($self,$lang,$text)=@_;
26             if ($self->{"lang"} ne $lang) {
27             my $locale=get_wx_locale($lang);
28             undef $self->{"wxlocale"}; # From the Wx::Locale demo of wxPerl
29             if ($locale eq "") {
30             $self->{"wxlocale"}=new Wx::Locale(wxLANGUAGE_DEFAULT);
31             }
32             else {
33             $self->{"wxlocale"}=new Wx::Locale($lang,$lang,$locale);
34             my $path=$self->{"path"}."/".$locale;
35             $self->{"wxlocale"}->AddCatalogLookupPathPrefix($path);
36             $self->{"wxlocale"}->AddCatalog($self->{"catalog"});
37             }
38             $self->{"lang"}=$lang;
39             }
40             return gettext($text);
41             }
42              
43             sub set_translation {
44             return 0;
45             }
46              
47             sub clear_cache {
48             }
49              
50             my @languages=(
51             "ab",
52             "aa",
53             "af_ZA",
54             "sq_AL",
55             "am",
56             "ar",
57             "ar_DZ",
58             "ar_BH",
59             "ar_EG",
60             "ar_IQ",
61             "ar_JO",
62             "ar_KW",
63             "ar_LB",
64             "ar_LY",
65             "ar_MA",
66             "ar_OM",
67             "ar_QA",
68             "ar_SA",
69             "ar_SD",
70             "ar_SY",
71             "ar_TN",
72             "ar_AE",
73             "ar_YE",
74             "hy",
75             "as",
76             "ay",
77             "az",
78             "az",
79             "az",
80             "ba",
81             "eu_ES",
82             "be_BY",
83             "bn",
84             "dz",
85             "bh",
86             "bi",
87             "br",
88             "bg_BG",
89             "my",
90             "km",
91             "ca_ES",
92             "zh_CN",
93             "zh_CN",
94             "zh_TW",
95             "zh_HK",
96             "zh_MO",
97             "zh_SG",
98             "zh_TW",
99             "co",
100             "hr_HR",
101             "cs_CZ",
102             "da_DK",
103             "nl_NL",
104             "nl_BE",
105             "en_GB",
106             "en_GB",
107             "en_US",
108             "en_AU",
109             "en_BZ",
110             "en_BW",
111             "en_CA",
112             "en_CB",
113             "en_DK",
114             "en_IE",
115             "en_JM",
116             "en_NZ",
117             "en_PH",
118             "en_ZA",
119             "en_TT",
120             "en_ZW",
121             "eo",
122             "et_EE",
123             "fo_FO",
124             "fa_IR",
125             "fj",
126             "fi_FI",
127             "fr_FR",
128             "fr_BE",
129             "fr_CA",
130             "fr_LU",
131             "fr_MC",
132             "fr_CH",
133             "fy",
134             "gl_ES",
135             "ka",
136             "de_DE",
137             "de_AT",
138             "de_BE",
139             "de_LI",
140             "de_LU",
141             "de_CH",
142             "el_GR",
143             "kl_GL",
144             "gn",
145             "gu",
146             "ha",
147             "he_IL",
148             "hi_IN",
149             "hu_HU",
150             "is_IS",
151             "id_ID",
152             "ia",
153             "ie",
154             "iu",
155             "ik",
156             "ga_IE",
157             "it_IT",
158             "it_CH",
159             "ja_JP",
160             "jw",
161             "kn",
162             "ks",
163             "ks_IN",
164             "kk",
165             "kw_GB",
166             "rw",
167             "ky",
168             "rn",
169             "konkani",
170             "ko_KR",
171             "ku",
172             "lo",
173             "la",
174             "lv_LV",
175             "ln",
176             "lt_LT",
177             "mk_MK",
178             "mg",
179             "ms_MY",
180             "ml",
181             "ms_BN",
182             "ms_MY",
183             "mt_MT",
184             "manipuri",
185             "mi",
186             "mr_IN",
187             "mo",
188             "mn",
189             "na",
190             "ne",
191             "ne_IN",
192             "nb_NO",
193             "nn_NO",
194             "oc",
195             "or",
196             "om",
197             "ps",
198             "pl_PL",
199             "pt_PT",
200             "pt_BR",
201             "pa",
202             "qu",
203             "rm",
204             "ro_RO",
205             "ru_RU",
206             "ru_UA",
207             "sm",
208             "sg",
209             "sa",
210             "gd",
211             "sr_YU",
212             "sr_YU",
213             "sr_YU",
214             "sh",
215             "st",
216             "tn",
217             "sn",
218             "sd",
219             "si",
220             "ss",
221             "sk_SK",
222             "sl_SI",
223             "so",
224             "es_ES",
225             "es_AR",
226             "es_BO",
227             "es_CL",
228             "es_CO",
229             "es_CR",
230             "es_DO",
231             "es_EC",
232             "es_SV",
233             "es_GT",
234             "es_HN",
235             "es_MX",
236             "es_ES",
237             "es_NI",
238             "es_PA",
239             "es_PY",
240             "es_PE",
241             "es_PR",
242             "es_UY",
243             "es_US",
244             "es_VE",
245             "su",
246             "sw_KE",
247             "sv_SE",
248             "sv_FI",
249             "tl",
250             "tg",
251             "ta",
252             "tt",
253             "te",
254             "th_TH",
255             "bo",
256             "ti",
257             "to",
258             "ts",
259             "tr_TR",
260             "tk",
261             "tw",
262             "ug",
263             "uk_UA",
264             "ur",
265             "ur_IN",
266             "ur_PK",
267             "uz",
268             "uz",
269             "uz",
270             "vi_VN",
271             "vo",
272             "cy",
273             "wo",
274             "xh",
275             "yi",
276             "yo",
277             "za",
278             "zu"
279             );
280              
281             sub get_wx_locale {
282             my $lang=shift;
283              
284             if ($lang eq "") { return ""; }
285              
286             my $n=length($lang);
287             for my $l (@languages) {
288             if (lc(substr($l,0,$n)) eq lc($lang)) {
289             return $l;
290             }
291             }
292             return "";
293             }
294              
295             1;
296              
297             =head1 NAME
298              
299             Locale::Framework::wxLocale, a WxPerl backend for Locale::Framework
300              
301             =head1 SYNOPSIS
302              
303             use Locale::Framework;
304             use Locale::Framework::wxLocale;
305            
306             my $wxloc=new Locale::Framework::wxLocale();
307             Locale::Framework::language("en");
308              
309             print _T("This is a test");
310              
311             Locale::Framework::language("nl");
312            
313             print _T("This is a test");
314              
315             =head1 ABSTRACT
316              
317             This module provides a Wx::Locale backend for the Locale::Framework
318             internationalization module.
319              
320             =head1 DESCRIPTION
321              
322             =head2 C --E Locale::Framework::wxLocale
323              
324             Instantiates a new backend object.
325              
326             =head2 C --E string
327              
328             This function looks up a translation for the tuple (language, text)
329             via Wx::Locale.
330              
331             =head2 C --E boolean
332              
333             This function returns false for this backend, because Wx::Locale
334             does not support dynamic updating.
335              
336             =head2 C --E void
337              
338             This function is a noop for this backend.
339              
340             =head1 SEE ALSO
341              
342             L, L.
343              
344             =head1 AUTHOR
345              
346             Hans Oesterholt-Dijkema
347              
348             =head1 COPYRIGHT AND LICENSE
349              
350             This library is free software; you can redistribute it and/or modify
351             it under LGPL terms.
352              
353             =cut