1. sfIMessageSource.class.php
  2. /** * sfIMessageSource interface. * * All messages source used by MessageFormat must be of sfIMessageSource. * It defines a set of operations to add and retrieve messages from the * message source. In addition, message source can load a particular * catalogue. * * @author Xiang Wei Zhuo * @version v1.0, last update on Fri Dec 24 17:40:19 EST 2004 * @package symfony * @subpackage i18n */
  3. interface sfIMessageSource
  4. {
  5. /**
  6. * Loads the translation table for this particular catalogue.
  7. * The translation should be loaded in the following order.
  8. * # [1] call getCatalogueList($catalogue) to get a list of variants for for the specified $catalogue.
  9. * # [2] for each of the variants, call getSource($variant) to get the resource, could be a file or catalogue ID.
  10. * # [3] verify that this resource is valid by calling isValidSource($source)
  11. * # [4] try to get the messages from the cache
  12. * # [5] if a cache miss, call load($source) to load the message array
  13. * # [6] store the messages to cache.
  14. * # [7] continue with the foreach loop, e.g. goto [2].
  15. *
  16. * @param string $catalogue a catalogue to load
  17. * @return boolean true if loaded, false otherwise.
  18. */
  19. function load($catalogue = 'messages');
  20. /**
  21. * Gets the translation table. This includes all the loaded sections.
  22. * It must return a 2 level array of translation strings.
  23. * # "catalogue+variant" the catalogue and its variants.
  24. * # "source string" translation keys, and its translations.
  25. * <code>
  26. * array('catalogue+variant' =>
  27. * array('source string' => 'target string', ...)
  28. * ...),
  29. * ...);
  30. * </code>
  31. *
  32. * @return array 2 level array translation table.
  33. */
  34. function read();
  35. /**
  36. * Saves the list of untranslated blocks to the translation source.
  37. * If the translation was not found, you should add those
  38. * strings to the translation source via the <b>append()</b> method.
  39. *
  40. * @param string $catalogue the catalogue to add to
  41. * @return boolean true if saved successfuly, false otherwise.
  42. */
  43. function save($catalogue = 'messages');
  44. /**
  45. * Adds a untranslated message to the source. Need to call save()
  46. * to save the messages to source.
  47. *
  48. * @param string $message message to add
  49. * @return void
  50. */
  51. function append($message);
  52. /**
  53. * Deletes a particular message from the specified catalogue.
  54. *
  55. * @param string $message the source message to delete.
  56. * @param string $catalogue the catalogue to delete from.
  57. * @return boolean true if deleted, false otherwise.
  58. */
  59. function delete($message, $catalogue = 'messages');
  60. /**
  61. * Updates the translation.
  62. *
  63. * @param string $text the source string.
  64. * @param string $target the new translation string.
  65. * @param string $comments comments
  66. * @param string $catalogue the catalogue of the translation.
  67. * @return boolean true if translation was updated, false otherwise.
  68. */
  69. function update($text, $target, $comments, $catalogue = 'messages');
  70. /**
  71. * Returns a list of catalogue as key and all it variants as value.
  72. *
  73. * @return array list of catalogues
  74. */
  75. function catalogues();
  76. /**
  77. * Set the culture for this particular message source.
  78. *
  79. * @param string $culture the Culture name.
  80. */
  81. function setCulture($culture);
  82. /**
  83. * Get the culture identifier for the source.
  84. *
  85. * @return string culture identifier.
  86. */
  87. function getCulture();
  88. /**
  89. * Returns a unique identifier for the current message source.
  90. */
  91. function getId();
  92. }

Debug toolbar