sfIMessageSource.class.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. /**
  3. * sfIMessageSource interface file.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the BSD License.
  7. *
  8. * Copyright(c) 2004 by Qiang Xue. All rights reserved.
  9. *
  10. * To contact the author write to {@link mailto:qiang.xue@gmail.com Qiang Xue}
  11. * The latest version of PRADO can be obtained from:
  12. * {@link http://prado.sourceforge.net/}
  13. *
  14. * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
  15. * @version $Id: sfIMessageSource.class.php 9128 2008-05-21 00:58:19Z Carl.Vondrick $
  16. * @package symfony
  17. * @subpackage i18n
  18. */
  19. /**
  20. * sfIMessageSource interface.
  21. *
  22. * All messages source used by MessageFormat must be of sfIMessageSource.
  23. * It defines a set of operations to add and retrieve messages from the
  24. * message source. In addition, message source can load a particular
  25. * catalogue.
  26. *
  27. * @author Xiang Wei Zhuo <weizhuo[at]gmail[dot]com>
  28. * @version v1.0, last update on Fri Dec 24 17:40:19 EST 2004
  29. * @package symfony
  30. * @subpackage i18n
  31. */
  32. interface sfIMessageSource
  33. {
  34. /**
  35. * Loads the translation table for this particular catalogue.
  36. * The translation should be loaded in the following order.
  37. * # [1] call getCatalogueList($catalogue) to get a list of variants for for the specified $catalogue.
  38. * # [2] for each of the variants, call getSource($variant) to get the resource, could be a file or catalogue ID.
  39. * # [3] verify that this resource is valid by calling isValidSource($source)
  40. * # [4] try to get the messages from the cache
  41. * # [5] if a cache miss, call load($source) to load the message array
  42. * # [6] store the messages to cache.
  43. * # [7] continue with the foreach loop, e.g. goto [2].
  44. *
  45. * @param string $catalogue a catalogue to load
  46. * @return boolean true if loaded, false otherwise.
  47. */
  48. function load($catalogue = 'messages');
  49. /**
  50. * Gets the translation table. This includes all the loaded sections.
  51. * It must return a 2 level array of translation strings.
  52. * # "catalogue+variant" the catalogue and its variants.
  53. * # "source string" translation keys, and its translations.
  54. * <code>
  55. * array('catalogue+variant' =>
  56. * array('source string' => 'target string', ...)
  57. * ...),
  58. * ...);
  59. * </code>
  60. *
  61. * @return array 2 level array translation table.
  62. */
  63. function read();
  64. /**
  65. * Saves the list of untranslated blocks to the translation source.
  66. * If the translation was not found, you should add those
  67. * strings to the translation source via the <b>append()</b> method.
  68. *
  69. * @param string $catalogue the catalogue to add to
  70. * @return boolean true if saved successfuly, false otherwise.
  71. */
  72. function save($catalogue = 'messages');
  73. /**
  74. * Adds a untranslated message to the source. Need to call save()
  75. * to save the messages to source.
  76. *
  77. * @param string $message message to add
  78. * @return void
  79. */
  80. function append($message);
  81. /**
  82. * Deletes a particular message from the specified catalogue.
  83. *
  84. * @param string $message the source message to delete.
  85. * @param string $catalogue the catalogue to delete from.
  86. * @return boolean true if deleted, false otherwise.
  87. */
  88. function delete($message, $catalogue = 'messages');
  89. /**
  90. * Updates the translation.
  91. *
  92. * @param string $text the source string.
  93. * @param string $target the new translation string.
  94. * @param string $comments comments
  95. * @param string $catalogue the catalogue of the translation.
  96. * @return boolean true if translation was updated, false otherwise.
  97. */
  98. function update($text, $target, $comments, $catalogue = 'messages');
  99. /**
  100. * Returns a list of catalogue as key and all it variants as value.
  101. *
  102. * @return array list of catalogues
  103. */
  104. function catalogues();
  105. /**
  106. * Set the culture for this particular message source.
  107. *
  108. * @param string $culture the Culture name.
  109. */
  110. function setCulture($culture);
  111. /**
  112. * Get the culture identifier for the source.
  113. *
  114. * @return string culture identifier.
  115. */
  116. function getCulture();
  117. /**
  118. * Returns a unique identifier for the current message source.
  119. */
  120. function getId();
  121. }