コード例 #1
0
ファイル: util.php プロジェクト: himmelex/NTW
/**
 * Switch locale during runtime, and poke gettext until it cries uncle.
 * Otherwise, sometimes it doesn't actually switch away from the old language.
 *
 * @param string $language code for locale ('en', 'fr', 'pt_BR' etc)
 */
function common_switch_locale($language = null)
{
    common_init_locale($language);
    setlocale(LC_CTYPE, 'C');
    // So we do not have to make people install the gettext locales
    $path = common_config('site', 'locale_path');
    bindtextdomain("statusnet", $path);
    bind_textdomain_codeset("statusnet", "UTF-8");
    textdomain("statusnet");
}
コード例 #2
0
ファイル: util.php プロジェクト: Br3nda/laconica
function common_init_language()
{
    mb_internal_encoding('UTF-8');
    $language = common_language();
    // So we don't have to make people install the gettext locales
    $locale_set = common_init_locale($language);
    bindtextdomain("laconica", common_config('site', 'locale_path'));
    bind_textdomain_codeset("laconica", "UTF-8");
    textdomain("laconica");
    setlocale(LC_CTYPE, 'C');
    if (!$locale_set) {
        common_log(LOG_INFO, 'Language requested:' . $language . ' - locale could not be set:', __FILE__);
    }
}
コード例 #3
0
ファイル: mail.php プロジェクト: Br3nda/laconica
/**
 * notify a user that they have received an "attn:" message AKA "@-reply"
 *
 * @param User   $user   The user who recevied the notice
 * @param Notice $notice The notice that was sent
 *
 * @return void
 */
function mail_notify_attn($user, $notice)
{
    if (!$user->email || !$user->emailnotifyattn) {
        return;
    }
    $sender = $notice->getProfile();
    $bestname = $sender->getBestName();
    common_init_locale($user->language);
    $subject = sprintf(_('%s sent a notice to your attention'), $bestname);
    $body = sprintf(_("%1\$s just sent a notice to your attention (an '@-reply') on %2\$s.\n\n" . "The notice is here:\n\n" . "\t%3\$s\n\n" . "It reads:\n\n" . "\t%4\$s\n\n" . "You can reply back here:\n\n" . "\t%5\$s\n\n" . "The list of all @-replies for you here:\n\n" . "%6\$s\n\n" . "Faithfully yours,\n" . "%2\$s\n\n" . "P.S. You can turn off these email notifications here: %7\$s\n"), $bestname, common_config('site', 'name'), common_local_url('shownotice', array('notice' => $notice->id)), $notice->content, common_local_url('newnotice', array('replyto' => $sender->nickname)), common_local_url('replies', array('nickname' => $user->nickname)), common_local_url('emailsettings'));
    common_init_locale();
    mail_to_user($user, $subject, $body);
}
コード例 #4
0
/**
 * Send a mail message to notify a user that her Twitter bridge link
 * has stopped working, and therefore has been removed.  This can
 * happen when the user changes her Twitter password, or otherwise
 * revokes access.
 *
 * @param User $user   user whose Twitter bridge link has been removed
 *
 * @return boolean success flag
 */
function mail_twitter_bridge_removed($user)
{
    common_init_locale($user->language);
    $profile = $user->getProfile();
    $subject = sprintf(_m('Your Twitter bridge has been disabled.'));
    $site_name = common_config('site', 'name');
    $body = sprintf(_m('Hi, %1$s. We\'re sorry to inform you that your ' . 'link to Twitter has been disabled. We no longer seem to have ' . 'permission to update your Twitter status. (Did you revoke ' . '%3$s\'s access?)' . "\n\n" . 'You can re-enable your Twitter bridge by visiting your ' . "Twitter settings page:\n\n\t%2\$s\n\n" . "Regards,\n%3\$s\n"), $profile->getBestName(), common_local_url('twittersettings'), common_config('site', 'name'));
    common_init_locale();
    return mail_to_user($user, $subject, $body);
}
コード例 #5
0
/**
 * notify a user that one of their notices has been chosen as a 'fave'
 *
 * Doesn't check that the user has an email address nor if they
 * want to receive notification of faves. Maybe this happens higher
 * up the stack...?
 *
 * @param User   $other  The user whose notice was faved
 * @param User   $user   The user who faved the notice
 * @param Notice $notice The notice that was faved
 *
 * @return void
 */
function mail_notify_fave($other, $user, $notice)
{
    if (!$user->hasRight(Right::EMAILONFAVE)) {
        return;
    }
    $profile = $user->getProfile();
    $bestname = $profile->getBestName();
    common_init_locale($other->language);
    // TRANS: Subject for favorite notification email
    $subject = sprintf(_('%s (@%s) added your notice as a favorite'), $bestname, $user->nickname);
    // TRANS: Body for favorite notification email
    $body = sprintf(_("%1\$s (@%7\$s) just added your notice from %2\$s" . " as one of their favorites.\n\n" . "The URL of your notice is:\n\n" . "%3\$s\n\n" . "The text of your notice is:\n\n" . "%4\$s\n\n" . "You can see the list of %1\$s's favorites here:\n\n" . "%5\$s\n\n" . "Faithfully yours,\n" . "%6\$s\n"), $bestname, common_exact_date($notice->created), common_local_url('shownotice', array('notice' => $notice->id)), $notice->content, common_local_url('showfavorites', array('nickname' => $user->nickname)), common_config('site', 'name'), $user->nickname);
    $headers = _mail_prepare_headers('fave', $other->nickname, $user->nickname);
    common_init_locale();
    mail_to_user($other, $subject, $body, $headers);
}
コード例 #6
0
<?php

if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
    print "This script must be run from the command line\n";
    exit;
}
define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
define('GNUSOCIAL', true);
define('STATUSNET', true);
// compatibility
require_once INSTALLDIR . '/scripts/commandline.inc';
require_once INSTALLDIR . '/extlib/php-gettext/gettext.inc';
common_init_locale("en_US");
common_init_locale('fr');
putenv("LANG=fr");
putenv("LANGUAGE=fr");
setlocale('fr.utf8');
_setlocale('fr.utf8');
_bindtextdomain("statusnet", INSTALLDIR . '/locale');
_bindtextdomain("FeedSub", INSTALLDIR . '/plugins/FeedSub/locale');
$times = 10000;
$delta = array();
$start = microtime(true);
for ($i = 0; $i < $times; $i++) {
    $result = _("Send");
}
$delta["_"] = array((microtime(true) - $start) / $times, $result);
$start = microtime(true);
for ($i = 0; $i < $times; $i++) {
    $result = __("Send");
}
コード例 #7
0
/**
 * Send a mail message to notify a user that her Facebook Application
 * access has been removed.
 *
 * @param User $user   user whose Facebook app link has been removed
 *
 * @return boolean success flag
 */
function mail_facebook_app_removed($user)
{
    common_init_locale($user->language);
    $profile = $user->getProfile();
    $site_name = common_config('site', 'name');
    $subject = sprintf(_m('Your %1$s Facebook application access has been disabled.', $site_name));
    $body = sprintf(_m("Hi, %1\$s. We're sorry to inform you that we are " . 'unable to update your Facebook status from %2$s, and have disabled ' . 'the Facebook application for your account. This may be because ' . 'you have removed the Facebook application\'s authorization, or ' . 'have deleted your Facebook account.  You can re-enable the ' . 'Facebook application and automatic status updating by ' . "re-installing the %2\$s Facebook application.\n\nRegards,\n\n%2\$s"), $user->nickname, $site_name);
    common_init_locale();
    return mail_to_user($user, $subject, $body);
}