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 for a complete program printing a duration in the locale language.

As of December 2013 available language modules on CPAN include

Time::Duration        English
Time::Duration::es    Spanish
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::es, 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, 2016, 2017 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/>.