I have a Drupal 7 site and need to output a small calendar control written in PHP.
It outputs a month name and table with days. Table has a header with week day names:
‘Mon’, ‘Tue’.
I need to output this with the current site language selected in Drupal. What’s the best way of doing this?
In Drupal the function used to translate strings is t().
When you enable a language that is not English, the literal strings passed to
t()are replaced with the translation available in the translation files. If there isn’t a translation for the weekday short names, then on admin/config/regional/translate/translate you can add the translations.As the translation system is implemented in Drupal, it works only when the string passed to
t()is a literal string. If the module is calling the function passing one of the following arguments, the string is not translatable.t('This is a' . 'string that is not translatable'))t($text_to_translate))t(get_string(STRING_ID_ERROR_MESSAGE)))If the module is hosted on drupal.org, then it can use the translation services provided from http://localize.drupal.org.