Wordpress

Error messages when running GnuWin32 msgfmt

by Niklas Waller on June 16, 2011

in Wordpress

In my last post I described how to translate the WordPress Thesis theme to your preferred language. When you run the command msgfmt in GnuWin32 GetText you might see these error messages.

"invalid multibyte sequence"
or
"Parse error"

The quick way that I came around this was that the encoding of thesis.pot was wrong. The first error message comes up if thesis.pot is encoded in ANSI. The second one comes up if it is encoded in UTF-8. If you convert encoding to “UTF-8 without BOM” it will work. This is easily done in Notepad++. Choose “Format” in the menu and then “Convert to UTF-8 without BOM”.

Share and Enjoy:

  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
  • email
  • Google Buzz
  • RSS
  • Slashdot
  • Technorati
  • Add to favorites
  • DZone
  • LinkedIn
  • MySpace
  • Tumblr

Be the first to comment

It’s not difficult to get WordPress in your preferred language. Since WordPress is already translated into most languages you can decide from the start to get it right or you can convert from one language to an existing. Read more about that here.

If you are using Thesis as your theme you’ll notice that the Thesis part of the admin interface and some parts of the public gui are not translated. This is because these parts don’t belong to the standard WordPress installation and because the Thesis theme is only shipped in English. To solve this you’ll have to get the Thesis theme translated yourself. If you’re lucky someone might have done this for you, otherwise you’ll have to do it yourself.

First, make sure that the file wp-config has your preferred language set, i.e. for example

define ('WPLANG', 'sv_SE');

This is part of the process of making the WordPress installation in the preferred language.

In the directory ‘wp-content/themes/thesis_18/lib/languages’ you have a file named ‘thesis.pot’. You can open this in Notepad++ and add the translations yourself for each text string. For each msgid (which is the string in english) you can specify a msgstr (which is the string in your language). Here is what it could look like if you translate to swedish:

msgid "in"msgstr "i"
msgid "by"msgstr "av"

msgid "% comments"msgstr "% kommentarer"
msgid "1 comment"msgstr "1 kommentar"

msgid "0 comments"msgstr "0 kommentarer"
msgid "on"msgstr "den"

msgid "You searched for:"msgstr "Du sökte efter:"

Now you need to take this file, compile it to get a machine readable file.

A good and free software that reads thesis.pot and create a new .mo file (machine code) is the GnuWin GetText. Install this and run it like this:

msgfmt -o sv_SE.mo thesis.pot

Gnuwin32

Upload the .mo file to to the same place as where thesis.pot is located. When this is done, Thesis will use your translated phrases instead.

Stay tuned and I hope to provide you with a translated file for the swedish Thesis theme soon.

Share and Enjoy:

  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
  • email
  • Google Buzz
  • RSS
  • Slashdot
  • Technorati
  • Add to favorites
  • DZone
  • LinkedIn
  • MySpace
  • Tumblr

Be the first to comment

On Wohill we are using different favicons on the site and the admin. This is something that I recommend since it is easy to see just by looking at the tabs. The blue icon is for the website and the pink is for the admin site.

Wohill favicons

We are using the Thesis theme (which I highly recommend) and with Thesis follows that it is  very easy to add a favicon for the site. Just use the Favicon Uploader.

Thesis Favicon Uploader

If you’re using another theme, check what they have or just add something like this to the header.php file:

<link rel="shortcut icon" href="mysite.com/favicon.ico"></link>

To put another favicon to the admin site just add a the favicon.ico file to the root, i.e. on the same level as the directories wp-admin”, ‘wp-content’ and ‘wp-includes’. If you see no difference directly, try cleaning the browser cache or opening with another browser.

Share and Enjoy:

  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
  • email
  • Google Buzz
  • RSS
  • Slashdot
  • Technorati
  • Add to favorites
  • DZone
  • LinkedIn
  • MySpace
  • Tumblr

Be the first to comment

The Thesis OpenHook WordPress plugin

by Niklas Waller on March 24, 2011

in Wordpress

One really great WordPress plugin that I would like to push for is one that I found the other day when configuring a clients website called Thesis OpenHook.

The Thesis OpenHook plugin

When customizing a WordPress blog or website you will spend quite some time in the css- and  functions editor to add, remove and move things in the menu, sidebars or other places. If you use the Thesis theme you use a system with so-called hooks. The purpose of using hooks is to simplify the way of adding and removing stuff on your blog. The hook system is a kind of API that covers all spots on your blog or site and will help you to both customize the site and get control of it.

The Thesis OpenHook WordPress plugin takes it a step further in making it more structured and under control since you won’t have to add code in the editor files anymore. All code is put in one place structured per hook.

As you can see in the screenshot above you can add only html or specify if PHP-code should be executed.

Here are some more information about hooks.
http://thesishooks.com/
http://diythemes.com/thesis/rtfm/hooks/
http://diythemes.com/thesis/how-to-customize-your-site-intelligently-with-hooks/
http://diythemes.com/thesis/rtfm/customizing-with-hooks/

Share and Enjoy:

  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
  • email
  • Google Buzz
  • RSS
  • Slashdot
  • Technorati
  • Add to favorites
  • DZone
  • LinkedIn
  • MySpace
  • Tumblr

Be the first to comment

Suddenly today when I was opening my WordPress plugins page I couldn’t browse or search plugins. Instead the error message ‘An Unexpected HTTP Error occurred during the API request’ was displayed. This came very sudden without any changes from my side.

I browsed the web a bit and found a solution.

Prior to  Wordpress 3.0
Edit file http.php in directory wp-includes and find the http timeout setting. It is by default set to 5. Increase to 30 or 60.
'timeout' => apply_filters( 'http_request_timeout', 60);

WordPress 3.0 and after
Edit file plugin-install.php in directory wp-admin/includes and find the timeout setting. It is by default set to 15. Increase to 60.
$request = wp_remote_post('http://api.wordpress.org/plugins/info/1.0/', array( 'timeout' => 60, 'body' => array('action' => $action, 'request' => serialize($args))) );

Share and Enjoy:

  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
  • email
  • Google Buzz
  • RSS
  • Slashdot
  • Technorati
  • Add to favorites
  • DZone
  • LinkedIn
  • MySpace
  • Tumblr

5 comments

Importing comments to WordPress

by Niklas Waller on July 29, 2010

in Wordpress

As mentioned before, we are in the process of evaluating WordPress as a candidate for our future blogging platform. This evaluation includes importing all information from the current blog to the possibly new one.

WordPress offers several ways to import data from another system. There are plugins for the major blogging platforms like Blogger, TypePad, LiveJournal and WordPress that can be found in the WordPress admin under Tools – Import. You can also search for importer or import to find more plugins.

Since Wohill is not put on any of these blogging platforms but instead is self-developed we can not use any of these plugins. However, there is a tool that can be found in the same place that allows importing from an RSS-feed. Since Wohill has a validated RSS-feed, this is what I have used. Worth mentioning is that I have downloaded WordPress which means that data tables are created in the same database as the one we use today. What I want said by that is that it is possible to copy data from the old data tables to the new ones without the RSS-importer. But since it exists and importer it is easier and we will use it.

It worked fine. The basic information gets in there. I had problems with the author though. I tried using the author-tag and the dc:creator-tag but neither worked. This was however solved by manually setting the author using SQL-queries in PHPMyAdmin after the import.

The RSS-import only imports posts and we still have comments, tags etc. to take care of and I don’t want to add them manually. There might be a plugin that works for this as well but I solved it this way to get the comments in and associated with the right posts.

Since the data tables from the current and the new platform resides in the same database we can use some SQL to fix this. I used the following to copy the comments from the old comments table to the new.

# Insert comments
INSERT INTO wp_comments (comment_author, comment_author_email, comment_author_url, comment_content, comment_date, comment_post_ID, comment_approved) SELECT a.name, a.email, a.website, a.body, a.publishDate, b.ID, '1' FROM old_comments_table a inner join wp_posts b on (a.postId = b.guid and a.approved = '1')

The comments get in there and also associated with the right posts. The comment count on the posts has not been adjusted though. I searched the web and found a solution for this. Use this code straight off as it is and this issue will be taken care of as well.

# Update comment count on existing posts
UPDATE wp_posts wpp LEFT JOIN (SELECT comment_post_id AS c_post_id, count(*) AS cnt FROM wp_comments WHERE comment_approved = 1 GROUP BY comment_post_id) wpc ON wpp.id=wpc.c_post_id SET wpp.comment_count=wpc.cnt WHERE wpp.post_type IN ('post', 'page') AND (wpp.comment_count!=wpc.cnt OR (wpp.comment_count != 0 AND wpc.cnt IS NULL));

Share and Enjoy:

  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
  • email
  • Google Buzz
  • RSS
  • Slashdot
  • Technorati
  • Add to favorites
  • DZone
  • LinkedIn
  • MySpace
  • Tumblr

Be the first to comment