Thord Daniel Hedengren - Smashing WordPress_ Beyond the Blog-Wiley (2014)

(avery) #1

164 PART II • Designing and Developing WordPress Themes


Other software and services for working with .po files include GNU’s very own gettext
(www.gnu.org/software/gettext) and Launchpad (https://translations.
launchpad.net). However, neither of these is as easy to use as Poedit, and most often,
Poedit is recommended. There is also an interesting project called GlotPress (http://
glotpress.org) that is in its early stages.

When you release a theme or a plugin with a language file, be sure to also make the original
.po file available so that the users can translate it into their own language. It is a good idea to
encourage that because others may benefit as well.

THE NAMING ISSUE
Although it may not be entirely within your theme or plugin translation scope, a weird error
arises when a widget area gets called and can’t be found because the name has been changed
by the translation. That happened with WordPress and the Swedish translation of “Sidebar,”
being a widget area located in sidebar.php, no less. The translators translated “Sidebar” (to
“Sidomeny,” which somewhat misses the mark, but still), and by doing so, they made the
themes that made direct calls to the “Sidebar” widget area fail because it was translated
incorrectly. Of course, themes using the sidebar ID rather than the name wouldn’t have this
problem, so let that be a lesson to use the ID rather than the name.

Messy? Yes, it is. The point is, be wary so that you don’t end up translating things that are used
for calling up various features, functions, or whatever. At least not without making sure that
the actual call for whatever it is is also altered accordingly. You might want to take a closer
look at the functions.php file in Twenty Fourteen for example and examine how the widget
areas are internationalized there. In other words, if you want to internationalize both the
interface words (name, description) and the ID of a widget area, make sure that you use the
internationalized version of the ID when including the widget area in your theme.

WORKING WITH RSS FEEDS


RSS feeds are a great way both to deliver and to subscribe to content. To enable feeds all across
your site, you want to add support for automatic feed links. Add this to your functions.php
file, ideally within a function that hooks on to the after_setup_theme hook, much as you
did in Simple Blog’s functions.php file in Chapter 4:

add_theme_support( 'automatic-feed-links' );

Most themes have feed links built in, and although the web browser will tell your visitors
discreetly that there is a feed available, you really want to push it a bit harder than that. Take a
look at just about any successful professional blogger, and you’ll see nice RSS graphics, often
incorporating the feed icon (if you need the icon, you can get it from Feed Icons at http://www.
feedicons.com) and pushing the subscription services in premier positions.

You should do the same if you want to gain subscribers. That’s lesson one on RSS: Position it
well on your site; otherwise, people will neither see nor use it.
Free download pdf