t(‘Go to %page’,
array(‘%page’ => $p));
Drupal.t(‘Go to %page’,
D!"#$% 6 Ch!$for new versions at hojtsy.hu – Freely redistri
By Gábor Hojtsy –
Translates ‘Home’ play.
ion API e’) language used for page dis
Core PHP translat to the Drupal.t(‘Hom
t(‘H ome’) requested language.
Plural Returns the prop er translation for
Drupal.format l rules in
Returns the proper (count, the text based on plura
lation for the text ba ‘1 comment’, the page’s langu
on plural rules in the
‘@coun t comments’)
‘1 comment’, guage.
’) requested lan can be provided,
ents placements array
Optional variable realways the page language!
and language is
Optional variable re provided in this order.
n be ix characters)
language code ca ats (based on pref
Replacement form value escaped with
features Replaced with the ut.
ns using translation
Other PHP functio @count check_plain() for outp
format_date Translates parts
+,-$& (,--&bu. ble as long as credit is kept.
value escaped an
($timesta mp, date/time formatting. Replaced with the r (theme
'medium', ...) ted as a placeholde
interval in (‘placeh older’)).
Displays the time t
l Translates value as is, withou
format_interva human terms. Replaced with the ting. Insecure! Only
... ) names of the segments.
($timestamp, ional format
!html any addit eady sanitized your text.
provided use if you alr
Formats a file size e MB, y(
tes. Translate s th irectory’, arra
ize, ...) in by me moved to @d
format_size($s Example: t(‘%na => $dirname);
KB and byte labels lename, ‘@dire
1.1 - '*.-/0
‘%name’ => $ﬁ
e code at the end.
an optional languag
All functions accept th e installer
Translating text in
ed later y as t(), but
translation and us Works the same wa ckend. Use
Text extracted for y ba
e; uses a file+memor
fo ﬁles description; package na
me. st(‘Home’ ) only in the installer and in install
profiles. No plural
Literal permission d
hook_per m() when provided with standar ll files and any
-! 15. 2007.
ns array syntax. Use get_t() in .insta
implementatio could run in the
other code which s ‘t’ or ‘st’
$t = get_t(); installer too. It retu nction to be
Menu item ‘title’ an
hook_menu() ‘description’ keys
, when $t(‘H ome’); depending on the fu
implem entations provided as literal str used at the momen
Log type and mes ral nslation, your
and need to use traif your module
when pr ovided as lite have an .install file ler
Remember: if you easily end up running in the instal e get_t()!
u’, strings. Third parameter
watchdog(‘men function calls could core module in an install profile. Us
calls specifies the replacements becomes a
‘Items saved’) pport.
array. No plural su
Usage of t() in a glo ST’, t(‘...’)). The
mistakes e message eg. for
The most common Reuse of the sam such as define(‘CON t initialized at
lues, such as t($type). d drupal_set_mes
sage() t ye
locale system is no e is incorrect
Using dynamic va s to call watchdog() an
dynamic string allows t(), the later e, so this usag
Whenever you use make sure that all calls. The former dis t possible. that tim
the above functions eady in the code is no
requires t(), so this e API functions and also leads to
possibl e values are alr I. Always ca ll the abov problems. Never do
l form using the AP indirection.
elsewhere in litera er provided content. directly, without
Do not translate
e using the API pr
operly ule plugin support, rt a
ar s have coder mod po
Tools to verify you Drupal 6. x-2 or later version rted in reviews. Also feel free to ex .
e API is repo ings appear
improper use of th ule/theme and check whether all str
http://drupal.org template for your m e t() or some
en you forgot to us
nn ot find mistakes wh localization client has a
The potx module ca late your output. The . If certain
ot her function to trans translate text displayed on the page e API.
_clie nt convenient interface to , you forg ot to use th
rg/project/l10n ing up for translation
http://drupal.o strings are not show
•Translation teams commit .po ﬁles to CVS
and under contributed projects
•Released on the parent project’s
•Drupal imports automatically
TRANSLATE YOUR CODE
• Open Atrium and Gallery 2 uses
Localization server to translate their
• Youcan set up l10n_server to parse
your own code and translate in-house
• Eg. https://translate.openatrium.com/