in reply to Mojolicious i18n "inflate"

Using that script above everything works. But when i try to separate the language parts, the script not fail, but not translate the 'hello world' word.

Hi,

What happens if you add

# debug mode on BEGIN { $ENV{MOJO_I18N_DEBUG} = 1 };

Replies are listed 'Best First'.
Re^2: Mojolicious i18n "inflate"
by pazt (Acolyte) on Oct 09, 2016 at 04:36 UTC

    Hi beech,

    I don't know if i'd insert the "BEGIN { $ENV{MOJO_I18N_DEBUG} = 1 };" on right file/line. Sorry, i'm just mojolicious rookie yet.

    Anyway, my App.pl becomes:

    #!/usr/bin/perl use Mojolicious::Lite; BEGIN { $ENV{MOJO_I18N_DEBUG} = 1 }; plugin I18N => { namespace => 'App::I18N', support_url_langs => [qw(en fr pt_br)] }; get '/' => 'index'; app->start; __DATA__ @@ index.html.ep %= l 'hello world'

    And the response was:

    Server available at http://127.0.0.1:3000
    Load default namespace App::I18N::pt_br at /usr/local/share/perl/5.18.2/Mojolicious/Plugin/I18N.pm line 200.
    Create default namespace App::I18N::pt_br at /usr/local/share/perl/5.18.2/Mojolicious/Plugin/I18N.pm line 206.
    Load the I18N class App::I18N::pt_br::en at /usr/local/share/perl/5.18.2/Mojolicious/Plugin/I18N.pm line 216.
    Create the I18N class App::I18N::pt_br::en at /usr/local/share/perl/5.18.2/Mojolicious/Plugin/I18N.pm line 224.
    Load the I18N class App::I18N::pt_br::pt_br at /usr/local/share/perl/5.18.2/Mojolicious/Plugin/I18N.pm line 216.
    Load the I18N class App::I18N::pt_br::pt at /usr/local/share/perl/5.18.2/Mojolicious/Plugin/I18N.pm line 216.
    Load the I18N class App::I18N::pt_br::en_us at /usr/local/share/perl/5.18.2/Mojolicious/Plugin/I18N.pm line 216.
    Sat Oct 8 06:55:57 2016 debug GET "/"
    Sat Oct 8 06:55:57 2016 debug Rendering template "index.html.ep" from DATA section
    Sat Oct 8 06:55:57 2016 debug 200 OK (0.003052s, 327.654/s)

    The selected language on my browser is "pt_BR".
    And "MOJO_I18N_DEBUG" showed that "App.pl" isn't calling my pt_br.pm on I18N folder

    What's the next step?

    Thanks for your help

      Hi,

      It appears you need a dash  perl app.pl get / -H "Accept-Language: pt-br"

      Maybe the DEBUG option should have logged that pt_br is not recognized ... might be worth a bug report to the author

      FYI, FWIW, App::I18N exists :)

      Also, debug/log info is data, so Put <code> </code> tags around it

        beech,

        Finally it's works. The second "App" directory was missing.

        The right dir structure is:

        App |+- App.pl |- App | |- I18N | |- fr.pm | +- pt_br.pm

        Thank you very much for your help beech

        Maybe i'll create a github for the truly mojolicious rookies like me. haha
        It's an awesome web framework.