Changeset 4152 for extensions/pLoader


Ignore:
Timestamp:
Oct 29, 2009, 8:23:43 PM (14 years ago)
Author:
ronosman
Message:

Bug 1219 fixed : property values must be language independant.

Location:
extensions/pLoader/trunk/src/Uploader
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • extensions/pLoader/trunk/src/Uploader/GUI/wxApp.pm

    r4138 r4152  
    104104          chunk_size
    105105          layout_clean
     106          colors
     107          eng_colors
     108          positions
     109          eng_positions
     110          default_photo_names
     111          eng_default_photo_names
    106112      /
    107113);
     
    211217   
    212218    $self->init_locale;
     219    $self->_init_localized_properties;
    213220
    214221    my $not_exit = $self->Login();
     
    228235
    229236    $not_exit;
     237}
     238
     239# some properties are displayed in choice list, with translated strings
     240# the translation has to be reverted to store a language independant value
     241sub _init_localized_properties {
     242    my ( $self ) = @_;
     243
     244    $self->colors(
     245        ['Black', 'White']
     246    );
     247    # We need to translate back to english when we store properties
     248    $self->eng_colors(
     249        {
     250            map { gettext($_) => $_ } @{$self->colors}
     251        }
     252    );
     253    $self->positions(
     254        [
     255            'Top',
     256            'Left',
     257            'Right',
     258            'Bottom',
     259            'Top left',
     260            'Top right',
     261            'Bottom left',
     262            'Bottom right',
     263            'Center',
     264        ]
     265    );
     266
     267    $self->eng_positions(
     268        {
     269             map { gettext($_) => $_ } @{$self->positions}
     270        }
     271    );
     272
     273    $self->default_photo_names(
     274        [
     275             'None',
     276             'File name',
     277             'File path and name',
     278             'Prefix',
     279             'Prefix + rank number',
     280             'Rank number + prefix',
     281             'Prefix + create date chrono',
     282             'Create date chrono + prefix',
     283        ]
     284    );
     285    $self->eng_default_photo_names(
     286        {
     287             map { gettext($_) => $_ } @{$self->default_photo_names}
     288        }
     289    );
    230290}
    231291
     
    425485        storable_file    => $self->storable_file,
    426486        userdata_dir     => $self->userdata_dir,
    427         default_photo_name => gettext('File name'),
     487        default_photo_name => 'File name',
    428488        default_name_prefix => gettext('Photo '),
    429489        upload_rejects   =>  [],
     
    436496        watermark_text => gettext("my watermark"),
    437497        watermark_text_size => 12,
    438         watermark_position => gettext("Center"),
     498        watermark_position => 'Center',
    439499        watermark_y => 10,
    440500        watermark_x => 10,
    441         watermark_color => gettext("White"),
     501        watermark_color => 'White',
    442502    };
    443503
  • extensions/pLoader/trunk/src/Uploader/GUI/wxFrameAUI.pm

    r4138 r4152  
    275275        [
    276276            {
    277                 label => gettext("Photo caption :"),
    278                 value => sub { $self->imagelist->current_image->site_name(@_) },
     277                label          => gettext("Photo caption :"),
     278                value          => sub { $self->imagelist->current_image->site_name(@_) },
     279                frame_callback => sub { $self->imageviewer->Refresh() },
    279280            },
    280281            {
     
    367368                value   => sub { $self->imagelist->default_photo_name(@_) },
    368369                choice  => [
    369                                   gettext('None'),
    370                                   gettext('File name'),
    371                                   gettext('File path and name'),
    372                                   gettext('Prefix'),
    373                                   gettext('Prefix + rank number'),
    374                                   gettext('Rank number + prefix'),
    375                                   gettext('Prefix + create date chrono'),
    376                                   gettext('Create date chrono + prefix'),
    377                               ],
     370                               map { gettext $_ } @{wxTheApp->default_photo_names}
     371                           ],
     372                pre_process => sub { my ( $value ) = @_; wxTheApp->eng_default_photo_names->{$value} },
    378373            },
    379374            {
     
    515510                label     => gettext("Color :"),
    516511                type      => 'Choice',
    517                 value   => sub { $self->imagelist->watermark_color(@_) },
    518                 choice  => [
    519                                   gettext("White"),
    520                                   gettext("Black"),
    521                            ],
     512                value     => sub { $self->imagelist->watermark_color(@_) },
     513                choice    => [
     514                               map { gettext $_ } @{wxTheApp->colors}
     515                             ],
     516                pre_process => sub { my ( $value ) = @_; wxTheApp->eng_colors->{$value} },
    522517            },           
    523518            {
     
    526521                value   => sub { $self->imagelist->watermark_position(@_) },
    527522                choice  => [
    528                                   gettext("Top"),
    529                                   gettext("Top left"),
    530                                   gettext("Top right"),
    531                                   gettext("Bottom"),
    532                                   gettext("Bottom left"),
    533                                   gettext("Bottom right"),
    534                                   gettext("Center"),
    535                                   gettext("Left"),
    536                                   gettext("Right"),
     523                               map { gettext $_ } @{wxTheApp->positions}
    537524                           ],
     525                pre_process => sub { my ( $value ) = @_; wxTheApp->eng_positions->{$value} },
    538526            },
    539527            {
     
    686674                parentwnd       => $self,
    687675                properties      => $self->piwigo_properties,
    688                 frame_callbacks => [
    689                                           sub {
    690                                               $self->imageviewer->Refresh();
    691                                           },
    692                                    ],
    693676            }
    694677        )
     
    699682            {
    700683                parentwnd       => $self,
    701                 frame_callbacks => [],
    702684                properties      => $self->exif_properties,
    703685            }
     
    711693                parentwnd       => $self,
    712694                properties      => $self->general_settings,
    713                 frame_callbacks => [],
    714695            }
    715696        )
     
    721702                parentwnd       => $self,
    722703                properties      => $self->resized_settings,
    723                 frame_callbacks => [],
    724704
    725705            }
     
    732712                parentwnd       => $self,
    733713                properties      => $self->thumbnail_settings,
    734                 frame_callbacks => [],
    735714
    736715            }
     
    742721                parentwnd       => $self,
    743722                properties      => $self->preview_settings,
    744                 frame_callbacks => [],
    745723
    746724            }
     
    753731                parentwnd       => $self,
    754732                properties      => $self->advanced_settings,
    755                 frame_callbacks => [],
    756733
    757734            }
     
    764741                parentwnd   => $self,
    765742                properties  => $self->watermark_settings,
    766                 frame_callbacks => [],
    767743            }
    768744        )
  • extensions/pLoader/trunk/src/Uploader/GUI/wxImageListCtrl.pm

    r3362 r4152  
    2929             wxLC_EDIT_LABELS
    3030             wxLC_ICON
     31             wxLC_SMALL_ICON
    3132             wxIMAGE_LIST_NORMAL
    3233             wxBITMAP_TYPE_JPEG
  • extensions/pLoader/trunk/src/Uploader/GUI/wxPropertyGridPanel.pm

    r4134 r4152  
    2424             wxDefaultPosition
    2525         /;
    26 
     26use Wx::Locale qw/:default/;
    2727use base qw/Wx::Grid Uploader::Object2/;
    2828
     
    3131/;
    3232use Data::Dumper;
    33 
    3433__PACKAGE__->mk_accessors(     
    3534    qw/
    36         frame_callbacks
    3735        renderer
    3836        editor
     
    7573    );
    7674   
    77     # a frame callback for each property
    78     $self->frame_callbacks(
    79         $params->{frame_callbacks}
    80     );
    81    
    8275    $self->Initialize;
    8376     
     
    121114                $row,
    122115                1,
    123                 $_->{value}->(),
     116                exists $_->{choice} ? gettext($_->{value}->()) : $_->{value}->(),
    124117            ); 
    125118
     
    173166                $row,
    174167                1,
    175                 $_->{value}->(),
     168                exists $_->{choice} ? gettext($_->{value}->()) : $_->{value}->(),
    176169            ); 
    177170
     
    201194    );
    202195
     196    # if we need to preprocess the value
     197    $value = $self->properties->[$row]->{pre_process}->($value) if exists
     198        $self->properties->[$row]->{pre_process};
     199
    203200    # set property
    204201    $self->properties->[$row]->{value}->($value);
    205 
     202printf("property value %s\n",     $self->properties->[$row]->{value}->());
    206203   
    207204    # execute the corresponding frame callback
    208     $self->frame_callbacks->[$row]->() if defined $self->frame_callbacks->[$row];
     205    $self->properties->[$row]->{frame_callback}->() if exists
     206        $self->properties->[$row]->{frame_callback};
    209207}
    210208
  • extensions/pLoader/trunk/src/Uploader/ImageList.pm

    r4121 r4152  
    112112    $self->gravity(
    113113        {
    114             gettext("Top") => 'North',
    115             gettext("Left") => 'West',
    116             gettext("Right") => 'East',
    117             gettext("Bottom") => 'South',
    118             gettext("Top left") => 'NorthWest',
    119             gettext("Top right") => 'NorthEast',
    120             gettext("Bottom left") => 'SouthWest',
    121             gettext("Bottom right") => 'SouthEast',
    122             gettext("Center") => 'Center',
     114            'Top'          => 'North',
     115            'Left'        => 'West',
     116            'Right'        => 'East',
     117            'Bottom'      => 'South',
     118            'Top left'    => 'NorthWest',
     119            'Top right'    => 'NorthEast',
     120            'Bottom left' => 'SouthWest',
     121            'Bottom right' => 'SouthEast',
     122            'Center'      => 'Center',
    123123       }   
    124124    );   
     
    126126    $self->rgbcolor(
    127127        {
    128             gettext("White") => '#FFFFFF',
    129             gettext("Black") => '#000000',
     128            "White" => '#FFFFFF',
     129            "Black" => '#000000',
    130130        }   
    131131    );
     
    344344 
    345345    my $chrono = join('', $yyyy, $mm, $dd);
    346     if(gettext('Prefix') eq $self->default_photo_name){
     346    if('Prefix' eq $self->default_photo_name){
    347347        $name = $self->default_name_prefix
    348348    }
    349     elsif(gettext('File name') eq $self->default_photo_name){
     349    elsif('File name' eq $self->default_photo_name){
    350350        $name = $filename
    351351    }
    352     elsif(gettext('File path and name') eq $self->default_photo_name){
     352    elsif('File path and name' eq $self->default_photo_name){
    353353        $name = sprintf(
    354354            "%s",
     
    356356        )       
    357357    }   
    358     elsif(gettext('Prefix + rank number') eq $self->default_photo_name){
     358    elsif('Prefix + rank number' eq $self->default_photo_name){
    359359        $name = sprintf(
    360360            "%s%s",
     
    363363        )       
    364364    }   
    365     elsif(gettext('Rank number + prefix') eq $self->default_photo_name){
     365    elsif('Rank number + prefix' eq $self->default_photo_name){
    366366        $name = sprintf(
    367367            "%s%s",
     
    370370        )       
    371371    }   
    372     elsif(gettext('Prefix + create date chrono') eq $self->default_photo_name){
     372    elsif('Prefix + create date chrono' eq $self->default_photo_name){
    373373        $name = sprintf(
    374374            "%s%s",
     
    377377        )       
    378378    }   
    379     elsif(gettext('Create date chrono + prefix') eq $self->default_photo_name){
     379    elsif('Create date chrono + prefix' eq $self->default_photo_name){
    380380        $name = sprintf(
    381381            "%s%s",
Note: See TracChangeset for help on using the changeset viewer.