Today I Learned: Translate custom (core) strings

Ben Buckman's picture
Tags:

On a site we're starting to build, Drupal's core "Sticky at top of lists" functionality isn't necessary (using Nodequeue for lists), but nodes need to be included or excluded from search results on a per-node basis. Rather than create a custom CCK field, and since we're building search (as usual) through Views, I decided the simplest answer was to rename "Sticky" to "Appear in Search Results," and filter accordingly in the view.

So how to do this? hook_locale() only works on non-English languages (see t()) and seems to define groups rather than strings.

The simplest solution, it seems, is to use settings.php (or in this case, a common.settings.php used by all the others). Like so:

<?php
$conf
['locale_custom_strings_en'] = array(
    
'Sticky at top of lists' => 'Appear in search results',
);
?>

Voila! It works even with the Locale module disabled. (It's not really needed since it's an English-only site.) And since the string is always run (by core and Views) through t(), it applies universally. It's still `sticky` to the database but that doesn't matter.

Comments

Josh G.'s picture

Perfect. I was trying to do the same thing. Thanks for saving me a little headache.

Anonymous's picture

I was not able to try this, but try this soon.

Linda28's picture

It supposes to be needful to accomplish a best range thesis while you study at the university. Therefore, your superb story related to this good post is a a really good issue for the dissertation reference performers.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockcode>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

More information about formatting options

CAPTCHA
Are you a robot? We usually like robots, but not in our comments.
Image CAPTCHA
Enter the characters (without spaces) shown in the image.