Translate This 9.03.12

View Comments // Written on Mar 12, 2009 // Net

In the latest release of Translate This I fixed a bug which affected wordpress installations that are not located in the root of your domain. This means that if your blog address is something like

http://my.domain.com/

everything worked fine, while if you have something like that

http://my.domain.com/myblog/

the old version would have returned a 404 error. This error was due to an absolute path used to indicate the iframe location and was fixed with the suggestions of Marco Battistoni.

Older Releases

As I didn’t publish anything about latest releases changes I will resume them below

9.03.11

In this release I added a very useful JS script that has the duty to hide the ‘Translate This’ icon on your editor when you move from visual to HTML mode. This is necessary as the script still do not support code editor for translation. I will try to realize that in the future but in the meantime I believe that is safer to disable the icon so that people do not try to translate in HTML mode.

I also improved the graphics inside the popup, moving elements and fixing some styles, and added language flags inside the selectbox. Icons have been realized by Icon Drawer and all the rights about them are their property.

9.03.09-1

This is a miny-minor release, needed to fix an incompatibility issue with contact-forms-iii. That was suggested by Rajesh in the comments .

9.03.09

In this release I fixed paths problem that where caused from the change of the plugin folder from translate to translate-this. That was my bad fault .

Translate This – Translate wordpress posts as you type!

View Comments // Written on Mar 08, 2009 // Net, Open Source

Playing with APIs is very funny, especially if you can obtain a lot, coding a few. This time I realized Translate This a simple wordpress plugin using Google Ajax APIs for Languages to translate the post you’re writing, directly from wordpress administration interface.

It was easy to create the plugin but it’s also very simple to use!
In fact it just adds an icon in the toolbar above wordpress text editor. Clicking it will open a popup containing a select for the language you want to translate your text to and a quick preview of what you will obtain. You change the language from the select and the preview updates itself. When you’re satisfied you press save and your text is automatically replaced with the translated one. There are 42 languages in which you can translate your text.

That’s amazing in my opinion…. here is a quick screencast to show what I’m talking about

As I’m still waiting for wordpress to accept my plugin on their directory you can visit the dedicated page on this blog.

.

Improve WordPress .htaccess

View Comments // Written on Mar 07, 2009 // Net

Url rewriting is very (very very) important for seo and WordPress users can easily avoid ugly urls like ?p=43 using permalinks in their installations.

To achieve the result of a true rewrite (no index.php file in the url) wordpress requires apache mod_rewrite module, and uses an .htaccess file that has the only purpose to redirect everything that does not exists physically to your index.php file. The default htaccess file looks something like that

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Apart from the comments let’s see quickly what most important line means

  • <IfModule mod_rewrite.c>

This just checks if your apache server has mod_rewrite installed and enabled

  • RewriteEngine On

Enables the rewriting engine

  • RewriteBase /

Sets the base url for the rewrite rules

  • RewriteCond %{REQUEST_FILENAME} !-f

Checks that the path requested is not present on your server.  This means that the server will  redirect on the index.php just addresses that do not match any physical file.

  • RewriteCond %{REQUEST_FILENAME} !-d

Checks that the path requested is not present on your server.  This means that the server will  redirect on the index.php just addresses that do not match any physical directory.

  • RewriteRule . /index.php [L]

Tells the server to redirect anything to the index.php file.

Let’s do some examples to clarify how does it work exactly. Imagine that the following files are your wordpress directory content

index.php

somepic.png

So if an user come to your websites with this url

http://www.yoursite.com/an-article.html

he will be redirected to the index.php file which will show the article, as the file does not exist on your server.

If instead an user arrives to

http://www.yoursite.com/somepic.png

he won’t be redirected because that image exists. He will just see the image, and this is correct.

Now suppose that someones arrive in your page

http://www.yoursite.com/an-article.html

and that in your template there is an inclusion of a js script (not present on your server) called

myscript.js

Including a script is like making an other http request to the server so it’s just like if the browser opened this page

http://www.yoursite.com/myscript.js

WordPress htaccess file, will redirect the user to the index.php as the JS does not exists!!

This means wordpress will try to treat that JS as an article and so it will search on its database for any article having that name.

This  means that opening http://www.yoursite.com/an-article.html with a missing js file has nearly the same weight of calling two pages!

This is a big problem when you got an heavy installation of WordPress with a lot of traffic, because it’s like doubling the traffic.

Yes that’s obviously an human error that can be avoided as you should always check for every image,js and css to exist.

However I prefer being sure that such problems do not verify so I just added some more rules to my htaccess,before the file and directory existence checks.

RewriteCond %{REQUEST_FILENAME} !^.*\.png [nc]
RewriteCond %{REQUEST_FILENAME} !^.*\.css [nc]
RewriteCond %{REQUEST_FILENAME} !^.*\.jpg [nc]
RewriteCond %{REQUEST_FILENAME} !^.*\.js [nc]
RewriteCond %{REQUEST_FILENAME} !^.*\.gif [nc]

As you can guess it’s just an other check before doing the redirects. If the file requested is not a css, a js or an image (gif,png, or jpg) then do the redirect.

So if any user come to my website and opens a page which contains an image that is no more there Apache will just launch a 404 not found error but won’t weigh down the server.

So here’s my full htaccess file, I bet you just wanted to see that without the explanations uh?

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !^.*\.png [nc]
RewriteCond %{REQUEST_FILENAME} !^.*\.css [nc]
RewriteCond %{REQUEST_FILENAME} !^.*\.jpg [nc]
RewriteCond %{REQUEST_FILENAME} !^.*\.js [nc]
RewriteCond %{REQUEST_FILENAME} !^.*\.gif [nc]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Twitter Avatars on WordPress

View Comments // Written on Feb 03, 2009 // Net

A few days ago Smashing Magazine, one of my favourite daily readings,  pulicized a WordPress plugin which is able to search the avatar of  a user both from gravatar and from Twitter.

As the gravatar one even the twitter avatar is searched by email address so obviously the user will be recognized just if he set the same email address he used on Twitter.

The plugin was originally realized by Ricardo Sousa and you can try it in this blog, leaving a comment to this or other posts.

The installation is quite simple, just like all the others wordpress plugin you need to download, extract and upload it to your /wp-content/plugins/ directory. Then you need to locate your comments.php under themes->editor and finally just add the code for the image inside the comment loop.

<span><span><?php twittar(size, placeholderimg, border, </span><span class="keyword">class</span><span>, usegravatar, rating); ?> </span></span>

For more informations, instructions and updates please read Smashing Magazine original post .

Hey Social – QuickSilver like Interactivity

View Comments // Written on Jul 23, 2008 // Net, Open Source

Yes, it’s ture. There are a lot of plugins for WordPress that let your users interact with Social Bookmarking sites, but as soon as I looked at Hey Silver, I started loving its new way of proposing content. Continue reading →

Voz Me – Listen to the Site!

View Comments // Written on Jul 16, 2008 // Net, Open Source

Voz Me Today I get surprised, seeing how, with so much simplicuity it is possibile to create something so userful! Perhaps lots of people already know VozMe , a 5Kb plugin that in a few second transform any text on your webpages in a Mp3 file, to download or to listen to in streaming with the embed player.

Continue reading →