package Locale::Framework::wxLocale;

use strict;
use Wx qw(:locale);
use Wx::Locale qw(:default);

our $VERSION='0.05';

sub new {
  my $class=shift;
  my $locale_path_prefix=shift  or die "You need to specify a locale path prefix";;
  my $catalog=shift or die "You need to specify a catalog to use";
  my $self;

  $self->{"wxlocale"}=new Wx::Locale(wxLANGUAGE_DEFAULT);

  bless $self,$class;
return $self;

sub translate {
  my ($self,$lang,$text)=@_;
  if ($self->{"lang"} ne $lang) {
    my $locale=get_wx_locale($lang);
    undef $self->{"wxlocale"};    # From the Wx::Locale demo of wxPerl
    if ($locale eq "") {
      $self->{"wxlocale"}=new Wx::Locale(wxLANGUAGE_DEFAULT);
    else {
      $self->{"wxlocale"}=new Wx::Locale($lang,$lang,$locale);
      my $path=$self->{"path"}."/".$locale;
return gettext($text);

sub set_translation {
return 0;

sub clear_cache {

my @languages=(

sub get_wx_locale {
  my $lang=shift;

  if ($lang eq "") { return ""; }

  my $n=length($lang);
  for my $l (@languages) {
    if (lc(substr($l,0,$n)) eq lc($lang)) {
      return $l;
return "";


=head1 NAME

Locale::Framework::wxLocale, a WxPerl backend for Locale::Framework


  use Locale::Framework;
  use Locale::Framework::wxLocale;
  my $wxloc=new Locale::Framework::wxLocale();

  print _T("This is a test");

  print _T("This is a test");


This module provides a Wx::Locale  backend for the Locale::Framework 
internationalization module.


=head2 C<new()> --E<gt> Locale::Framework::wxLocale

Instantiates a new backend object.

=head2 C<translate(language,text)> --E<gt> string

This function looks up a translation for the tuple (language, text)
via Wx::Locale. 

=head2 C<set_translation(language,text,translation)> --E<gt> boolean

This function returns false for this backend, because Wx::Locale
does not support dynamic updating.

=head2 C<clear_cache()> --E<gt> void

This function is a noop for this backend.

=head1 SEE ALSO

L<Locale::Framework|Locale::Framework>, L<>.

=head1 AUTHOR

Hans Oesterholt-Dijkema <>


This library is free software; you can redistribute it and/or modify
it under LGPL terms.