Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Disable use of fallback language in Locale::Maketext::Lexicon

by Eily (Monsignor)
on Oct 09, 2018 at 13:59 UTC ( [id://1223737]=note: print w/replies, xml ) Need Help??


in reply to Disable use of fallback language in Locale::Maketext::Lexicon

Hello njfranck. I suppose you meant "fallback_languages" rather than "language_languages"? If so, overwriting it actually (partially) works: the list of default it returns is ('i-default', 'en', 'en-US'), and both "i-default" and "en-US" are successfully removed as fallbacks when you have a Loc::fallback_languages defined.

But beside those fallbacks, Locale::Maketext also uses the panic languages from I18N::LangTags as seen here.

One way to disable that behaviour is to set $Locale::Maketext::USING_LANGUAGE_TAGS = 0;. I can't tell you what else it does though (it's not documented and I don't want to analyze the whole code).

Another way to it is to locally replace I18N::LangTags::panic_languages so that it returns the empty list. It's a little dirtier, but at least it's limited in scope:

package Loc; use parent "Locale::Maketext"; use Locale::Maketext::Lexicon { "en" => [ Gettext => \*main::DATA ] }; sub fallback_languages { }; package main; use Data::Dump qw( pp ); use strict; { # The effect of local will be reversed outside of this block local *I18N::LangTags::panic_languages = sub {}; print ( Loc->get_handle("nl") ? pp(Loc->get_handle("nl")) : "OK: got + undef" ); } # end of local, so limited side effects print "\n"; __DATA__ msgid "greet" msgstr "hello %1"
Notice that I still have Loc::fallback_languages to overwrite one set of defaults beside the panic languages ("en" is defined in both)

Replies are listed 'Best First'.
Re^2: Disable use of fallback language in Locale::Maketext::Lexicon
by njfranck (Initiate) on Oct 16, 2018 at 06:59 UTC
    Thanks for your reply! I'll have a look at it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1223737]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (1)
As of 2024-04-25 01:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found