Update translation template and fix incorrect use of ts()

This commit is contained in:
Jens Schuppe 2024-09-11 13:30:39 +02:00
parent 2834f8028d
commit fa301676e3
5 changed files with 862 additions and 274 deletions

View file

@ -458,7 +458,7 @@ class CRM_Twingle_BAO_TwingleProduct extends CRM_Twingle_DAO_TwingleProduct {
}
catch (\Civi\Core\Exception\DBQueryException $e) {
throw new ProductException(
E::ts('Could not find TwingleProduct in database: ' . $e->getMessage()),
E::ts('Could not find TwingleProduct in database: %1', [1 => $e->getMessage()]),
ShopException::ERROR_CODE_COULD_NOT_FIND_SHOP_IN_DB);
}
@ -466,7 +466,8 @@ class CRM_Twingle_BAO_TwingleProduct extends CRM_Twingle_DAO_TwingleProduct {
$twingle_product_values = $this->getAttributes();
try {
\CRM_Utils_Hook::pre($mode, 'TwingleProduct', $this->id, $twingle_product_values);
} catch (\Exception $e) {
}
catch (\Exception $e) {
$tx->rollback();
throw $e;
}
@ -481,14 +482,15 @@ class CRM_Twingle_BAO_TwingleProduct extends CRM_Twingle_DAO_TwingleProduct {
// Save object to database
try {
$this->save();
} catch (\Exception $e) {
}
catch (\Exception $e) {
$tx->rollback();
throw new ProductException(
E::ts('Could not save TwingleProduct to database: ' . $e->getMessage()),
E::ts('Could not save TwingleProduct to database: %1', [1 => $e->getMessage()]),
ProductException::ERROR_CODE_COULD_NOT_CREATE_PRODUCT);
}
$result = self::findById($this->id);
/* @var self $result */
/** @var self $result */
$this->load($result->getAttributes());
// Register post-hook
@ -629,7 +631,7 @@ class CRM_Twingle_BAO_TwingleProduct extends CRM_Twingle_DAO_TwingleProduct {
}
catch (CRM_Core_Exception $e) {
throw new ProductException(
E::ts('An Error occurred while searching for the associated PriceFieldValue: ' . $e->getMessage()),
E::ts('An Error occurred while searching for the associated PriceFieldValue: %1', [1 => $e->getMessage()]),
ProductException::ERROR_CODE_PRICE_FIELD_VALUE_NOT_FOUND);
}
try {
@ -637,7 +639,7 @@ class CRM_Twingle_BAO_TwingleProduct extends CRM_Twingle_DAO_TwingleProduct {
}
catch (CRM_Core_Exception $e) {
throw new ProductException(
E::ts('Could not delete associated PriceFieldValue: ' . $e->getMessage()),
E::ts('Could not delete associated PriceFieldValue: %1', [1 => $e->getMessage()]),
ProductException::ERROR_CODE_COULD_NOT_DELETE_PRICE_FIELD_VALUE);
}
@ -661,13 +663,14 @@ class CRM_Twingle_BAO_TwingleProduct extends CRM_Twingle_DAO_TwingleProduct {
}
catch (CRM_Core_Exception $e) {
throw new ProductException(
E::ts('An Error occurred while searching for the associated PriceField: ' . $e->getMessage()),
E::ts('An Error occurred while searching for the associated PriceField: %1', [1 => $e->getMessage()]),
ProductException::ERROR_CODE_PRICE_FIELD_NOT_FOUND);
}
throw new ProductException(
E::ts('Could not delete associated PriceField: ' . $e->getMessage()),
E::ts('Could not delete associated PriceField: %1', [1 => $e->getMessage()]),
ProductException::ERROR_CODE_COULD_NOT_DELETE_PRICE_FIELD);
}
$this->price_field_id = NULL;
}
}

View file

@ -147,9 +147,10 @@ class CRM_Twingle_BAO_TwingleShop extends CRM_Twingle_DAO_TwingleShop {
if ($dao->fetch()) {
$this->load($dao->toArray());
}
} catch (\Civi\Core\Exception\DBQueryException $e) {
}
catch (\Civi\Core\Exception\DBQueryException $e) {
throw new ShopException(
E::ts('Could not find TwingleShop in database: ' . $e->getMessage()),
E::ts('Could not find TwingleShop in database: %1', [1 => $e->getMessage()]),
ShopException::ERROR_CODE_COULD_NOT_FIND_SHOP_IN_DB);
}
@ -191,7 +192,7 @@ class CRM_Twingle_BAO_TwingleShop extends CRM_Twingle_DAO_TwingleShop {
catch (\CRM_Core_Exception $e) {
if ($e->getMessage() != 'Expected one PriceSet but found 0') {
throw new ShopException(
E::ts('Could not find associated PriceSet: ' . $e->getMessage()),
E::ts('Could not find associated PriceSet: %1', [1 => $e->getMessage()]),
ShopException::ERROR_CODE_PRICE_SET_NOT_FOUND);
}
else {
@ -207,7 +208,7 @@ class CRM_Twingle_BAO_TwingleShop extends CRM_Twingle_DAO_TwingleShop {
['id' => $this->price_set_id]);
} catch (\CRM_Core_Exception $e) {
throw new ShopException(
E::ts('Could not delete associated PriceSet: ' . $e->getMessage()),
E::ts('Could not delete associated PriceSet: %1', [1 => $e->getMessage()]),
ShopException::ERROR_CODE_COULD_NOT_DELETE_PRICE_SET);
}
@ -451,9 +452,10 @@ class CRM_Twingle_BAO_TwingleShop extends CRM_Twingle_DAO_TwingleShop {
public function deleteProducts() {
try {
$products = $this->getProducts();
} catch (\Civi\Core\Exception\DBQueryException $e) {
}
catch (\Civi\Core\Exception\DBQueryException $e) {
throw new ProductException(
E::ts('Could not retrieve associated products: ' . $e->getMessage()),
E::ts('Could not retrieve associated products: %1', [1 => $e->getMessage()]),
ProductException::ERROR_CODE_COULD_NOT_GET_PRODUCTS
);
}
@ -464,8 +466,8 @@ class CRM_Twingle_BAO_TwingleShop extends CRM_Twingle_DAO_TwingleShop {
}
catch (ProductException $e) {
throw new ProductException(
E::ts('Could not delete associated products: ' . $e->getMessage()),
ProductException::ERROR_CODE_COULD_NOT_DELETE_PRICE_SET
E::ts('Could not delete associated products: %1', [1 => $e->getMessage()]),
ProductException::ERROR_CODE_COULD_NOT_DELETE_PRICE_SET,
);
}
}

View file

@ -648,8 +648,7 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
if (!isset($profile_data[$key]) && $required) {
CRM_Core_Session::setStatus(
E::ts(
'The required configuration option "%1" has no value.'
. ' Saving the profile might set this option to a possibly unwanted default value.',
'The required configuration option "%1" has no value. Saving the profile might set this option to a possibly unwanted default value.',
[1 => $metadata['label'] ?? $key]
),
E::ts('Error'),

View file

@ -546,7 +546,7 @@ class CRM_Twingle_Submission {
if (!empty($line_item['is_error'])) {
$line_item_name = $line_item_data['name'];
throw new CiviCRM_API3_Exception(
E::ts("Could not create line item for product '$line_item_name'"),
E::ts("Could not create line item for product '%1'", [1 => $line_item_name]),
'api_error'
);
}

File diff suppressed because it is too large Load diff