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.