<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">NAME

    Mojolicious::Plugin::I18NUtils - provide some helper functions for I18N

VERSION

    version 0.21

SYNOPSIS

    In your startup:

        sub startup {
            my $self = shift;
      
            # do some Mojolicious stuff
            $self-&gt;plugin( 'I18NUtils' );
    
            # more Mojolicious stuff
        }

    In your template:

        &lt;%= datetime_loc('2014-12-10', 'de') %&gt;

CONFIGURE

    If you use a default format other than %Y-%m-%d %H:%M:%S for dates in
    your application, you can set a format for the parser. E.g. if your
    dates look like

      10.12.2014 12:34:56

    You can add the plugin this way

      $self-&gt;plugin( I18NUtils =&gt; { format =&gt; '%d.%m.%Y %H:%M:%S' } );

HELPERS

    This plugin adds those helper methods to your web application:

 browser_languages

    Return a list of languages defined in the Accept-Language header.

      my @languages = $c-&gt;browser_languages;

    or

      your browser accepts those languages: &lt;%= join ', ', browser_languages() %&gt;

    Samples:

      Accept-Language: en-ca,en;q=0.8,en-us;q=0.6,de-de;q=0.4,de;q=0.2

    returns

      your browser accepts those languages: en-ca, en, en-us, de-de, de

 datetime_loc

    This helper returns the givent date and time in the localized format.

     &lt;%= datetime_loc('2014-12-10 11:12:13', 'de') %&gt;

    will return

     10.12.2014 11:12:13

    If you omit the language it will be retrieved from Accept-Language
    header

     &lt;%= datetime_loc('2014-12-10 11:12:13') %&gt;
     # Accept-Language: de, en;q=0.8

    will return

     10.12.2014 11:12:13

 date_loc

    Same as datetime_loc, but omits the time

     &lt;%= date_loc('2014-12-10 11:12:13', 'de') %&gt;

    will return

     10.12.2014

    If you omit the language it will be retrieved from Accept-Language
    header

     &lt;%= date_loc('2014-12-10 11:12:13') %&gt;
     # Accept-Language: de, en;q=0.8

    will return

     10.12.2014

 currency

    If you need to handle prices, the helper currency might help you

      &lt;%= currency(1111.99, 'ar', 'EUR') %&gt;
      &lt;%= currency(1111.99, 'de', 'EUR') %&gt;
      &lt;%= currency(1111.99, 'en', 'EUR') %&gt;

    will return

      竄ｬ ﾙ｡ﾙｬﾙ｡ﾙ｡ﾙ｡ﾙｫﾙｩﾙｩ
      1.111,99 竄ｬ
      竄ｬ1,111.99 

    If you omit the language it will be retrieved from Accept-Language
    header

     &lt;%= currency(1111.99, 'EUR') %&gt;
     # Accept-Language: de, en;q=0.8

    will return

     1.111,99 竄ｬ

 decimal

      &lt;%= decimal( 2000, 'ar' ) %&gt;
      &lt;%= decimal( 2000, 'de' ) %&gt;
      &lt;%= decimal( 2000, 'en' ) %&gt;

    will return

      ﾙ｢ﾙｬﾙ�ﾙ�ﾙ�
      2.000
      2,000

    If you omit the language it will be retrieved from Accept-Language
    header

     &lt;%= decimal( 2000 ) %&gt;
     # Accept-Language: de, en;q=0.8

    will return

     2.000

 range

      &lt;%= range(1, 2000, 'ar' ) %&gt;
      &lt;%= range(1, 2000, 'de' ) %&gt;
      &lt;%= range(1, 2000, 'en' ) %&gt;

    will return

      ﾙ｡窶遁｢ﾙｬﾙ�ﾙ�ﾙ�
      1窶�2.000
      1窶�2,000

    If you omit the language it will be retrieved from Accept-Language
    header

     &lt;%= range( 1, 2000 ) %&gt;
     # Accept-Language: de, en;q=0.8

    will return

      1窶�2.000

 at_least

      &lt;%= at_least( 2000, 'ar' ) %&gt;
      &lt;%= at_least( 2000, 'de' ) %&gt;
      &lt;%= at_least( 2000, 'en' ) %&gt;

    will return

      +ﾙ｢ﾙｬﾙ�ﾙ�ﾙ�
      2.000+
      2,000+

    If you omit the language it will be retrieved from Accept-Language
    header

     &lt;%= at_least( 2000 ) %&gt;
     # Accept-Language: de, en;q=0.8

    will return

      2.000+

METHODS

 register

    Called when registering the plugin.

        # load plugin, alerts are dismissable by default
        $self-&gt;plugin( 'I18NUtils' );

AUTHOR

    Renee Baecker &lt;reneeb@cpan.org&gt;

COPYRIGHT AND LICENSE

    This software is Copyright (c) 2017 by Renee Baecker.

    This is free software, licensed under:

      The Artistic License 2.0 (GPL Compatible)

</pre></body></html>