[vhffs-dev] [2192] fixed gettext support for welcome messages |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 2192
Author: gradator
Date: 2012-05-13 00:29:35 +0200 (Sun, 13 May 2012)
Log Message:
-----------
fixed gettext support for welcome messages
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Robots/User.pm
Modified: trunk/vhffs-api/src/Vhffs/Robots/User.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/User.pm 2012-05-12 15:40:18 UTC (rev 2191)
+++ trunk/vhffs-api/src/Vhffs/Robots/User.pm 2012-05-12 22:29:35 UTC (rev 2192)
@@ -31,7 +31,12 @@
use strict;
use utf8;
-use POSIX;
+
+package Vhffs::Robots::User;
+
+use POSIX qw(locale_h);
+use locale;
+use Locale::gettext;
use Quota;
use File::Path;
use File::Basename;
@@ -41,8 +46,6 @@
use Vhffs::Robots;
use Vhffs::User;
-package Vhffs::Robots::User;
-
sub create {
my $user = shift;
return undef unless defined $user and $user->get_status == Vhffs::Constants::WAITING_FOR_CREATION;
@@ -68,11 +71,20 @@
chown $user->get_uid, $user->get_gid, $dir;
chmod 0700, $dir;
+ # TODO: write a beautiful module for INTL
+ bindtextdomain('vhffs', '%localedir%');
+ textdomain('vhffs');
+
+ my $prevlocale = setlocale( LC_ALL );
+ setlocale( LC_ALL, $user->get_lang );
+
my $subject = sprintf( gettext('Account created on %s'), $vhffs->get_config->get_host_name );
my $content = sprintf( gettext("Hello %s %s,\n\nWe are pleased to announce that your account is now fully created on\n%s.\nYou can now login on the panel.\n\n%s Administrators\n"),
$user->get_firstname, $user->get_lastname, $vhffs->get_config->get_host_name, $vhffs->get_config->get_host_name );
$user->send_mail_user( $subject, $content );
+ setlocale( LC_ALL, $prevlocale );
+
Vhffs::Robots::vhffs_log( $vhffs, 'Created home dir for user '.$user->get_username );
$user->set_status( Vhffs::Constants::ACTIVATED );
$user->commit;