Apache2-PageKit

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

		deliver in the default_output_charset and set the charset
		in the content_type header. ( Erik Günther )
	- Fix uri_prefix in conjunction with can_edit
		( Boris Zentner, Erik Günther ) 
1.13
	- Add support for Apache2 ( Boris Zentner )
	- Add scripts/pkit_rename_app.pl it helps to start new applications
		fast ( Boris Zentner )
	- Add <PKIT_COMMENT> and </PKIT_COMMENT> tags. ( Boris Zentner )
	- Fix filetest for upload_tmp_dir ( Boris Zentner )
	- Fix locale support. One message was twice in the .po files.
		( Boris Zentner )
	- Fix Encoding of Apache::PageKit::Edit. Use HTML::Entities
		and encode only '<>&"' ( Boris Zentner )	
	- Fix encoding of Apache::ErrorReport stacktrace
		( Boris Zentner, Paul Flinders )
1.12
	- PageKit now install the right version for the installed perl.
		This requires the patch command if you use perl 5.8.x.
		( Boris Zentner )
	- Replace Apache::test with Apache::Test ( Boris Zentner )

MANIFEST  view on Meta::CPAN

eg/Content/content_loop.xml
eg/Content/customize.xml
eg/Content/form_validation.xml
eg/Content/index.xml
eg/Content/language.xml
eg/Content/license.xml
eg/Content/login1.xml
eg/Content/media_xslt.xml
eg/Content/newacct1.xml
eg/Content/restricted.xml
eg/contrib/bin/build_locale.pl
eg/contrib/locale/README
eg/contrib/locale/templates/empty/empty.po
eg/contrib/locale/templates/po/de.po
eg/contrib/locale/templates/po/fr.po
eg/contrib/locale/templates/po/pt.po
eg/Model/MyPageKit/Common.pm
eg/Model/MyPageKit/MyModel.pm
eg/README
eg/View/Default/begin_cell.tmpl
eg/View/Default/bottom.tmpl
eg/View/Default/charset.tmpl
eg/View/Default/charset_tmpl.tmpl
eg/View/Default/content_loop.tmpl
eg/View/Default/customize.tmpl
eg/View/Default/demo_desc.tmpl

docsrc/reference.xml  view on Meta::CPAN

      <para>
       Prefix of URI that should be trimmed before dispatching to the Model code.
      </para>
      <para>
       See also <link linkend="model.api.pkit_fixup_uri">pkit_fixup_uri</link>
       in the Model API.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry id="config.global.use_locale">
     <term>use_locale</term>
     <listitem>
      <para>
       If set to <emphasis>yes</emphasis> pkit translates the original message to the language
       of the client if possible. If <link linkend="config.server.reload">reload</link>
       is set to <emphasis>yes</emphasis>, the translationtables are reloaded on every usage else only on first usage.
      </para>
      <para>
       Defaults to <emphasis>no</emphasis>.
       See also <link linkend="model.api.pkit_gettext">pkit_gettext</link> and
        <link linkend="model.api.pkit_gettext_message">pkit_gettext_message</link>

eg/README  view on Meta::CPAN


View/print/
This directory contains PageKit Template files that override the templates
	in "Default" if the view equals "print".

View/xml/ View/wml View/pdf
These directories contain XSLT and PageKit Template files that are used
	to provide different media outputs.

contrib/
This directory contains Templates for locale support and script(s) that do your work.
	See contrib/locale/README

eg/contrib/bin/build_locale.pl  view on Meta::CPAN

#!/usr/bin/perl -w

# $Id: build_locale.pl,v 1.1 2001/12/04 13:57:49 borisz Exp $

use strict;

use File::Path;

use vars qw( $root_dir $template_dir @catalog_files $msgfmt_cmd );

chomp( $msgfmt_cmd = `which msgfmt` );
$msgfmt_cmd =~ /^which: no/ and die "msgfmt not found!";

$root_dir = shift || die "$0 /full/path/to/your/documentroot";

$template_dir = $root_dir . '/contrib/locale/templates/po';

chdir $template_dir and opendir DIR, '.' or die "$!";
@catalog_files = grep { /\.po$/ && -f } readdir DIR;
closedir DIR;

for (@catalog_files) {
  my ($lang) = /(.*)\.po$/;
  my $catalog_dir = "$root_dir/locale/$lang/LC_MESSAGES";
  mkpath($catalog_dir);
  print "Create catalog $catalog_dir/PageKit.mo\n";
  system( "$msgfmt_cmd", "-o", "$catalog_dir/PageKit.mo", "$_" ) == 0 or die "$msgfmt_cmd failed $?";
}

eg/contrib/locale/README  view on Meta::CPAN


lets perl do the work!

cd to_the_example_site;
./contrib/bin/build_locale.pl `pwd`

this creates all possible message catalogs from the dir .../locale/templates/po/
and install them in the right place.

How to build a compiled message file (.mo) manual?

first cd into the po_templates directory and copy the file
empty.po to your_lang.po i.e. cp empty.po de.po
the translate it. for all your messages add a

msgid "Hello World" and a
msgstr "Hallo Welt" line with the translation

if done call msgfmt to build the .mo file.

msgfmt -o de.mo de.po

then copy the file de.mo into the pkit_root/locale/de/LC_MESSAGES directory.

thats all.

with this patch pkit have locale info. This is very usefull for
languages != en for obvious reason but also for en. with this you
can have some sites with different messages four the same thing.

like: "You logged in succsesfully." on one site and
"You are welcome." on the other.

also all messages form the pkit_validate_input are translated.

use_locale = 'yes' in the global config part of the Config.xml file activates
the use of the locale info you provide. You need the module Locale::gettext
1.01. if reload = 'yes' (from the server config part) then the .mo files
are reread on every request. else only on serverstartup or first usage.

the API:

pkit_gettext($text);
	translate the text $text and return the translated text.
	if the text cant be translated, the original text is returned.

and pkit_gettext_message($text,...);
	this is a shortcut for
$model->pkit_message($model->pkit_gettext($text),...);


what to do?
copy your locale files into the directory
pkit_root/locale/*YOUR_LANG*/LC_MESSAGES/MyPageKit.mo where *YOUR_LANG*
should be replaced with your language shortcut from the ISO 639 standard.

here some i know of.

en English
de German
fr French
es Spanish
ga Irish
it Italian
zu Zulu

and MyPageKit should be replaced with the name of your pkit application.

so for my internal site pkit.brain.de with the dispatch class MyPageKit::MyModel

../htdocs/pkit.brain.de/locale/de/LC_MESSAGES/PageKit.mo
../htdocs/pkit.brain.de/locale/en/LC_MESSAGES/PageKit.mo

the .mo files are created with the msgfmt commandline tool form your PageKit.po
file.
A simple one is here:

######## start of file

domain "PageKit.mo"

#

lib/Apache2/PageKit.pm  view on Meta::CPAN


  # delete all cache files, since some of them might be stale
  # and might not be checked for freshness, if reload is off
  # even if reload is on, PageKit might change, so it should be refreshed
  my $unlink_sub = sub {
    -f && unlink;
  };
  File::Find::find($unlink_sub,$view_cache_dir);

  # init gettext
  if (($config->get_global_attr('use_locale') || 'no') eq 'yes') {
    eval { require Locale::gettext };

    unless ($@) {

      # check for broken locale settings
      delete @ENV{qw/LANG LANGUAGE LC_ALL/};

      $ENV{LC_MESSAGES} = $config->get_global_attr('default_lang') || 'en';

      # ( my $textdomain ) = $config->get_global_attr('model_base_class') =~ m/^([^:]+)/;
      my $textdomain = 'PageKit';
      Locale::gettext::bindtextdomain($textdomain, $pkit_root . '/locale');
      Locale::gettext::textdomain($textdomain);
    }
    else {
      warn "Locale::gettext not installed ($@)";
    }
  }

  $model_base_class->pkit_startup($pkit_root, $server, $config)
    if $model_base_class->can('pkit_startup');
}

lib/Apache2/PageKit/Model.pm  view on Meta::CPAN

}

sub pkit_gettext_message {
  my ( $model, $text ) = splice(@_, 0, 2);
  return $model->pkit_message($model->pkit_gettext($text), @_);
}

sub pkit_gettext {
  my ( $model, $text ) = @_;
  my $config = $model->config;
  my $use_locale = $config->get_global_attr('use_locale') || 'no';
  return $text if ( !exists &Locale::gettext::gettext || $use_locale ne 'yes' );
  unless ( $model->pnotes('pkit_env_lang_is_set') ) {
    $model->pnotes('pkit_env_lang_is_set' => 1);
    $ENV{LC_MESSAGES} = $model->{pkit_pk}->{lang} || 'en';

    # notice changes in the .mo file if reload eq 'yes'
    my $reload = $config->get_server_attr('reload') || 'no';
    if ( $reload eq 'yes' ) {
      #my ( $textdomain ) = $config->get_global_attr('model_base_class') =~ m/^([^:]+)/;
      my $textdomain = 'PageKit';
      Locale::gettext::textdomain($textdomain);



( run in 2.667 seconds using v1.01-cache-2.11-cpan-ceb78f64989 )