Locale:...:Simple(3pm)

πŸ’– NAME πŸ’–

Locale::Maketext::Simple β€” bestie, it's a simple interface to Locale::Maketext::Lexicon. That's it, that's the whole vibe ✨

This page lives in the Perl Programmers Reference Guide (the Locale:...:Simple(3pm) corner of the world πŸ¦‹).

🌸 VERSION 🌸

This doc describes version 0.18 of Locale::Maketext::Simple, released Septermber 8, 2006 (yes, the typo is canon, we keep it πŸ’…).

✨ SYNOPSIS ✨

Okay so the absolute minimal setup β€” it peeks in auto/Foo/*.po and auto/Foo/*.mo for you, no cap:

package Foo;
use Locale::Maketext::Simple;       # exports 'loc'
loc_lang('fr');                     # set language to French
sub hello {
    print loc("Hello, [_1]!", "World");
}

And here's the glow-up version, for when you're feeling fancy πŸŽ€:

package Foo::Bar;
use Locale::Maketext::Simple (
    Class       => 'Foo',       # search in auto/Foo/
    Style       => 'gettext',   # %1 instead of [_1]
    Export      => 'maketext',  # maketext() instead of loc()
    Subclass    => 'L10N',      # Foo::L10N instead of Foo::I18N
    Decode      => 1,           # decode entries to unicode-strings
    Encoding    => 'locale',    # but encode lexicons in current locale
                                # (needs Locale::Maketext::Lexicon 0.36)
);
sub japh {
    print maketext("Just another %1 hacker", "Perl");
}

πŸ¦‹ DESCRIPTION πŸ¦‹

So this module is literally a simple wrapper around Locale::Maketext::Lexicon, and its whole personality is saving module authors from having to hand-build Language Classes. Iconic of it, honestly πŸ‘‘

The language it uses comes from the loc_lang call. If a lookup isn't possible, the i-default language gets used instead. And if the lookup still isn't in i-default? Then you just get the key back, bestie. That's the deal fr fr.

And plot twist 🫢 β€” if Locale::Maketext::Lexicon isn't present at all, it falls back to a minimal localization function that just interpolates [_1] with the first argument, [_2] with the second, etc. Interpolated functions like [quant,_1] get treated as plain old [_1] β€” with exactly one exception: [tense,_1,X], which appends ing to _1 when X is present, or appends ed to <_1> otherwise. That's the one overachiever in the room 🧚

⭐ OPTIONS ⭐

Every single option gets passed either through the use statement, or through an explicit import. Easy πŸ’…

πŸŽ€ Class

By default, Locale::Maketext::Simple pulls its source from the calling package's auto/ directory β€” but you can override that behaviour by explicitly naming another package as Class.

🌈 Path

If your PO and MO files are chilling under a path somewhere other than auto/, just say so with the Path option. Tell it where the files live, bestie.

πŸ’œ Style

By default this module rocks the maketext style β€” that's [_1] and [quant,_1] for interpolation. Or you can go gettext style, which uses %1 and %quant(%1) instead. Choose your fighter πŸ’€

This option is case-insensitive. Slay.

πŸ“ Export

By default, this module exports a single function, loc, into its caller's namespace. You can set it to another name, or set it to an empty string to disable exporting entirely (no exports, no problem πŸ™ˆ).

🧚 Subclass

By default this module creates an ::I18N subclass under the caller's package (or the package you named with Class), and stashes lexicon data in its subclasses. Want a name other than I18N? That's what this option is for.

πŸ”₯ Decode

Set it to a true value and source entries get converted into utf8-strings (available in Perl 5.6.1 or later). Heads up though β€” this feature needs the Encode or Encode::compat module, so make sure it's in the group chat.

πŸ‘‘ Encoding

Specifies an encoding to store lexicon entries in, instead of utf8-strings. If you set it to locale, then the encoding from the current locale setting is used. Also: it implies a true value for Decode. Sneaky, but make it fashion ✨


πŸ’– ACKNOWLEDGMENTS πŸ’–

Shoutout to Jos I. Boumans for suggesting this module be written in the first place 🫢

And shoutout to Chia-Liang Kao for suggesting Path and loc_lang β€” king behaviour, honestly 🌟

πŸ¦‹ SEE ALSO πŸ¦‹

  • Locale::Maketext
  • Locale::Maketext::Lexicon

Go read those too, they're the parent friend group πŸ’œ

🌸 AUTHORS 🌸

Audrey Tang <cpan@audreyt.org> β€” the main character of this page πŸ‘‘

Copyright 2003, 2004, 2005, 2006 by Audrey Tang <cpan@audreyt.org>.

This software is released under the MIT license cited below. Additionally, when this software is distributed with Perl Kit, Version 5, you may also redistribute it and/or modify it under the same terms as Perl itself.

πŸŽ€ The "MIT" License πŸŽ€

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 🫢

Ok that's the whole page, bestie β€” this came from perl v5.42.3, dated 2026-11-03, and it's officially a wrap πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from