Category: Code

How to correctly internationalize WordPress child themes

Internationalization (i18n) and localization (l10n) are important and often overlooked aspects of WordPress development. Themes should give developers and administrators the ability to add translations for users from among the roughly 95% of the world whose first language isn’t English.

There are plenty of articles written about how to provide i18n and l10n for a single theme, but what about child themes? When building a child theme, assuming the parent theme is properly internationalized, developers may want to do any or all of the following:

  1. Provide localizations that aren’t provided by the parent theme, either in different languages or in gaps in existing localizations.
  2. Modify existing localizations in the parent theme, for instance if the developer of the child theme wants to change the wording of some area of the site.
  3. Provide new internationalizations unique to the child theme, using the child theme’s text domain.

Let’s start by looking at a simple example of i18n in a WordPress theme. For the purposes of this article, the parent theme will be called “Parent Theme” with the text domain parenttheme, and the child theme will be called “Child Theme” with the text domain childtheme.

Continue reading “How to correctly internationalize WordPress child themes”

Leave a Comment

On Vim’s being institutionally outdated

I adore Vim, I use it every day, and I wouldn’t dream of switching to anything else, but every once in a while I’m reminded of another thing about it that is just unequivocally bad and indefensible.

I was reading about the “CoC” plugin (“Conqueror of Completion”) this morning when I thought, “Wait, can’t Omni completion do some of that?” So I opened up Vim with a minimal .vimrc and typed:

document.que<C-x><C-o>

<C-x><C-o> opens Vim’s native Omni completion function, which I would expect to be at least somewhat current on JavaScript methods in 2020. Instead, nothing came up.

I had a look at the source of the JavaScript completion function in Vim, and found this: a file that was last updated three years ago, but that hasn’t been meaningfully updated since 2006.

So how have Vim users been getting by?

Continue reading “On Vim’s being institutionally outdated”

Leave a Comment

Getting the “Belle & Sebastian effect” with CSS filters

There are a lot of articles out there regarding using SVG’s feColorMatrix with CSS filters to get a “duotone” or “Instagram” effect on photos, but frankly most of the examples looked too weird to me, and the matrix multiplication that’s going on is pretty hard to wrap my brain around.

Usually what I want is a simple monochrome duotone effect; in other words, the Belle & Sebastian effect:

Most of these are a “dark” duotone effect, where the blacks remain black and the whites become the desired color.

Continue reading “Getting the “Belle & Sebastian effect” with CSS filters”

Leave a Comment

Chris Coyier on PostCSS

Chris Coyier on PostCSS:

We know that specs change. It happens all the time. Seems weird to base a syntax on a non-final spec. What happens when the spec changes? Do you change the language and let existing code break? How is that future-proof? Or support all past formats? Meaning the language isn’t really based on future CSS, it’s based on any experimental idea that was considered?

These have been exactly my thoughts since hearing about CSS post-processors. How can people honestly believe that the code they’re writing is future-proof? Sass source files certainly are prone to “spec rot”, but the CSS they generate isn’t (at least, insofar as anything can be immune to it).

On writing real CSS (again) | CSS-Tricks

One Response

Understanding GNU Screen’s hardstatus strings

My current development setup revolves mainly around Vim and GNU Screen. I use Screen only to keep sessions running between work days or in case I get disconnected, but lately I’ve been tempted to try using different windows inside Screen. In order to make this easier, I wanted one of those status lines that shows you all your windows as “tabs”.

Configuring this status line (the “hardware status line” or, as I’ll call it, “hardstatus”) is done with a single, often long string of characters in ~/.screenrc that at first can look entirely baffling:

hardstatus string "%{= KW} %H [%`] %{= Kw}|%{-} %-Lw%{= bW}%n%f %t%{-}%+Lw %=%C%a %Y-%M-%d"

Exactly.

To my dismay, almost everything I can find about hardstatus through Google are just dumps of other people’s strings, with little to no explanation about why they do what they do – it’s easy to imagine that the people who post them hardly know why they do what they do, either. GNU’s official documentation isn’t terribly helpful.

After finally deciphering a lot of what goes on in these strings, I wanted to spell it out to anybody else who might be hunting around for half a clue about this voodoo. There are (more than?) a few things I haven’t covered here, of course – truncation and conditionals, namely – but this should be enough to get you started.

Continue reading “Understanding GNU Screen’s hardstatus strings”

14 Responses

HTML indent settings in Vim

Despite not agreeing with all of it, “Just Use Sublime Text” (an invective against Vim — or, more accurately, against recommending Vim to anyone who isn’t already indoctrinated by it) by Andrew Ray is an interesting read. The section dealing with indenting in particular struck a chord with me:

Paste this into an empty buffer:

<div>
<p>
<span>foo</span>
</p>
</div>

:set ft=html and then gg=G. Let me know what you get. In all seriousness, never, ever tell me what you get.

As I said in a tweet, what I got didn’t offend me too much. But many people would argue that the <span> tag should be indented inside the <p> tag. I’d probably do this myself, actually — and there have been aspects of Vim’s indenting that irk me. So I set about finding a solution.

Continue reading “HTML indent settings in Vim”

Leave a Comment

Ubuntu’s Semantic Indicator Color Palette

It wasn’t until Mark Shuttleworth’s announcement of “windicators” that I learned of the rationale behind the palette of notification colors in the indicator applet. To quote:

[Windicators] would follow the same styling as Ayatana indicators: Semantically colored: with red for critical problems, orange for alerts, green for positive status changes and blue for informative states that are not the default or usual state.

This came as a real surprise given that I had (and still have) never seen a blue or orange indicator icon.

The obvious and primary objection is that four colors in a palette to convey meaning is far too many. Shuttleworth even said as late as April 1 — just four weeks before Lucid’s release — “Personally, my expectation is that green vs orange/red is as far as we want to go.” Two colors is an absolute maximum here — one for negative messages about something being broken, the other merely to notify you of something — although even one should suffice: “Something has changed; requesting your attention.”

If “orange is for alerts” and “green is for positive status changes,” then why do new IM messages turn the messaging icon green? Isn’t that an alert? What is “positive” about getting a new message? What if it’s your boss firing you? Your boyfriend breaking up with you? A spambot?

Continue reading “Ubuntu’s Semantic Indicator Color Palette”

4 Responses

Building a Songbird Add-On: Part 0

songbird-artist-web-media-view-mockupAfter complaining about alphabetization in music libraries for — wow — almost a year, I’ve decided it’s time to do something about it.

I know very little about JavaScript and XUL, but that is going to have to change. My goal is to complete the add-on described here, an Artist Web media view, or perhaps “Constellations.”

To make the task appear less daunting, I’ve broken it up into many milestones of marginal improvements. If I follow this timeline, the plugin will be usable and released to the public as Constellations v0.1 on July 27.

Milestone ver Description Target Date Actual Date
i 0.0.1 display all artists in a vertical list 08 Jun 2009
ii 0.0.2 display most recent Last Played value for each artist 15 Jun 2009
iii 0.0.3 display total Play Count for each artist 22 Jun 2009
iv 0.0.4 vary font sizes according to total artist Play Count 29 Jun 2009
v 0.0.5 vary font colors according to total artist Play Count 6 Jul 2009
vi 0.0.6 vary font colors according to Last Played 13 Jul 2009
vii 0.0.7 arrange artist names left-to-right instead of vertically 20 Jul 2009
viii 0.1 focus first of the artist’s tracks in the playlist pane when the artist’s name is clicked 27 Jul 2009
ix 0.1.1 resize/re-color based on play frequency instead of play count 10 Aug 2009
x 0.2 options window that alternates between which variable is assigned to which font property 31 Aug 2009

I’m going to create a separate blog to track my progress on this, for several reasons:

  1. Threat of shame. If I emphasize publicly that I am going to do this, and I fail, I’ll be kind of embarrassed. Hopefully that will motivate me to actually complete the project.
  2. Geeks love proving that they’re smarter than you. If I’m having a tough time with some relatively elementary code, maybe people will mock me in the form of writing the correct code themselves. I’m certain that what I’m attempting could be done in no time flat if I’d been formally educated in things like JavaScript. Maybe the biting sarcasm of people who need to demonstrate their intelligence will show me where I’m going wrong.
  3. To encourage plagiarism. Look, I’ll admit that I’d be proud if the add-on that comes out of this bore my name. But ultimately, I don’t care. If somebody sees what I’m doing, likes it, wants it to be their own, and knows they can beat me to it, then great. At least we’ll have the add-on.

If you feel like mocking me or encouraging me you can email me at topdownjimmy@gmail.com, leave/follow comments on this post, or visit my dedicated Constellations blog to see where I’m taking this and how quickly I fail.

2 Responses