modules/promotion/src/Element/CouponRedemptionForm.php | 2 +- modules/promotion/src/Entity/Promotion.php | 13 +++++++------ modules/promotion/src/Form/PromotionForm.php | 2 +- src/Plugin/Field/FieldType/PluginItemDeriver.php | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/modules/promotion/src/Element/CouponRedemptionForm.php b/modules/promotion/src/Element/CouponRedemptionForm.php index 8a2664a2..0ddb914b 100644 --- a/modules/promotion/src/Element/CouponRedemptionForm.php +++ b/modules/promotion/src/Element/CouponRedemptionForm.php @@ -19,7 +19,7 @@ use Drupal\Core\Render\Element\FormElement; * $form['coupon'] = [ * '#type' => 'commerce_coupon_redemption_form', * '#title' => t('Coupon code'), - * '#description' => t('Enter your coupon code to redeem a promotion.'), + * '#description' => t('Enter your coupon code to redeem a promotion.', [], ['context' => 'a drupal commerce promotion']), * '#order_id' => $order_id, * ]; * @endcode diff --git a/modules/promotion/src/Entity/Promotion.php b/modules/promotion/src/Entity/Promotion.php index 87a0c59b..4af37252 100644 --- a/modules/promotion/src/Entity/Promotion.php +++ b/modules/promotion/src/Entity/Promotion.php @@ -15,13 +15,14 @@ use Drupal\Core\Field\BaseFieldDefinition; * * @ContentEntityType( * id = "commerce_promotion", - * label = @Translation("Promotion"), - * label_collection = @Translation("Promotions"), - * label_singular = @Translation("promotion"), - * label_plural = @Translation("promotions"), + * label = @Translation("Promotion", context = "a drupal commerce promotion"), + * label_collection = @Translation("Promotions", context = "a drupal commerce promotion"), + * label_singular = @Translation("promotion", context = "a drupal commerce promotion"), + * label_plural = @Translation("promotions", context = "a drupal commerce promotion"), * label_count = @PluralTranslation( * singular = "@count promotion", * plural = "@count promotions", + * context = "a drupal commerce promotion", * ), * handlers = { * "event" = "Drupal\commerce_promotion\Event\PromotionEvent", @@ -718,8 +719,8 @@ class Promotion extends ContentEntityBase implements PromotionInterface { */ public static function getCompatibilityOptions() { return [ - self::COMPATIBLE_ANY => t('Any promotion'), - self::COMPATIBLE_NONE => t('Not with any other promotions'), + self::COMPATIBLE_ANY => t('Any promotion', [], ['context' => 'a drupal commerce promotion']), + self::COMPATIBLE_NONE => t('Not with any other promotions', [], ['context' => 'a drupal commerce promotion']), ]; } diff --git a/modules/promotion/src/Form/PromotionForm.php b/modules/promotion/src/Form/PromotionForm.php index eb112603..6417ba97 100644 --- a/modules/promotion/src/Form/PromotionForm.php +++ b/modules/promotion/src/Form/PromotionForm.php @@ -96,7 +96,7 @@ class PromotionForm extends ContentEntityForm { */ public function save(array $form, FormStateInterface $form_state) { $this->entity->save(); - drupal_set_message($this->t('Saved the %label promotion.', ['%label' => $this->entity->label()])); + drupal_set_message($this->t('Saved the %label promotion.', ['%label' => $this->entity->label()], ['context' => 'a drupal commerce promotion'])); $form_state->setRedirect('entity.commerce_promotion.collection'); } diff --git a/src/Plugin/Field/FieldType/PluginItemDeriver.php b/src/Plugin/Field/FieldType/PluginItemDeriver.php index bb4163bd..0169a112 100644 --- a/src/Plugin/Field/FieldType/PluginItemDeriver.php +++ b/src/Plugin/Field/FieldType/PluginItemDeriver.php @@ -53,7 +53,7 @@ class PluginItemDeriver extends DeriverBase implements ContainerDeriverInterface public function getDerivativeDefinitions($base_plugin_definition) { $plugin_types = [ 'commerce_condition' => $this->t('Condition'), - 'commerce_promotion_offer' => $this->t('Promotion offer'), + 'commerce_promotion_offer' => $this->t('Promotion offer', [], ['context' => 'a drupal commerce promotion']), ]; // Core has no way to list plugin types, so each referenceable plugin // type needs to register itself via the event.