4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Translation
;
14 use Symfony\Component\Config\
Resource\ResourceInterface
;
17 * MessageCatalogueInterface.
19 * @author Fabien Potencier <fabien@symfony.com>
23 interface MessageCatalogueInterface
26 * Gets the catalogue locale.
28 * @return string The locale
32 public function getLocale();
37 * @return array An array of domains
41 public function getDomains();
44 * Gets the messages within a given domain.
46 * If $domain is null, it returns all messages.
48 * @param string $domain The domain name
50 * @return array An array of messages
54 public function all($domain = null);
57 * Sets a message translation.
59 * @param string $id The message id
60 * @param string $translation The messages translation
61 * @param string $domain The domain name
65 public function set($id, $translation, $domain = 'messages');
68 * Checks if a message has a translation.
70 * @param string $id The message id
71 * @param string $domain The domain name
73 * @return Boolean true if the message has a translation, false otherwise
77 public function has($id, $domain = 'messages');
80 * Checks if a message has a translation (it does not take into account the fallback mechanism).
82 * @param string $id The message id
83 * @param string $domain The domain name
85 * @return Boolean true if the message has a translation, false otherwise
89 public function defines($id, $domain = 'messages');
92 * Gets a message translation.
94 * @param string $id The message id
95 * @param string $domain The domain name
97 * @return string The message translation
101 public function get($id, $domain = 'messages');
104 * Sets translations for a given domain.
106 * @param array $messages An array of translations
107 * @param string $domain The domain name
111 public function replace($messages, $domain = 'messages');
114 * Adds translations for a given domain.
116 * @param array $messages An array of translations
117 * @param string $domain The domain name
121 public function add($messages, $domain = 'messages');
124 * Merges translations from the given Catalogue into the current one.
126 * The two catalogues must have the same locale.
128 * @param MessageCatalogueInterface $catalogue A MessageCatalogueInterface instance
132 public function addCatalogue(MessageCatalogueInterface
$catalogue);
135 * Merges translations from the given Catalogue into the current one
136 * only when the translation does not exist.
138 * This is used to provide default translations when they do not exist for the current locale.
140 * @param MessageCatalogueInterface $catalogue A MessageCatalogueInterface instance
144 public function addFallbackCatalogue(MessageCatalogueInterface
$catalogue);
147 * Gets the fallback catalogue.
149 * @return MessageCatalogueInterface|null A MessageCatalogueInterface instance or null when no fallback has been set
153 public function getFallbackCatalogue();
156 * Returns an array of resources loaded to build this collection.
158 * @return ResourceInterface[] An array of resources
162 public function getResources();
165 * Adds a resource for this collection.
167 * @param ResourceInterface $resource A resource instance
171 public function addResource(ResourceInterface
$resource);