Permalink
Browse files

Merge branch 'master' of github.com:newsapps/wordpress-mtv

  • Loading branch information...
2 parents a702f13 + c4db956 commit 0f3e99505106a3cbd31df4ee6f151236d4eaae91 @ryanmark ryanmark committed Dec 8, 2011
Showing with 96 additions and 17 deletions.
  1. +1 −0 .gitignore
  2. +5 −4 http.php
  3. BIN locale/mtv-es_ES.mo
  4. +75 −0 locale/mtv-es_ES.po
  5. +2 −0 wp-plugin.php
  6. +13 −13 wp/models.php
View
@@ -1 +1,2 @@
.DS_Store
+*.pot
View
@@ -25,7 +25,7 @@ function urlresolver( $kwargs ) {
$url = get_default($_REQUEST, 'url', '');
if ( !isset($url_patterns) )
- throw new BadFunctionCallException('url_patterns keyword argument required');
+ throw new BadFunctionCallException(__('url_patterns keyword argument required', 'mtv'));
try {
@@ -69,7 +69,8 @@ function resolve($url, $url_patterns) {
// we found a match!
// Check to see if the function exists
- if ( ! function_exists( $view ) ) throw new BadFunctionCallException("Can't find view function: $view");
+ if ( ! function_exists( $view ) ) throw new BadFunctionCallException(
+ sprintf(__("Can't find view function: %s", 'mtv'), $view));
// pass the match array to the view function
call_user_func( $view, array_slice($matches, 1) );
@@ -87,7 +88,7 @@ function include_urls_for($app_name) {
include $registered_apps[$app_name]['urls'];
return $url_patterns;
} else
- throw new Exception("MTV App $app_name has no urls.php");
+ throw new Exception(sprintf(__("MTV App %s has no urls.php", 'mtv'), $app_name));
}
class HttpException extends Exception {
@@ -189,7 +190,7 @@ class AjaxHttp404 extends HttpException {
public function display_message() {
$response = array(
'exception' => $this,
- 'error' => 'Callback not found',
+ 'error' => __('Callback not found', 'mtv'),
);
shortcuts\display_json($response);
}
View
Binary file not shown.
View
@@ -0,0 +1,75 @@
+# Copyright (C) 2010
+# This file is distributed under the same license as the package.
+msgid ""
+msgstr ""
+"Project-Id-Version: MTV 1.0\n"
+"Report-Msgid-Bugs-To: https://github.com/newsapps/wordpress-mtv\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"PO-Revision-Date: 2011-12-08 17:09:28+00:00\n"
+"Last-Translator: Ryan Nagle <rnagle@tribune.com>\n"
+
+#: http.php:28
+msgid "url_patterns keyword argument required"
+msgstr ""
+
+#: http.php:73
+msgid "Can't find view function: %s"
+msgstr ""
+
+#: http.php:91
+msgid "MTV App %s has no urls.php"
+msgstr ""
+
+#: http.php:193
+msgid "Callback not found"
+msgstr ""
+
+#: wp/models.php:118
+msgid "Couldn't update the post"
+msgstr ""
+
+#: wp/models.php:136
+msgid "Need a blogid and post id to fetch a post"
+msgstr ""
+
+#: wp/models.php:141
+msgid "Post not found"
+msgstr ""
+
+#: wp/models.php:345
+msgid "Post is not an attachment"
+msgstr ""
+
+#: wp/models.php:529
+msgid "Please enter your user name or email address."
+msgstr "Por favor"
+
+#: wp/models.php:531
+msgid "Please enter your password."
+msgstr ""
+
+#: wp/models.php:584 wp/models.php:662
+msgid "I don't know that email address"
+msgstr ""
+
+#: wp/models.php:587
+msgid "I don't know that user name"
+msgstr ""
+
+#: wp/models.php:665
+msgid "I don't know that username"
+msgstr ""
+
+#: wp/models.php:727
+msgid "Invalid activation key."
+msgstr ""
+
+#: wp/models.php:730
+msgid "This account is already activated."
+msgstr ""
+
+#: wp/models.php:742
+msgid "Could not create user"
+msgstr ""
View
@@ -89,6 +89,8 @@
add_action( 'init', function() {
+ load_plugin_textdomain('mtv', false, basename(__DIR__) . '/locale/');
+
/**
* Is our chosen theme an MTV theme?
* If not, we don't want to hijack rewrite rules and template selection
View
@@ -115,7 +115,7 @@ public function save() {
if ( is_wp_error( $postid ) )
throw new Exception($postid->get_error_message());
else if ( $postid == 0 )
- throw new Exception("Couldn't update the post");
+ throw new Exception(__("Couldn't update the post"));
if ( ! empty( $meta ) ) {
foreach ( $meta as $key => $val )
@@ -133,12 +133,12 @@ public function save() {
public function fetch() {
if ( empty($this->attributes['blogid']) || empty($this->attributes['id']) )
- throw new BadMethodCallException("Need a blogid and post id to fetch a post");
+ throw new BadMethodCallException(__("Need a blogid and post id to fetch a post"));
switch_to_blog( $this->attributes['blogid'] );
$post = get_post( $this->attributes['id'] );
if ( $post === NULL ) {
restore_current_blog();
- throw new ModelNotFound("Post", "Post not found");
+ throw new ModelNotFound("Post", __("Post not found"));
}
$this->reload( $post );
@@ -342,7 +342,7 @@ public function parse( &$postdata ) {
# If this isn't an attachment, we haven't found what we're looking for
if ( $ret['post_type'] != "attachment" )
- throw new ModelParseException("Post is not an attachment");
+ throw new ModelParseException(__("Post is not an attachment"));
# Add some special fields depending on the post type
$ret['url'] = wp_get_attachment_url($ret['id']);
@@ -526,9 +526,9 @@ public static function signon( $kwargs ) {
$collection = static::$collection;
$user = $collection::get_by( array( 'user_email' => $kwargs['user_email'] ) );
$creds['user_login'] = $user->user_login;
- } else throw new JsonableException("Please enter your user name or email address.");
+ } else throw new JsonableException(__("Please enter your user name or email address."));
- if ( empty( $kwargs['user_pass'] ) ) throw new JsonableException('Please enter your password.');
+ if ( empty( $kwargs['user_pass'] ) ) throw new JsonableException(__('Please enter your password.'));
$creds['user_password'] = $kwargs['user_pass'];
@@ -581,10 +581,10 @@ class UserCollection extends Collection {
public static function get_by( $kwargs ) {
if ( isset($kwargs['user_email']) ) {
$userid = get_user_id_from_string($kwargs['user_email']);
- if ( $userid === 0 ) throw new JsonableException("I don't know that email address");
+ if ( $userid === 0 ) throw new JsonableException(__("I don't know that email address"));
} else if ( isset($kwargs['user_login']) ) {
$userid = get_user_id_from_string($kwargs['user_login']);
- if ( $userid === 0 ) throw new JsonableException("I don't know that user name");
+ if ( $userid === 0 ) throw new JsonableException(__("I don't know that user name"));
} else throw new NotImplementedException();
$user = new static::$model( array( 'id'=>$userid ) );
@@ -659,10 +659,10 @@ public static function for_user( $kwargs ) {
$userid = $kwargs['user_id'];
} else if ( isset($kwargs['user_email']) ) {
$userid = get_user_id_from_string($kwargs['user_email']);
- if ( $userid === 0 ) throw new JsonableException("I don't know that email address");
+ if ( $userid === 0 ) throw new JsonableException(__("I don't know that email address"));
} else if ( isset($kwargs['user_login']) ) {
$userid = get_user_id_from_string($kwargs['user_login']);
- if ( $userid === 0 ) throw new JsonableException("I don't know that username");
+ if ( $userid === 0 ) throw new JsonableException(__("I don't know that username"));
} else throw new NotImplementedException();
$class = get_called_class();
@@ -724,10 +724,10 @@ function activate_signup($key) {
);
if (empty($signup))
- return new WP_Error('invalid_key', 'Invalid activation key.');
+ return new WP_Error('invalid_key', __('Invalid activation key.'));
if ($signup->active)
- return new WP_Error('already_active', 'This account is already activated.', $signup );
+ return new WP_Error('already_active', __('This account is already activated.'), $signup );
$user_meta = unserialize($signup->meta);
$user_login = $wpdb->escape($signup->user_login);
@@ -739,7 +739,7 @@ function activate_signup($key) {
$user_id = wpmu_create_user($user_login, wp_generate_password( 12, false ), $user_email);
if (!$user_id)
- return new WP_Error('create_user', 'Could not create user', $signup);
+ return new WP_Error('create_user', __('Could not create user'), $signup);
// Be sure to unset the user pass because
// we don't want to store it as meta once

0 comments on commit 0f3e995

Please sign in to comment.