Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix(deprecations) Fix deprecations in sfMessageSource_Aggregate, #277

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
--------------------------

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

/**
* Constructor.
@@ -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();
@@ -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)
@@ -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();
@@ -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();
@@ -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();
@@ -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
@@ -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
@@ -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;
@@ -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;
@@ -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.');