Skip to content

Commit

Permalink
Fix(deprecations) Fix deprecations in sfMessageSource_Aggregate (#277)
Browse files Browse the repository at this point in the history
* Fix(deprecations) Fix deprecations in sfMessageSource_Aggregate, add return types from implemented sfIMessageSource
  • Loading branch information
thePanz authored Jan 13, 2023
1 parent 31d2c60 commit 2c5a4d6
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CHANGELOG
=========

=======
xx/xx/xxxx: Version 1.5.16
--------------------------

Expand Down
69 changes: 67 additions & 2 deletions lib/i18n/sfMessageSource_Aggregate.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
*/
class sfMessageSource_Aggregate extends sfMessageSource
{
protected
$messageSources = array();
protected $messageSources = array();

/**
* Constructor.
Expand All @@ -46,6 +45,12 @@ public function setCulture($culture)
}
}

/**
* Gets the last modified unix-time for this particular catalogue+variant.
*
* @param string $source catalogue+variant
* @return int last modified in unix-time format.
*/
protected function getLastModified($sources)
{
$lastModified = time();
Expand All @@ -60,6 +65,12 @@ protected function getLastModified($sources)
return $lastModified;
}

/**
* Determines if the source is valid.
*
* @param string $source catalogue+variant
* @return boolean true if valid, false otherwise.
*/
public function isValidSource($sources)
{
foreach ($sources as $source)
Expand All @@ -75,6 +86,12 @@ public function isValidSource($sources)
return false;
}

/**
* Gets the source, this could be a filename or database ID.
*
* @param string $variant catalogue+variant
* @return string the resource key
*/
public function getSource($variant)
{
$sources = array();
Expand All @@ -86,6 +103,12 @@ public function getSource($variant)
return $sources;
}

/**
* Loads the message for a particular catalogue+variant.
* This methods needs to implemented by subclasses.
*
* @return array of translation messages.
*/
public function &loadData($sources)
{
$messages = array();
Expand All @@ -106,6 +129,13 @@ public function &loadData($sources)
return $messages;
}

/**
* Gets all the variants of a particular catalogue.
* This method must be implemented by subclasses.
*
* @param string $catalogue catalogue name
* @return array list of all variants for this catalogue.
*/
public function getCatalogueList($catalogue)
{
$variants = array();
Expand All @@ -120,6 +150,12 @@ public function getCatalogueList($catalogue)
return $variants;
}

/**
* Adds a untranslated message to the source. Need to call save()
* to save the messages to source.
*
* @param string $message message to add
*/
public function append($message)
{
// Append to the first message source only
Expand All @@ -129,6 +165,15 @@ public function append($message)
}
}

/**
* Updates the translation.
*
* @param string $text the source string.
* @param string $target the new translation string.
* @param string $comments comments
* @param string $catalogue the catalogue of the translation.
* @return boolean true if translation was updated, false otherwise.
*/
public function update($text, $target, $comments, $catalogue = 'messages')
{
// Only update one message source
Expand All @@ -143,6 +188,13 @@ public function update($text, $target, $comments, $catalogue = 'messages')
return false;
}

/**
* Deletes a particular message from the specified catalogue.
*
* @param string $message the source message to delete.
* @param string $catalogue the catalogue to delete from.
* @return boolean true if deleted, false otherwise.
*/
public function delete($message, $catalogue = 'messages')
{
$retval = false;
Expand All @@ -157,6 +209,14 @@ public function delete($message, $catalogue = 'messages')
return $retval;
}

/**
* Saves the list of untranslated blocks to the translation source.
* If the translation was not found, you should add those
* strings to the translation source via the <b>append()</b> method.
*
* @param string $catalogue the catalogue to add to
* @return boolean true if saved successfuly, false otherwise.
*/
public function save($catalogue = 'messages')
{
$retval = false;
Expand All @@ -182,6 +242,11 @@ public function getId()
return md5($id);
}

/**
* Returns a list of catalogue as key and all it variants as value.
*
* @return array list of catalogues
*/
public function catalogues()
{
throw new sfException('The "catalogues()" method is not implemented for this message source.');
Expand Down

0 comments on commit 2c5a4d6

Please sign in to comment.