Whilst developing the Perl module Locale::MaybeMaketext (now available on CPAN!) , I started off in in one direction but decided it was all overkill in more than one way - but at least it helped me ease back into Perl development.
I've kept this code though as it may be useful for myself, or others, to revisit in the future. For example, it has:
- Various in-built language detection files (based on third party code which was difficult to invoke seperately/directly) within
Detectors
- It has a better language code validator (
LanguageCodeValidator
) which is based off RFC5646 meaning it can cope with language codes such asen-latn-gb-u-jxds-t-cklsd-tester-dlsk-cx
along with "grandfathered" codes such asen-gb-oed
and can handle alternatives (such as convertingen-uk
toen-gb
and can be updated from the IANA list usingtools/build_alternatives.pl
- Has got the ability to change alternatives (see above) using
Alternatives
andSupers
(including all permutations of any language extensions) - Has a very flexible configuration system(
LanguageFinder
andLanguageFinderProcessor
) allowing you to specify in detail how a language code should be detected and handled (want to check the CLI first and then expand any alternatives before checking web codes - then that is possible!) - Has a nifty
PackageLoader
which can check if a module is already loaded, load it (and handle errors appropriately) and double check if it was actually loaded or failed on loading. - Has its own mock system (in
t/lib/Locale/MaybeMaketext/Tests/Overrider
) which not only allows classes/packages to be easily mocked for testing, but also for file system level calls (such asopen
,close
andread
) to be mocked. - Has quite extensive testing of all of the above (although the tests are probably outdated by now)
Hopefully some use will come to this unused code! It's MIT licensed so feel free to play!