From 45b03a03c364457250ecaeda764f41ed05546fe3 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 12 Jan 2006 21:21:15 +0000 Subject: [PATCH] document changes in International.pm API --- docs/migration.txt | 23 +++++++++++++++++++++++ lib/WebGUI/International.pm | 16 ++++++++++------ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/docs/migration.txt b/docs/migration.txt index 18ce3b02a..1da470a6c 100644 --- a/docs/migration.txt +++ b/docs/migration.txt @@ -836,6 +836,29 @@ perl -pi.bak -e 's!WebGUI\:\:Subscription\-\>new\(!WebGUI::Subscription->new(\$s perl -pi.bak -e 's!WebGUI\:\:TabForm\-\>new\(!WebGUI::TabForm->new(\$self->session,!g' fileNameGoesHere +5.23.24 WebGUI::International API Refactored + +The WebGUI::Paginator API was changed to use the session API, and was +changed to be solely object oriented, where before it would work in +either subroutine or OO modes. The latter change precludes writing +a script to make the changes. + +The changes are summarized here. For complete details, please read the POD +documentation in lib/WebGUI/International.pm + +WebGUI::International::get('key','namespace'); + my $i18n = WebGUI::International->new($session, 'namespace'); + $i18n->get('key'); + +WebGUI::International::getLanguage('English', 'property'); + my $i18n = WebGUI::International->new($session); + $i18n->getLanguage('key'); + +WebGUI::International::getLanguages(); + my $i18n = WebGUI::International->new($session); + $i18n->getLanguages(); + + 6. Automatic list of Assets in Help System. ------------------------------------- diff --git a/lib/WebGUI/International.pm b/lib/WebGUI/International.pm index 43e37dc2d..32e100927 100644 --- a/lib/WebGUI/International.pm +++ b/lib/WebGUI/International.pm @@ -53,7 +53,9 @@ These functions/methods are available from this package: =head2 get ( internationalId [ , namespace, language ] ) -Returns the internationalized message string for the user's language. If there is no internationalized message, this method will return the English string. +Returns the internationalized message string for the user's language. +If there is no internationalized message, this method will return +the English string. =head3 internationalId @@ -73,8 +75,8 @@ my $safeRe = qr/[^\w\d\s\/]/; sub get { my ($self, $id, $namespace, $language) = @_; - $namespace = $namespace || $_[0]->{_namespace} || "WebGUI"; - $language = $language || $_[0]->{_language} || $self->session->user->profileField("language") || "English"; + $namespace = $namespace || $self->{_namespace} || "WebGUI"; + $language = $language || $self->{_language} || $self->session->user->profileField("language") || "English"; $id =~ s/$safeRe//g; $language =~ s/$safeRe//g; $namespace =~ s/$safeRe//g; @@ -170,7 +172,7 @@ Specify a default language. Defaults to user preference or "English". sub makeUrlCompliant { my ($self, $url, $language) = @_; - $language = $language || $_[0]->{_language} || $self->session->user->profileField("language") || "English"; + $language = $language || $self->{_language} || $self->session->user->profileField("language") || "English"; my $cmd = "WebGUI::i18n::".$language; my $load = "use ".$cmd; eval($load); @@ -184,9 +186,11 @@ sub makeUrlCompliant { #------------------------------------------------------------------- -=head2 new ( [ namespace, language ] ) +=head2 new ( session, [ namespace, language ] ) -The constructor for the International function if using it in OO mode. +The constructor for the International function if using it in OO mode. Note +that namespace and languages are defaults; they may be overridden in +all accessor methods, (get, getLanguage). =head3 session