Backstage with Drupal localization session slides part 1 from Drupalcon Copenhagen. See part 2 at http://www.slideshare.net/devseed/backstage-with-drupal-localization-part-2.
4. D!"#$% 6 Ch!$for new versions at hojtsy.hu – Freely redistri
y Gábor Hojtsy –
ion API
JavaScript translat to the
Translates ‘Home’ ge display.
ion API e’) language used fo r pa
Core PHP translat to the Drupal.t(‘Hom
Translates ‘Home’
t(‘Home’) requested language. lation for
Plural Returns the proper trans
Drupal.format ral rules in
Returns the proper (count, the text based on plu
format_plural
& '(%$&)*'
sed age.
lation for the text ba ‘1 comment’, the page’s langu
eck
($count, trans les in the ents’)
‘1 comment’,
on plural ru ‘@count comm
ts’) requested
language. can be provided,
‘@count comm
en placements array
Optional variable realways the page language!
and language is
GET THE
placements array
Optional variable re provided in this order. acters)
language code ca
n be ased on prefix char
Repla cement formats (b
value escaped with
ns using translation features Replaced with the ut.
Other PHP functio @count check_plain() for outp
format_date Translates parts
of the
+,-$& (,--&bu. ble as long as credit is kept.
d
value escaped an
($tim estamp, date/time formatting. Replaced with the r (theme
'medium', ...) ted as a placeholde
%size format
interval in eholder’)).
CHEAT SHEET
Displays the time (‘plac
anslates t
l
format_interva human terms.
Tr value as is, withou
) gments. Replaced with the ting. Insecure! Only
($ timestamp, ... names of the se ional format
!html any additu already sanitized your text.
provided use if yo
Formats a file size e MB, y(
tes. Translates th irectory’, arra
ize, ...) in by me moved to @d
format_size($s Example: t(‘%na y’ => $dirnam
e);
ta
.
KB and byte labels me, ‘@director
1.1 - '*.-/0
‘%na me’ => $filena
e code at the end.
FROM
an optional languag
All functions accept the installer
Translating text in
ed later y as t(), but
translation and us Works the same wa ckend. Use
Text extracted for ory ba
e;
Module/theme nam name. uses a file+mem
and in install
.info files description; package st(‘Home’) only in the installer
support.
profiles. No plural
names,
Literal permission ard
hook_p erm() when provided with stand ll files and any
-! 15. 2007.
HOJTSY.HU
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
d rn
Menu item ‘title’ an en fu
hook_menu() ‘description’ keys
, wh $t (‘Home’); depending on the
l strings. t.
impl ementations provided as litera used at the momen
sage,
Log type and mes ral ur
use translation, yo le
provided as lite ll file and need to
when Remember: if you have an .insta running in the installer if your modu
u’, strings. Third parameter easily end up e get_t()!
watchdog(‘men function calls could core module in an install profile. Us
calls specifies the replacements become sa
‘Items saved’) pport.
array. No plural su
bal context,
mistakes Usage of t() in a glo ST’, t(‘...’)). The
The most common e message eg. for such as define( ‘CON
type). Reuse of the sam t yet initialized at
lues, such as t($ t_message() locale system is no e is incorrect
Using dynamic va g() and drupal_se
strings to call watchdo allows t(), the later ag
dynamic
Whenever you use make sure that all that time, so this us
ALSO SEE
, calls. The former dis t possible. ds to nasty perform
ance
the above functions eady in the code is no
requires t(), so this e API functions and also lea
it.
po ssible values are alr using the API. Always call the abov problems. Never do
l form indirection.
elsewhere in litera ovided content. directly, without
user pr
Do not translate
pport, so
e API properly r module plugin su
Tools to verify you
are using th er versions have code ws. Also feel free to export a
Drupal 6.x-2 or lat revie
e API is reported in ings appear.
improper use of th ule/theme and check whether all str
D.O/NODE/322729
rg/proje ct/potx od
http://drupal.o template for your m use t() or some
when you forgot to
nnot find mistakes e localization client has a
The potx module ca late your output. Th
ns ge. If certain
other function to tra to translate text displayed on the pa the API.
rg/project/l10n
_client convenient interface , you forgot to use
http://drupal.o ing up for translation
str ings are not show