Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@0
|
4 * This file is part of the Symfony package.
|
Chris@0
|
5 *
|
Chris@0
|
6 * (c) Fabien Potencier <fabien@symfony.com>
|
Chris@0
|
7 *
|
Chris@0
|
8 * For the full copyright and license information, please view the LICENSE
|
Chris@0
|
9 * file that was distributed with this source code.
|
Chris@0
|
10 */
|
Chris@0
|
11
|
Chris@0
|
12 namespace Symfony\Component\Translation;
|
Chris@0
|
13
|
Chris@0
|
14 use Symfony\Component\Config\Resource\ResourceInterface;
|
Chris@0
|
15
|
Chris@0
|
16 /**
|
Chris@0
|
17 * MessageCatalogueInterface.
|
Chris@0
|
18 *
|
Chris@0
|
19 * @author Fabien Potencier <fabien@symfony.com>
|
Chris@0
|
20 */
|
Chris@0
|
21 interface MessageCatalogueInterface
|
Chris@0
|
22 {
|
Chris@0
|
23 /**
|
Chris@0
|
24 * Gets the catalogue locale.
|
Chris@0
|
25 *
|
Chris@0
|
26 * @return string The locale
|
Chris@0
|
27 */
|
Chris@0
|
28 public function getLocale();
|
Chris@0
|
29
|
Chris@0
|
30 /**
|
Chris@0
|
31 * Gets the domains.
|
Chris@0
|
32 *
|
Chris@0
|
33 * @return array An array of domains
|
Chris@0
|
34 */
|
Chris@0
|
35 public function getDomains();
|
Chris@0
|
36
|
Chris@0
|
37 /**
|
Chris@0
|
38 * Gets the messages within a given domain.
|
Chris@0
|
39 *
|
Chris@0
|
40 * If $domain is null, it returns all messages.
|
Chris@0
|
41 *
|
Chris@0
|
42 * @param string $domain The domain name
|
Chris@0
|
43 *
|
Chris@0
|
44 * @return array An array of messages
|
Chris@0
|
45 */
|
Chris@0
|
46 public function all($domain = null);
|
Chris@0
|
47
|
Chris@0
|
48 /**
|
Chris@0
|
49 * Sets a message translation.
|
Chris@0
|
50 *
|
Chris@0
|
51 * @param string $id The message id
|
Chris@0
|
52 * @param string $translation The messages translation
|
Chris@0
|
53 * @param string $domain The domain name
|
Chris@0
|
54 */
|
Chris@0
|
55 public function set($id, $translation, $domain = 'messages');
|
Chris@0
|
56
|
Chris@0
|
57 /**
|
Chris@0
|
58 * Checks if a message has a translation.
|
Chris@0
|
59 *
|
Chris@0
|
60 * @param string $id The message id
|
Chris@0
|
61 * @param string $domain The domain name
|
Chris@0
|
62 *
|
Chris@0
|
63 * @return bool true if the message has a translation, false otherwise
|
Chris@0
|
64 */
|
Chris@0
|
65 public function has($id, $domain = 'messages');
|
Chris@0
|
66
|
Chris@0
|
67 /**
|
Chris@0
|
68 * Checks if a message has a translation (it does not take into account the fallback mechanism).
|
Chris@0
|
69 *
|
Chris@0
|
70 * @param string $id The message id
|
Chris@0
|
71 * @param string $domain The domain name
|
Chris@0
|
72 *
|
Chris@0
|
73 * @return bool true if the message has a translation, false otherwise
|
Chris@0
|
74 */
|
Chris@0
|
75 public function defines($id, $domain = 'messages');
|
Chris@0
|
76
|
Chris@0
|
77 /**
|
Chris@0
|
78 * Gets a message translation.
|
Chris@0
|
79 *
|
Chris@0
|
80 * @param string $id The message id
|
Chris@0
|
81 * @param string $domain The domain name
|
Chris@0
|
82 *
|
Chris@0
|
83 * @return string The message translation
|
Chris@0
|
84 */
|
Chris@0
|
85 public function get($id, $domain = 'messages');
|
Chris@0
|
86
|
Chris@0
|
87 /**
|
Chris@0
|
88 * Sets translations for a given domain.
|
Chris@0
|
89 *
|
Chris@0
|
90 * @param array $messages An array of translations
|
Chris@0
|
91 * @param string $domain The domain name
|
Chris@0
|
92 */
|
Chris@0
|
93 public function replace($messages, $domain = 'messages');
|
Chris@0
|
94
|
Chris@0
|
95 /**
|
Chris@0
|
96 * Adds translations for a given domain.
|
Chris@0
|
97 *
|
Chris@0
|
98 * @param array $messages An array of translations
|
Chris@0
|
99 * @param string $domain The domain name
|
Chris@0
|
100 */
|
Chris@0
|
101 public function add($messages, $domain = 'messages');
|
Chris@0
|
102
|
Chris@0
|
103 /**
|
Chris@0
|
104 * Merges translations from the given Catalogue into the current one.
|
Chris@0
|
105 *
|
Chris@0
|
106 * The two catalogues must have the same locale.
|
Chris@0
|
107 */
|
Chris@16
|
108 public function addCatalogue(self $catalogue);
|
Chris@0
|
109
|
Chris@0
|
110 /**
|
Chris@0
|
111 * Merges translations from the given Catalogue into the current one
|
Chris@0
|
112 * only when the translation does not exist.
|
Chris@0
|
113 *
|
Chris@0
|
114 * This is used to provide default translations when they do not exist for the current locale.
|
Chris@0
|
115 */
|
Chris@16
|
116 public function addFallbackCatalogue(self $catalogue);
|
Chris@0
|
117
|
Chris@0
|
118 /**
|
Chris@0
|
119 * Gets the fallback catalogue.
|
Chris@0
|
120 *
|
Chris@0
|
121 * @return self|null A MessageCatalogueInterface instance or null when no fallback has been set
|
Chris@0
|
122 */
|
Chris@0
|
123 public function getFallbackCatalogue();
|
Chris@0
|
124
|
Chris@0
|
125 /**
|
Chris@0
|
126 * Returns an array of resources loaded to build this collection.
|
Chris@0
|
127 *
|
Chris@0
|
128 * @return ResourceInterface[] An array of resources
|
Chris@0
|
129 */
|
Chris@0
|
130 public function getResources();
|
Chris@0
|
131
|
Chris@0
|
132 /**
|
Chris@0
|
133 * Adds a resource for this collection.
|
Chris@0
|
134 */
|
Chris@0
|
135 public function addResource(ResourceInterface $resource);
|
Chris@0
|
136 }
|