
Locale::TextDomain::Ties - Tying all translating subs to a hash

0.03

Tie what you want. Here is one example for each sub.
require Tie::Sub;
tie my %__x, 'Tie::Sub', sub { return __x(shift, @_) };
tie my %__n, 'Tie::Sub', sub { return __n(shift, shift, shift) };
tie my %__nx, 'Tie::Sub', sub { return __nx(shift, shift, shift, @_) };
tie my %__xn, 'Tie::Sub', sub { return __xn(shift, shift, shift, @_) };
tie my %__p, 'Tie::Sub', sub { return __p(shift, shift) };
tie my %__px, 'Tie::Sub', sub { return __px(shift, shift, @_) };
tie my %__np, 'Tie::Sub', sub { return __np(shift, shift, shift, shift, @_) };
tie my %__npx, 'Tie::Sub', sub { return __npx(shift, shift, shift, shift, @_) };
tie my %N__, 'Tie::Sub', sub { return [N__(shift)] };
tie my %N__n, 'Tie::Sub', sub { return [N__n(shift, shift, shift)] };
tie my %N__p, 'Tie::Sub', sub { return [N__p(shift, shift)] };
tie my %N__np, 'Tie::Sub', sub { return [N__np(shift, shift, shift, shift)] };
The construct 'shift, @_' or 'shift, shift, @_' is necessary because the module Locale::TextDomain uses prototypes. A simple '@_' does not work.
use Locale::TextDomain::Ties 1.20;
%__ is already tied and exported by Locale::Text::Domain. It is the same like:
tie my %__, 'Tie::Sub', sub { return __(shift) };
Further information and concrete examples are in the chapter example.

Inside of this Distribution is a directory named example. Read and run this *.pl files.
This describes how to write and how to extract.

Locale::TextDomain only ties a sub named &__ to a hash named %__ and a hash reference named $__ .
This module shows how to tie all the other translating subs of Locale::TextDomain.
This is a documentation module only. Use of this module makes no sense.

none

none

nothing

none

none

not known

Locale::TextDomain Localisation framework
Tie::Sub The idea to use an arrayref as hash key too.

Steffen Winkler

Copyright (c) 2009, Steffen Winkler <steffenw at cpan.org>. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.