Kevin Ryde > Time-Duration-Locale-10 > Time::Duration::Locale

Download:
Time-Duration-Locale-10.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 10   Source  

NAME ^

Time::Duration::Locale - time duration string chosen by user's language preferences

SYNOPSIS ^

 use Time::Duration::Locale;
 print "next update ",duration(150),"\n";

DESCRIPTION ^

Time::Duration::Locale has the same interface as Time::Duration but chooses a language according to the user's locale settings. See examples/simple.pl in the Time-Duration-Locale sources for a complete program printing a duration in the locale language.

As of January 2013 available language modules on CPAN include

    Time::Duration        English
    Time::Duration::fr    French
    Time::Duration::id    Indonesian
    Time::Duration::ja    Japanese
    Time::Duration::pl    Polish
    Time::Duration::pt    Portuguese
    Time::Duration::sv    Swedish

If the user's locale setting is not one of these then the fallback is the English module.

EXPORTS ^

Like Time::Duration, the following functions are exported by default

    later()       later_exact()
    earlier()     earlier_exact()
    ago()         ago_exact()
    from_now()    from_now_exact()
    duration()    duration_exact()
    concise()

EXTRA FUNCTIONS ^

The following extra functions are provided by Time::Duration::Locale and are not exported.

Time::Duration::Locale::setlocale ()

Set the language from the current locale environment variables etc. The current implementation uses I18N::LangTags::Detect.

This is done automatically the first time one of the duration functions is called. But call it explicitly if you change the environment variables etc later and want Time::Duration::Locale to follow the new values.

$lang = Time::Duration::Locale::language ()
$module = Time::Duration::Locale::module ()
Time::Duration::Locale::language ($lang)
Time::Duration::Locale::module ($module)

Get or set the language to use, either in the form of a language code like "en" or "ja", or a module name like "Time::Duration" or "Time::Duration::ja".

undef means a language has not been chosen yet. When setting the language the necessary module must exist and is loaded if not already loaded.

ENVIRONMENT VARIABLES ^

LANGUAGE, LANG, LC_MESSAGES etc, as per I18N::LangTags::Detect.

SEE ALSO ^

Time::Duration::LocaleObject, Time::Duration, Time::Duration::fr, Time::Duration::id, Time::Duration::ja, Time::Duration::pl, Time::Duration::pt, Time::Duration::sv, I18N::LangTags::Detect

HOME PAGE ^

http://user42.tuxfamily.org/time-duration-locale/index.html

COPYRIGHT ^

Copyright 2009, 2010, 2011, 2013 Kevin Ryde

Time-Duration-Locale is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

Time-Duration-Locale is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Time-Duration-Locale. If not, see <http://www.gnu.org/licenses/>.

syntax highlighting: