NAME
    Dancer::Plugin::SimpleLexicon - Tiny Dancer interface to
    Locale::Maketext::Lexicon

VERSION
    Version 0.01

SYNOPSIS
    In your configuration:

      plugins:
        SimpleLexicon:
          path: languages
          session_name:   lang
          param_name:     lang
          var_name:       lang
          default:        en
          encoding: UTF-8
          langs:
            en:    "US English"
            de:       "Deutsch"
            nl:       "Netherlands"
            se:       "Sweden"
            it:       "Italiano"

    In your module

        use Dancer ':syntax';
        use Dancer::Plugin::SimpleLexicon;
        var lang => 'it';
        my $string = l('Hello %s', 'Marco');
        # assuming languages/it.po have a translation for this, will return "Ciao Marco"

SETTINGS
    This module is a tiny alternative to Dancer::Plugin::Lexicon. See what
    it works best for you.

    Explanation of the settings.

  path
    The path, absolute or relative, to the `.po' files. The `.po' files must
    be named as the defined language tags (see below).

  langs
    An array of keys/values with the language tag and the full name on the
    language.

    Please note that if you define a language "it", the file
    `languages/it.po' must be present.

  param_name
    If specified, when determining the language, the module will try to
    lookup the key in the request parameters (`param').

  session_name
    The key of the `session' where to read and store the current language.
    If not specified, the session is not touched.

  var_name
    The name of the Dancer `var' to read when determining the current
    language.

  default
    The value of the default language. If not specified, and the looking up
    in the above values fails, no translation will be done.

  encoding
    The string returned by maketext will be decoded using this encoding. By
    default is `UTF-8'.

    To disable the decoding, set it to `raw'.

EXPORT
  l($string, @args)
    Return the translation for $string. If optional arguments are provided,
    pass the string to sprintf with the arguments.

  language
    Return the current language used, returning the long name of the
    language as defined in the configuration.

    The priority set is follow: param, session, var, default. The first
    wins, assuming it was defined in the config. Unclear if it's the right
    thing to do. TODO: make this configurable or at runtime.

  set_language($language_tag)
    Set the current language to $language_tag, writing it into the session,
    using the key specified in the `session_name' value.

Dancer::Template::TemplateFlute integration
    In the configuration:

      engines:
        template_flute:
          i18n:
            class: My::Lexicon
            method: localize
      plugins:
        SimpleLexicon:
          path: languages
          session_name:   lang
          param_name:     lang
          var_name:       lang
          default:        en
          encoding: UTF-8
          langs:
            en:    "US English"
            de:    "Deutsch"
            nl:    "Netherlands"
            se:    "Sweden"

    And write the tiny class My::Lexicon wit the following content:

      package My::Lexicon;
      use Dancer ':syntax';
      use Dancer::Plugin::SimpleLexicon;
      use Encode;
  
      sub new {
          my $class = shift;
          my $self = {};
          bless $self, $class;
      }
  
      sub localize {
          my ($self, $string) = @_;
          my $translated = l($string);
          return $translated;
      }
  
      1;

AUTHOR
    Marco Pessotto, `<melmothx at gmail.com>'

BUGS
    Please report any bugs or feature requests to
    `bug-dancer-plugin-simplelexicon at rt.cpan.org', or through the web
    interface at
    http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Dancer-Plugin-SimpleLexic
    on. 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 Dancer::Plugin::SimpleLexicon

    You can also look for information at:

    * RT: CPAN's request tracker (report bugs here)
        http://rt.cpan.org/NoAuth/Bugs.html?Dist=Dancer-Plugin-SimpleLexicon

    * AnnoCPAN: Annotated CPAN documentation
        http://annocpan.org/dist/Dancer-Plugin-SimpleLexicon

    * CPAN Ratings
        http://cpanratings.perl.org/d/Dancer-Plugin-SimpleLexicon

    * Search CPAN
        http://search.cpan.org/dist/Dancer-Plugin-SimpleLexicon/

ACKNOWLEDGEMENTS
LICENSE AND COPYRIGHT
    Copyright 2014 Marco Pessotto.

    This program is free software; you can redistribute it and/or modify it
    under the terms of either: the GNU General Public License as published
    by the Free Software Foundation; or the Artistic License.

    See http://dev.perl.org/licenses/ for more information.

