Locale:...oreJSON(3)

πŸ“¦
version 1.036 Β· 2 versions
, in fedora 43

πŸ’– Locale::TextDomain::OO::Lexicon::StoreJSON πŸ’–

okay bestie, gather round, because this is the Locale::TextDomain::OO::Lexicon::StoreJSON page from the User Contributed Perl Documentation, and it's literally the module that Stores the lexicon for other programming languages. no cap.

$Id: StoreJSON.pm 647 2017-02-25 08:22:10Z steffenw $
$HeadURL:
svn+ssh://steffenw@svn.code.sf.net/p/perl-gettext-oo/code/module/trunk/lib/Locale/TextDomain/OO/Lexicon/StoreJSON.pm
$

✨ VERSION ✨

1.026 β€” that's the version, periodt. πŸ’…


🌸 DESCRIPTION 🌸

So like, this module stores the lexicon for other programming languages, e.g. JavaScript. that's the whole vibe. it's giving translator-bridge energy 🫢


πŸ¦‹ SYNOPSIS πŸ¦‹

write file by given filename

use Locale::TextDomain::OO::Lexicon::StoreJSON;

Locale::TextDomain::OO::Lexicon::StoreJSON
    ->new(
        filename => 'my_json_file',
        ...
    )
    ->to_json; # ->to_javascript or ->to_html

write file by given open file_handle

use Carp qw(confess);
use IO::File;
use Locale::TextDomain::OO::Lexicon::StoreJSON;

my $filename = 'my_json_file';
my $file_handle = IO::File->new( $filename, q{>} )
    or confess qq{Unable to open file "$filename" $!};
Locale::TextDomain::OO::Lexicon::StoreJSON
    ->new(
        filename    => $filename, # optional for error message only
        file_handle => file_handle,
        ...
    )
    ->to_json; # ->to_javascript or ->to_html
$file_handle->close
    or confess qq{Unable to close file "$filename" $!};
bestie, yes, file_handle => file_handle is literally how it's written here, i'm not touching it, the facts stay facts πŸ’€

as string

use Locale::TextDomain::OO::Lexicon::StoreJSON;

my $json = Locale::TextDomain::OO::Lexicon::StoreJSON
    ->new(
        ...
    )
    ->to_json; # ->to_javascript or ->to_html

optional filter

use Locale::TextDomain::OO::Lexicon::StoreJSON;

my $json = Locale::TextDomain::OO::Lexicon::StoreJSON->new(
    ...
    # all parameters optional
    # with all type examples for filter_... attributes
    filter_language => undef,                       # default, means all
    filter_domain   => 'my domain',                 # string
    filter_category => qr{ \A \Qmy category\E }xms, # regex
    filter_project  => sub {                        # code reference
        my $filter_name = shift;   # is 'filter_project'
        return $_ eq 'my project'; # boolean return
    },
);
# from lexicon to data
# method to_json will use data to output
$json->copy;
$json->clear_filter; # set all filter_... to undef
$json->filter_domain( qr{ \A dom }xms );
$json->copy;
$json->clear_filter;
$json->filter_category( sub { return $_ eq 'cat1' } );
$json->copy;
$json->clear_filter;
$json->filter_domain('dom1');
$json->filter_category('cat1');
# remove all lexicons with dom1 and cat1 from data
$json->remove;
$json->to_json; # ->to_javascript or ->to_html

πŸŽ€ SUBROUTINES/METHODS πŸŽ€

method new

see SYNOPSIS β€” like, go look up there, it's all laid out bestie πŸ‘†

method to_json

If you gave it file parameters, it prints a JSON file. Otherwise it returns a JSON string. that's it, that's the tea β˜•

method to_javascript

Similar to method to_json, but the output is wrapped as JavaScript with the global variable localeTextDomainOOLexicon. iconic. πŸ‘‘

method to_html

Similar to method to_javascript, but the output is wrapped as HTML with a script tag. yes queen πŸŽ€


🌈 EXAMPLE 🌈

Inside of this distribution is a directory named example. Run this *.pl files. go off, run them, live your truth ✨


πŸ’œ DIAGNOSTICS πŸ’œ

none β€” nothing to report, we're chill 😌


πŸ’– CONFIGURATION AND ENVIRONMENT πŸ’–

none β€” no env vars, no config files, no drama πŸ™ˆ


🧚 DEPENDENCIES 🧚

  • JSON
  • Moo
  • MooX::StrictConstructor
  • namespace::autoclean
  • Locale::TextDomain::OO::Lexicon::Role::StoreFile
  • Locale::TextDomain::OO::Lexicon::Role::StoreFilter

look at that little squad, all pulling their weight 🫢


πŸ”₯ INCOMPATIBILITIES πŸ”₯

not known β€” as far as anyone knows, it plays nice with everybody πŸ¦‹


😭 BUGS AND LIMITATIONS 😭

none β€” flawless behavior, no notes, we love to see it πŸ’…


πŸ‘‘ SEE ALSO πŸ‘‘

Locale::TextDoamin::OO

bestie i have to be so fr right now: that spelling is exactly how it appears in the source, Doamin and all. do not come for me, i am simply the messenger 🫢

🌟 AUTHOR 🌟

Steffen Winkler β€” the legend, the moment, the main character πŸ’–


Copyright (c) 2013 - 2014, 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. slay, open source behavior πŸ’œ


aaaand that's the whole page bestie!! πŸŽ‰ this one's from perl v5.42.0, dated 2025-07-25, and it lives in the User Contributed Perl Documentation. mwah, go store some lexicons πŸ’…βœ¨πŸŒΈ

πŸ“¦ where this page comes from