1Locale::TextDomain::OO:U:sLeerxiCcoonnt:r:iSbLtuootcreaedlJeSP:Oe:NrT(le3x)DtoDcoummaeinnt:a:tOiOo:n:Lexicon::StoreJSON(3)
2
3
4

NAME

6       Locale::TextDomain::OO::Lexicon::StoreJSON - Stores the lexicon for
7       other programming languages
8
9       $Id: StoreJSON.pm 647 2017-02-25 08:22:10Z steffenw $
10
11       $HeadURL:
12       svn+ssh://steffenw@svn.code.sf.net/p/perl-gettext-oo/code/module/trunk/lib/Locale/TextDomain/OO/Lexicon/StoreJSON.pm
13       $
14

VERSION

16       1.026
17

DESCRIPTION

19       This module stores the lexicon for other programming language e.g.
20       JavaScript.
21

SYNOPSIS

23   write file by given filename
24           use Locale::TextDomain::OO::Lexicon::StoreJSON;
25
26           Locale::TextDomain::OO::Lexicon::StoreJSON
27               ->new(
28                   filename => 'my_json_file',
29                   ...
30               )
31               ->to_json; # ->to_javascript or ->to_html
32
33   write file by given open file_handle
34           use Carp qw(confess);
35           use IO::File;
36           use Locale::TextDomain::OO::Lexicon::StoreJSON;
37
38           my $filename = 'my_json_file';
39           my $file_handle = IO::File->new( $filename, q{>} )
40               or confess qq{Unable to open file "$filename" $!};
41           Locale::TextDomain::OO::Lexicon::StoreJSON
42               ->new(
43                   filename    => $filename, # optional for error message only
44                   file_handle => file_handle,
45                   ...
46               )
47               ->to_json; # ->to_javascript or ->to_html
48           $file_handle->close
49               or confess qq{Unable to close file "$filename" $!};
50
51   as string
52           use Locale::TextDomain::OO::Lexicon::StoreJSON;
53
54           my $json = Locale::TextDomain::OO::Lexicon::StoreJSON
55               ->new(
56                   ...
57               )
58               ->to_json; # ->to_javascript or ->to_html
59
60   optional filter
61           use Locale::TextDomain::OO::Lexicon::StoreJSON;
62
63           my $json = Locale::TextDomain::OO::Lexicon::StoreJSON->new(
64               ...
65               # all parameters optional
66               # with all type examples for filter_... attributes
67               filter_language => undef,                       # default, means all
68               filter_domain   => 'my domain',                 # string
69               filter_category => qr{ \A \Qmy category\E }xms, # regex
70               filter_project  => sub {                        # code reference
71                   my $filter_name = shift;   # is 'filter_project'
72                   return $_ eq 'my project'; # boolean return
73               },
74           );
75           # from lexicon to data
76           # method to_json will use data to output
77           $json->copy;
78           $json->clear_filter; # set all filter_... to undef
79           $json->filter_domain( qr{ \A dom }xms );
80           $json->copy;
81           $json->clear_filter;
82           $json->filter_category( sub { return $_ eq 'cat1' } );
83           $json->copy;
84           $json->clear_filter;
85           $json->filter_domain('dom1');
86           $json->filter_category('cat1');
87           # remove all lexicons with dom1 and cat1 from data
88           $json->remove;
89           $json->to_json; # ->to_javascript or ->to_html
90

SUBROUTINES/METHODS

92   method new
93       see SYNOPSIS
94
95   method to_json
96       With file parameters it prints a JSON file.  Otherwise returns a JSON
97       string.
98
99   method to_javascript
100       Similar to method to_json but output wrapped as JavaScript with global
101       variable "localeTextDomainOOLexicon".
102
103   method to_html
104       Similar to method to_javascript but output wrapped as HTML with script
105       tag.
106

EXAMPLE

108       Inside of this distribution is a directory named example.  Run this
109       *.pl files.
110

DIAGNOSTICS

112       none
113

CONFIGURATION AND ENVIRONMENT

115       none
116

DEPENDENCIES

118       JSON
119
120       Moo
121
122       MooX::StrictConstructor
123
124       namespace::autoclean
125
126       Locale::TextDomain::OO::Lexicon::Role::StoreFile
127
128       Locale::TextDomain::OO::Lexicon::Role::StoreFilter
129

INCOMPATIBILITIES

131       not known
132

BUGS AND LIMITATIONS

134       none
135

SEE ALSO

137       Locale::TextDoamin::OO
138

AUTHOR

140       Steffen Winkler
141
143       Copyright (c) 2013 - 2014, Steffen Winkler "<steffenw at cpan.org>".
144       All rights reserved.
145
146       This module is free software; you can redistribute it and/or modify it
147       under the same terms as Perl itself.
148
149
150
151perl v5.30.0                     L2o0c1a9l-e0:7:-T2e6xtDomain::OO::Lexicon::StoreJSON(3)
Impressum