Catalyst-Plugin-I18N-PathPrefix

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN


    You can wrap this method (using eg. the "after" in Moose method
    modifier) so you can store the language code into the stash if you like:

      after prepare_path_prefix => sub {
        my $c = shift;

        $c->stash('language' => $c->language);
      };

  uri_for_in_language
      $c->uri_for_in_language($language_code => @uri_for_args)

    Returns: $uri_object

    The same as "uri_for" in Catalyst but returns the URI with the
    $language_code path prefix (independently of what the current language
    is).

    Internally this method temporarily sets the paths in "$c->req", calls
    "uri_for" in Catalyst then resets the paths. Ineffective, but you
    usually call it very infrequently.

    Note: You should not call this method to generate language-independent
    paths, as it will generate invalid URLs currently (ie. the language
    independent path prefixed with the language prefix).

    Note: This module intentionally does not override "uri_for" in Catalyst
    but provides this method instead: "uri_for" in Catalyst is usually
    called many times per request, and most of the cases you want it to use
    the current language; not overriding it can be a significant performance
    saving. YMMV.

  switch_language
      $c->switch_language($language_code)

    Returns: N/A

    Changes "$c->req->base" to end with $language_code and calls
    "$c->set_languages_from_language_prefix" with $language_code.

    Useful if you want to switch the language later in the request
    processing (eg. from a request parameter, from the session or from the
    user object).

  language_switch_options
      $c->language_switch_options()

    Returns: "{ $language_code => { name => $language_name, uri => $uri },
    ... }"

    Returns a data structure that contains all the necessary data (language
    code, name, URL of the same page) for displaying a language switch
    widget on the page.

    The data structure is a hashref with one key for each valid language
    code (see the "valid_languages" config option) (in all-lowercase format)
    and the value is a hashref that contains the following key-value pairs:

    name
        The localized (translated) name of the language. (The actual msgid
        used in "$c->loc()" is the English name of the language, returned by
        "name" in I18N::LangTags::List.)

    url The URL of the equivalent of the current page in that language (ie.
        the language prefix replaced).

    You can find an example TT2 HTML template for the language switch
    included in the distribution.

SEE ALSO
    Catalyst::Plugin::I18N, Catalyst::TraitFor::Request::PerLanguageDomains

AUTHOR
    Norbert Buchmuller, "<norbi at nix.hu>"

TODO
    make "uri_for_in_language" work on language-independent URIs
    support locales instead of language codes

BUGS
    Please report any bugs or feature requests to
    "bug-catalyst-plugin-i18n-pathprefix at rt.cpan.org", or through the web
    interface at
    <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Catalyst-Plugin-I18N-Pat
    hPrefix>. I will be notified, and then you'll automatically be notified
    of progress on your bug as I make changes.

SUPPORT
    You can find documentation for this module with the perldoc command.

        perldoc Catalyst::Plugin::I18N::PathPrefix

    You can also look for information at:

    *   RT: CPAN's request tracker

        <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Catalyst-Plugin-I18N-PathP
        refix>

    *   AnnoCPAN: Annotated CPAN documentation

        <http://annocpan.org/dist/Catalyst-Plugin-I18N-PathPrefix>

    *   CPAN Ratings

        <http://cpanratings.perl.org/d/Catalyst-Plugin-I18N-PathPrefix>

    *   Search CPAN

        <http://search.cpan.org/dist/Catalyst-Plugin-I18N-PathPrefix/>

ACKNOWLEDGEMENTS
    Thanks for Larry Leszczynski for the idea of appending the language
    prefix to "$c->req->base" after it's split off of "$c->req->path"
    (<http://dev.catalystframework.org/wiki/wikicookbook/urlpathprefixing>).

    Thanks for Tomas (t0m) Doran <bobtfish@bobtfish.net> for the code
    reviews, improvement ideas and mentoring in general.

COPYRIGHT & LICENSE



( run in 0.659 second using v1.01-cache-2.11-cpan-97f6503c9c8 )