diff --git a/docs/en/topics/i18n.md b/docs/en/topics/i18n.md index 56a60d13f..b321c3822 100644 --- a/docs/en/topics/i18n.md +++ b/docs/en/topics/i18n.md @@ -79,7 +79,7 @@ not PHP's built-in [date()](http://nz.php.net/manual/en/function.date.php). By default, URLs for pages in SilverStripe (the `SiteTree->URLSegment` property) are automatically reduced to the allowed allowed subset of ASCII characters. -If characters outside this subsetare added, they are either removed or (if possible) "transliterated". +If characters outside this subset are added, they are either removed or (if possible) "transliterated". This describes the process of converting from one character set to another while keeping characters recognizeable. For example, vowels with french accents are replaced with their base characters, `pâté` becomes `pate`. @@ -103,7 +103,7 @@ Defaults can be applied globally for all field instances through [api:DateField: and [api:TimeField::set_default_config()]. If no 'locale' default is set on the field, [api:i18n::get_locale()] will be used. -Important: Form fields in the CMS are automatically configured according to the profile settings for the logged-in user (`Member->Locale`, `Member->DateFormat` and `Member->TimeFormat`). This means that in most cases, +**Important:** Form fields in the CMS are automatically configured according to the profile settings for the logged-in user (`Member->Locale`, `Member->DateFormat` and `Member->TimeFormat`). This means that in most cases, fields created through [api:DataObject::getCMSFields()] will get their i18n settings from a specific member The [api:DateField] API can be enhanced by JavaScript, and comes with @@ -130,12 +130,12 @@ language-dependent and use a translator function call instead. echo _t("Namespace.Entity","This is a string"); -All strings passed through the `_t()` function will be collected in a separate language table (see "Collecting entities" -below), which is the starting point for translations. +All strings passed through the `_t()` function will be collected in a separate language table (see [Collecting text](#collecting-text)), which is the starting point for translations. ### The _t() function -The `_t()` function is the main gateway to localized text, and takes four parameters, all but the first being optional. +The `_t()` function is the main gateway to localized text, and takes four parameters, all but the first being optional. +It can be used to translate strings in both PHP files and template files. The usage for each case is described below. * **$entity:** Unique identifier, composed by a namespace and an entity name, with a dot separating them. Both are arbitrary names, although by convention we use the name of the containing class or template. Use this identifier to reference the same translation elsewhere in your code. * **$string:** (optional) The original language string to be translated. Only needs to be declared once, and gets picked up the [text collector](#collecting-text). @@ -144,63 +144,45 @@ are very context dependent. This parameter allows the developer to convey this i to the translator. * **$array::** (optional) An array of injecting variables into the second parameter +#### Usage in PHP Files + :::php - //Example 4: Using context to hint information about a parameter + + // Simple string translation + _t('LeftAndMain.FILESIMAGES','Files & Images'); + + // Using the natural languate comment parameter to supply additional context information to translators + _t('LeftAndMain.HELLO','Site content','Menu title'); + + // Using injection to add variables into the translated strings. _t('CMSMain.RESTORED', "Restored {value} successfully", 'This is a message when restoring a broken part of the CMS', array('value' => $itemRestored) ); -### Usage +#### Usage in Template Files -There're two types of files in a module where you can use this _t() function: code files (under code folder) and -template files (under templates) +