String
A Drupal module for managing and translating strings using "Keyword" philosophy.
<?php
$this->t('Drupal is great');
$this->t('drupal.great');
In the first method, messages are written in the language of the default locale (English in this case). That message is then used as the "id" when creating translations.
In the second method, messages are actually "keywords" that convey the idea of the message. The keyword message is then used as the "id" for any translations. In this case, translations must be made for the default locale (i.e. to translate drupal.great
to Drupal is great
).
String enables developers to,
- define Keyword (i.e.
drupal.great
) - optionally provide a default value
Drupal is great
- integrate with core's translation api so that it works well with
t
function, locale import/export, editing interface translation, etc.
Documentation
For detailed documentation, please visit our documentation site.
Quick Links
Support
Sample usage
Current (Core) | String |
---|---|
t('Dashboard') |
t('dashboard.title') |
t('My Dashboard') |
t('user_dashboard.title') |
t('Welcome @name!', ['@name' => $name]) |
t('dashboard.welcome_message.title', ['@name' => $name]) |
format_plural($count, '1 item', '@count items') |
format_plural($count, 'search_result.item_count', 'search_result.item_count') |