From fa26ead0f6814dfa7dd9989da3c9f77c057be08f Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Mon, 26 Nov 2018 17:15:17 +0100 Subject: [PATCH] DOCS Add namespaces to PHP i18n examples, and reference __CLASS__ and self::class as options --- docs/en/02_Developer_Guides/13_i18n/index.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/en/02_Developer_Guides/13_i18n/index.md b/docs/en/02_Developer_Guides/13_i18n/index.md index 524c19fed..93e87dd5e 100644 --- a/docs/en/02_Developer_Guides/13_i18n/index.md +++ b/docs/en/02_Developer_Guides/13_i18n/index.md @@ -254,16 +254,20 @@ Please ensure that any required plurals are exposed via provideI18nEntities. ```php // Simple string translation -_t('LeftAndMain.FILESIMAGES','Files & Images'); +_t('SilverStripe\\Admin\\LeftAndMain.FILESIMAGES','Files & Images'); // Using injection to add variables into the translated strings. -_t('CMSMain.RESTORED', +_t('SilverStripe\\CMS\\Controllers\\CMSMain.RESTORED', "Restored {value} successfully", ['value' => $itemRestored] ); // Plurals are invoked via a `|` pipe-delimeter with a {count} argument _t('MyObject.PLURALS', 'An object|{count} objects', [ 'count' => $count ]); + +// You can use __CLASS__ or self::class to reference the current (early bound) class name +_t(self::class . '.GREETING', 'Welcome!'); +_t(__CLASS__ . '.GREETING', 'Welcome!'); ``` #### Usage in Template Files