Skip to content

Commit

Permalink
Release Alpha 1 - part 2
Browse files Browse the repository at this point in the history
Complete moves from Translation to Babble.

Updates to readme.txt and babble-poc.php as per previous commit
comments.
  • Loading branch information
Simon Wheatley committed Sep 28, 2011
1 parent f7cee68 commit b675d04
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 10 deletions.
4 changes: 0 additions & 4 deletions README

This file was deleted.

27 changes: 21 additions & 6 deletions translation-poc.php → babble-poc.php
@@ -1,12 +1,12 @@
<?php <?php


/* /*
Plugin Name: Translations Proof of Concept Plugin Name: Babble – Proof of Concept
Plugin URI: http://simonwheatley.co.uk/wordpress/tpoc Plugin URI: https://github.com/simonwheatley/babble
Description: Translation proof of concept Description: Translation proof of concept
Version: 0.1 Version: alpha 1
Author: Simon Wheatley Author: Simon Wheatley
Author URI: http://simonwheatley.co.uk//wordpress/ Author URI: http://simonwheatley.co.uk/wordpress/
*/ */


/* Copyright 2011 Simon Wheatley /* Copyright 2011 Simon Wheatley
Expand Down Expand Up @@ -39,6 +39,7 @@
* Hooks the WP init action early * Hooks the WP init action early
* *
* @return void * @return void
* @access private
**/ **/
function sil_init_early() { function sil_init_early() {
global $sil_post_types; global $sil_post_types;
Expand Down Expand Up @@ -68,6 +69,7 @@ function sil_init_early() {
* *
* @param array $langs The language codes * @param array $langs The language codes
* @return array An array of language codes utilised for this site. * @return array An array of language codes utilised for this site.
* @access private
**/ **/
function sil_rewrite_rules_filter( $rules ){ function sil_rewrite_rules_filter( $rules ){
// Add a prefix to the URL to pick up the virtual sub-dir specifying // Add a prefix to the URL to pick up the virtual sub-dir specifying
Expand All @@ -84,6 +86,7 @@ function sil_rewrite_rules_filter( $rules ){
* *
* @param string $locale The locale * @param string $locale The locale
* @return string The locale * @return string The locale
* @access private
**/ **/
function sil_locale( $locale ) { function sil_locale( $locale ) {
// @FIXME: Copying a huge hunk of code from WP->parse_request here, feels ugly. // @FIXME: Copying a huge hunk of code from WP->parse_request here, feels ugly.
Expand Down Expand Up @@ -154,6 +157,7 @@ function sil_locale( $locale ) {
* *
* @param array $langs The language codes * @param array $langs The language codes
* @return array An array of language codes utilised for this site. * @return array An array of language codes utilised for this site.
* @access private
**/ **/
function sil_languages( $langs ) { function sil_languages( $langs ) {
$langs[] = 'de_DE'; $langs[] = 'de_DE';
Expand All @@ -170,6 +174,7 @@ function sil_languages( $langs ) {
* @param string $post_type The post type which has just been registered. * @param string $post_type The post type which has just been registered.
* @param array $args The arguments with which the post type was registered * @param array $args The arguments with which the post type was registered
* @return void * @return void
* @access private
**/ **/
function sil_registered_post_type( $post_type, $args ) { function sil_registered_post_type( $post_type, $args ) {
// @FIXME: When we turn this into classes we can avoid a global $sil_syncing here // @FIXME: When we turn this into classes we can avoid a global $sil_syncing here
Expand Down Expand Up @@ -261,6 +266,7 @@ function sil_registered_post_type( $post_type, $args ) {
* @param string $taxonomy The name of the newly registered taxonomy * @param string $taxonomy The name of the newly registered taxonomy
* @param array $args The args passed to register the taxonomy * @param array $args The args passed to register the taxonomy
* @return void * @return void
* @access private
**/ **/
function sil_registered_taxonomy( $taxonomy, $object_type, $args ) { function sil_registered_taxonomy( $taxonomy, $object_type, $args ) {
// @FIXME: When we turn this into classes we can avoid a global $sil_syncing here // @FIXME: When we turn this into classes we can avoid a global $sil_syncing here
Expand Down Expand Up @@ -321,6 +327,7 @@ function sil_registered_taxonomy( $taxonomy, $object_type, $args ) {
* *
* @param object $wp WP object, passed by reference (so no need to return) * @param object $wp WP object, passed by reference (so no need to return)
* @return void * @return void
* @access private
**/ **/
function sil_parse_request( $wp ) { function sil_parse_request( $wp ) {
// If this is the site root, redirect to default language homepage // If this is the site root, redirect to default language homepage
Expand Down Expand Up @@ -399,7 +406,7 @@ function sil_parse_request( $wp ) {
* *
* @param array $query_vars An array of the public query vars * @param array $query_vars An array of the public query vars
* @return array An array of the public query vars * @return array An array of the public query vars
* @author Simon Wheatley * @access private
**/ **/
function sil_query_vars( $query_vars ) { function sil_query_vars( $query_vars ) {
// @FIXME: We only add the home_url filter at this point because having it earlier screws with the request method of the WP class. // @FIXME: We only add the home_url filter at this point because having it earlier screws with the request method of the WP class.
Expand All @@ -416,6 +423,7 @@ function sil_query_vars( $query_vars ) {
* *
* @param array $posts The posts retrieved by WP_Query, passed by reference * @param array $posts The posts retrieved by WP_Query, passed by reference
* @return array The posts * @return array The posts
* @access private
**/ **/
function sil_the_posts( $posts ) { function sil_the_posts( $posts ) {
$subs_index = array(); $subs_index = array();
Expand Down Expand Up @@ -446,6 +454,7 @@ function sil_the_posts( $posts ) {
* *
* @param object $wp_admin_bar The WP Admin Bar, passed by reference * @param object $wp_admin_bar The WP Admin Bar, passed by reference
* @return void * @return void
* @access private
**/ **/
function sil_admin_bar_menu( $wp_admin_bar ) { function sil_admin_bar_menu( $wp_admin_bar ) {
global $wp, $sil_post_types, $sil_lang_map; global $wp, $sil_post_types, $sil_lang_map;
Expand Down Expand Up @@ -531,6 +540,7 @@ function sil_admin_bar_menu( $wp_admin_bar ) {
* @param string $orig_scheme The original scheme * @param string $orig_scheme The original scheme
* @param int $blog_id The ID of the blog * @param int $blog_id The ID of the blog
* @return string The URL * @return string The URL
* @access private
**/ **/
function sil_home_url( $url, $path ) { function sil_home_url( $url, $path ) {
$orig_url = $url; $orig_url = $url;
Expand All @@ -548,6 +558,7 @@ function sil_home_url( $url, $path ) {
* Hooks the WP admin_init action * Hooks the WP admin_init action
* *
* @return void * @return void
* @access private
**/ **/
function sil_admin_init( ) { function sil_admin_init( ) {
add_filter( 'home_url', 'sil_home_url', null, 2 ); add_filter( 'home_url', 'sil_home_url', null, 2 );
Expand All @@ -559,6 +570,7 @@ function sil_admin_init( ) {
* *
* @param string $admin_url The admin URL * @param string $admin_url The admin URL
* @return string The URL with the appropriate language (lang) GET parameter * @return string The URL with the appropriate language (lang) GET parameter
* @access private
**/ **/
function sil_admin_url( $url ) { function sil_admin_url( $url ) {
return add_query_arg( array( 'lang' => sil_get_current_lang_code() ), $url ); return add_query_arg( array( 'lang' => sil_get_current_lang_code() ), $url );
Expand All @@ -570,6 +582,7 @@ function sil_admin_url( $url ) {
* *
* @param array $menu The WP Admin Menu * @param array $menu The WP Admin Menu
* @return array The WP Admin Menu, with our query args * @return array The WP Admin Menu, with our query args
* @access private
**/ **/
function sil_add_menu_classes( $menu ) { function sil_add_menu_classes( $menu ) {
// @FIXME: Adding the language string like this feels so so dirty. // @FIXME: Adding the language string like this feels so so dirty.
Expand All @@ -586,6 +599,7 @@ function sil_add_menu_classes( $menu ) {
* @param string $post_link The permalink * @param string $post_link The permalink
* @param object $post The WP Post object being linked to * @param object $post The WP Post object being linked to
* @return string The permalink * @return string The permalink
* @access private
**/ **/
function sil_post_type_link( $post_link, $post, $leavename ) { function sil_post_type_link( $post_link, $post, $leavename ) {
global $sil_post_types, $sil_lang_map, $wp_rewrite; global $sil_post_types, $sil_lang_map, $wp_rewrite;
Expand Down Expand Up @@ -693,6 +707,7 @@ function sil_post_type_link( $post_link, $post, $leavename ) {
* @param string $link The permalink for the page * @param string $link The permalink for the page
* @param int $id The ID for the post represented by this permalink * @param int $id The ID for the post represented by this permalink
* @return string * @return string
* @access private
**/ **/
function sil_page_link( $link, $id ) { function sil_page_link( $link, $id ) {
global $sil_syncing; global $sil_syncing;
Expand All @@ -719,7 +734,6 @@ function sil_page_link( $link, $id ) {
* @param int|object $post The WP Post object, or the ID of a post * @param int|object $post The WP Post object, or the ID of a post
* @return string The transid * @return string The transid
* @access private * @access private
* @author Simon Wheatley
**/ **/
function sil_get_transid( $post ) { function sil_get_transid( $post ) {
$post = get_post( $post ); $post = get_post( $post );
Expand All @@ -736,6 +750,7 @@ function sil_get_transid( $post ) {
* @param int $post_id The ID of the post which has just been inserted * @param int $post_id The ID of the post which has just been inserted
* @param object $post The WP Post object which has just been inserted * @param object $post The WP Post object which has just been inserted
* @return void * @return void
* @access private
**/ **/
function sil_wp_insert_post( $post_id, $post ) { function sil_wp_insert_post( $post_id, $post ) {
global $sil_syncing; global $sil_syncing;
Expand Down
44 changes: 44 additions & 0 deletions readme.txt
@@ -0,0 +1,44 @@
=== Babble ===
Contributors: simonwheatley
Requires at least: 3.3-aortic-dissection
Tested up to: 3.3-aortic-dissection
Stable tag: Alpha 1
Tags: translations

A plugin to handle translating content into a variety of languages.

== Description ==

This plugin is at a proof of concept stage for translating post type content for the built
in types of `post` and `page`.

The plugin is built with the Automattic VIP Hosting Environment in mind, and, hopefully, to
WordPress development best practices.

There are a **lot** of `@FIXME` comments, expressing doubts, fears, uncertainties and
unknowns; feel free to weigh in on any of them.

Please send bugs to simon@sweetinteraction.com, or enter them on https://github.com/simonwheatley/babble/issues

== Installation ==

Installation is a little more involved than usual.

1. Upload the `babble` directory to the `/wp-content/plugins/` directory
1. Activate the plugin through the 'Plugins' menu in WordPress
1. Apply the `new_hook.diff` to add the `registered_post_type` hook to before `return $args;` in the `register_post_type` function in the `wp-includes/post.php` file.
1. Apply the `new_tax_hook.diff` to add the `registered_taxonomy` hook to the end of the `register_taxonomy` function in the `wp-includes/taxonomy.php` file.
1. Copy the contents of `languages` into `wp-content/languages/` (optional, but makes it easier to see when languages have been switched)

== Screenshots ==

1. Shows the Babble language switch menu in the admin area, showing the site in Hebrew and the options to switch to English or German
2. Shows the Babble language switch menu while editing a post, where a German translation has been created and offering the option to create a Hebrew translation
3. Shows the provisional URL structure on the frontend, and the collapsed Babble language switcher menu in the admin bar

== Changelog ==

= alpha 1 =

Proof of concept concentrating on the translation of posts. Taxonomies and menus are not handled yet. Widgets are out of scope completely for this phase of work.

0 comments on commit b675d04

Please sign in to comment.