View on
Jesse Vincent > Jifty > Jifty::I18N



Annotate this POD


New  13
Open  3
Stalled  1
View/Report Bugs
Source   Latest Release: Jifty-1.50430


Jifty::I18N - Internationalization framework for Jifty


  # Whenever you need an internationalized string:
  print _('Hello, %1!', 'World');

In your Mason templates:

  <% _('Hello, %1!', 'World') %>



This module provides a method named _, which allows you to quickly and easily include localized strings in your application. The first argument is the string to translated. If that string contains placeholders, the remaining arguments are used to replace the placeholders. The placeholders in the form of "%1" where the number is the number of the argument used to replace it:

  _('Welcome %1 to the %2', 'Bob', 'World');

This example would return the string "Welcome Bob to the World" if no translation is being performed.


Set up Jifty's internationalization for your application. This pulls in Jifty's PO files, your PO files and then exports the _ function into the wider world.


Get list of patterns for all PO files in the project. (Paths are gotten from the configuration variables and plugins).


Get the lanauge language for this request.


Used by Jifty::Handler in DevelMode to reload .po files whenever they are modified on disk.

promote_encoding STRING [CONTENT-TYPE]

Return STRING promoted to our best-guess of an appropriate encoding. STRING should not have the UTF-8 flag set when passed in.

Optionally, you can pass a MIME content-type string as a second argument. If it contains a charset= parameter, we will use that encoding. Failing that, we use Encode::Guess to guess between UTF-8 and iso-latin-1. If that fails, and the string validates as UTF-8, we assume that. Finally, we fall back on returning the string as is.

maybe_decode_utf8 STRING

Attempt to decode STRING as UTF-8. If STRING is not valid UTF-8, or already contains wide characters, return it undecoded.

N.B: In an ideal world, we wouldn't need this function, since we would know whether any given piece of input is UTF-8. However, the world is not ideal.

syntax highlighting: