- Informational Messages
- Strings with description
- Date and Time Locale Settings
- Messages With Placeholders
- Stop Words
In the WordPress administration interface, there are various messages that must be translated. Some of these messages are seen frequently, while others are only seen occasionally. Each of these message types are documented below, along with examples.
Labels are often used in the context of HTML <label>, <legend>, <a>, or <select> tags. They are short and precise descriptors of the purpose of a UI element. These can be very difficult to translate at times, especially if they are single words, and if the word used in English can be interpreted as either a noun or imperative verb. With most labels you will need to do some searching through the code to find the context of its use before coming up with an appropriate translation.
Because so many of the messages are part of the WordPress administration interface, Labels are probably the most frequent type of message to translate.
“Post” could be interpreted as an imperative verb, but in this context it’s a noun. The noun form of “post” in English can be difficult to translate, and the most appropriate translation has been difficult for some teams to decide upon. Many translations use their language’s equivalent to the English “Article,” as the one below, from the Finnish (Finland) translation does.
msgid "Post" msgstr "Artikkeli"
Another example of a label is seen here, from the Hindi translation.
#: wp-login.php:79 wp-login.php:233 wp-register.php:166 #: wp-includes/template-functions-general.php:46 msgid "Register" msgstr "रजिस्टर"
Labels with surrounding dashes, as in the example below (from the Welsh translation), can be eliminated or replaced if they might be confusing to users in your target locale, or if there are different established conventions for your locale.
#: wp-admin/admin-functions.php:357 msgid "- Select -" msgstr " - Dewis -"
Informational Messages #
Informational message are usually composed of full sentences. They convey information or request an action from a user. Since these tend to be longer than labels, they tend to be slightly easier to translate. However, with the longer messages comes more variation in the level of formality (or informality), which is something translators need to be aware of.
In the example below – from the Bulgarian translation – the information message contains a modified English formulaic expression (“the check/cheque is in the mail”), which contributes to its informality.
#: wp-login.php:146 msgid "Your new password is in the mail." msgstr "Вашата нова парола е в електронната ви поща."
Error messages tend to be more formal, simply because they’re short and concise, as seen in this example from the Swedish translation.
#: wp-includes/functions.php:1636 msgid "<strong>Error</strong>: Incorrect password." msgstr "<strong>FEL</strong>: Felaktigt lösenord."
Of course, not all error messages are formal in the WordPress interface. The below example, from the German translation, shows an error message with an informal tone.
#: wp-includes/functions-post.php:467 msgid "Sorry, you can only post a new comment once every 15 seconds. Slow down cowboy." msgstr "Leider kannst du nur alle 15 Sekunden einen neuen Kommentar eingeben. Immer locker bleiben."
Strings with description #
If a string contains a vertical bar |, the part on the right of | is a description. Its purpose is to help you translate the string, placing it in certain context or providing additional information.
The description in the below case suggests you look at a web page in order to translate the string.
#: wp-includes/locale.php:186 msgid "" "number_format_decimal_point|$dec_point argument for http://php.net/number_format, default is ." msgstr ","
Date and Time Locale Settings #
Rather than using PHP’s built-in locale switching features, which is not configured properly for very many languages on most hosts, WordPress uses the gettext translation module to accomplish date and time translations and formatting.
WordPress translates all of the following date and time settings.
Month names #
#: wp-includes/locale.php:42 wp-includes/locale.php:57 msgid "May" msgstr "Květen"
(From the Czech translation.)
Month abbreviations #
#: wp-includes/locale.php:57 msgid "May_May_abbreviation" msgstr "Mag"
Note the unusual msgid in the example above. These messages should not be translated literally. The msgid here is a hack that is used because the full name and abbreviation are the same in English and Gettext would erroneously combine the two into one entry. (From the Italian translation.)
Weekday Names #
#: wp-includes/locale.php:7 #: wp-includes/locale.php:18 #: wp-includes/locale.php:31 msgid "Tuesday" msgstr "火曜日"
(From the Japanese translation.)
Weekday Abbreviations #
#: wp-includes/locale.php:31 msgid "Tue" msgstr "Уто"
(From the Serbian translation.)
Weekday Initials #
#: wp-includes/locale.php:18 msgid "T_Tuesday_initial" msgstr "ti"
The weekday initials are for WordPress’s calendar feature, and uses the same hack as the month abbreviations above to get around the fact that in English Tuesday and Thursday share the same first letter. Not all locales use single-letter abbreviations for all days. In the example above, Norwegian Bokmål uses an extra letter to distinguish tirsdag (Tuesday) and torsdag (Thursday).
Date Formatting Strings #
These are PHP date() formatting strings, and they allow you to change the formatting of the date and time for your locale.
WordPress uses the translations elsewhere in the localization file for month names, weekday names, etc. This special string is for the selection of which elements to include in the date & time, as well as the order in which they’re presented.
Take this msgid from the theme.pot file:
#: archive.php:40 search.php:19 single.php:22 msgid "l, F jS, Y" msgstr ""
In English, this gets formatted as:
Sunday, February 27th, 2005
However, different locales format their dates differently. In Danish, for example, dates are written:
søndag, 27. februar 2005
To accomplish this, the msgid above would be translated to:
#: archive.php:40 search.php:19 single.php:22 msgid "l, F jS, Y" msgstr "l, j. F Y"
To use another example, one way to format dates in Chinese and Japanese is as follows:
This would be accomplished in the translation like this:
#: archive.php:40 search.php:19 single.php:22 msgid "l, F jS, Y" msgstr "Y年n月j日"
Lastly, if you need to include literal alphabetic characters in your date format, as sometimes occurs in Spanish, you can backslash them:
#: archive.php:40 search.php:19 single.php:22 msgid "l, F jS, Y" msgstr "l j \d\e F \d\e Y "
This would output:
domingo 27 de febrero de 2005
Translation via WordPress-PHP #
Messages With Placeholders #
Many messages contain special PHP formatting placeholders, which allow the insertion of untranslatable dynamic content into the message after it is translated. The PHP placeholders come in two different formats:
%s: used when only one placeholder is present.
%1$s, %2$s, %3$s, …: numbered placeholders, which enable translators to rearrange their order. This allows for more flexibility in the translated string while ensuring the dynamic content will still be inserted in the right places.
In the example below – from the Spanish translation – the message inserts the username of the user to which an email has been sent.
#: wp-login.php:116 msgid "The e-mail was sent successfully to %s's e-mail address." msgstr "El e-mail fue enviado satisfactoriamente a la dirección e-mail de %s."
Whereas, the example below – from the Chinese translation – uses numbered placeholders and reverses the order in which the filename and type are used.
#: wp-admin/upload.php:96 #, php-format msgid "File %1$s of type %2$s is not allowed." msgstr "类型为%2$s的文件%1$s不允许被上传。"
Stop Words #
Stop words are very common words that should be excluded from a search, like ‘a’, ‘the’, and ‘and’. You should not simply translate these individual words into your language. Instead, look for and provide commonly accepted stopwords in your language.
- WordPress core’s comparison algorithm for stop words is looking for exact matches, so if your language makes use of diacritic marks, be sure to include all possible variation of a stop word in the list (e.g “pravé” and “právě”).
- There’s no need to add single letter stop words (if those letters are in the A-Z range).
#: wp-includes/query.php:2031 msgctxt "Comma-separated list of search stopwords in your language" msgid "about,an,are,as,at,be,by,com,for,from,how,in,is,it,of,on,or,that,the,this,to,was,what,when,where,who,will,with,www" msgstr "le,la,les,de,des,un,uns,une,unes,et,a,à,il,elle,on,ne,je,tu,nous,vous,ils,elles,son,sa,ses,que,quoi,se,qui,ce,cette,dans,en,du,au,aux,pour,pas,sur,y,ou,où,si,ton,ta,te,mon,ma,tout,toute,tous,toutes,ça,ni,www,com,fr,par,sur,par,dans,mais,vos,votre,vôtre,sans,toi,moi,lui,leur,leurs"