18
18
*/
19
19
class sfMessageSource_Aggregate extends sfMessageSource
20
20
{
21
- protected
22
- $ messageSources = array ();
21
+ protected $ messageSources = array ();
23
22
24
23
/**
25
24
* Constructor.
@@ -46,6 +45,12 @@ public function setCulture($culture)
46
45
}
47
46
}
48
47
48
+ /**
49
+ * Gets the last modified unix-time for this particular catalogue+variant.
50
+ *
51
+ * @param string $source catalogue+variant
52
+ * @return int last modified in unix-time format.
53
+ */
49
54
protected function getLastModified ($ sources )
50
55
{
51
56
$ lastModified = time ();
@@ -60,6 +65,12 @@ protected function getLastModified($sources)
60
65
return $ lastModified ;
61
66
}
62
67
68
+ /**
69
+ * Determines if the source is valid.
70
+ *
71
+ * @param string $source catalogue+variant
72
+ * @return boolean true if valid, false otherwise.
73
+ */
63
74
public function isValidSource ($ sources )
64
75
{
65
76
foreach ($ sources as $ source )
@@ -75,6 +86,12 @@ public function isValidSource($sources)
75
86
return false ;
76
87
}
77
88
89
+ /**
90
+ * Gets the source, this could be a filename or database ID.
91
+ *
92
+ * @param string $variant catalogue+variant
93
+ * @return string the resource key
94
+ */
78
95
public function getSource ($ variant )
79
96
{
80
97
$ sources = array ();
@@ -86,6 +103,12 @@ public function getSource($variant)
86
103
return $ sources ;
87
104
}
88
105
106
+ /**
107
+ * Loads the message for a particular catalogue+variant.
108
+ * This methods needs to implemented by subclasses.
109
+ *
110
+ * @return array of translation messages.
111
+ */
89
112
public function &loadData ($ sources )
90
113
{
91
114
$ messages = array ();
@@ -106,6 +129,13 @@ public function &loadData($sources)
106
129
return $ messages ;
107
130
}
108
131
132
+ /**
133
+ * Gets all the variants of a particular catalogue.
134
+ * This method must be implemented by subclasses.
135
+ *
136
+ * @param string $catalogue catalogue name
137
+ * @return array list of all variants for this catalogue.
138
+ */
109
139
public function getCatalogueList ($ catalogue )
110
140
{
111
141
$ variants = array ();
@@ -120,6 +150,12 @@ public function getCatalogueList($catalogue)
120
150
return $ variants ;
121
151
}
122
152
153
+ /**
154
+ * Adds a untranslated message to the source. Need to call save()
155
+ * to save the messages to source.
156
+ *
157
+ * @param string $message message to add
158
+ */
123
159
public function append ($ message )
124
160
{
125
161
// Append to the first message source only
@@ -129,6 +165,15 @@ public function append($message)
129
165
}
130
166
}
131
167
168
+ /**
169
+ * Updates the translation.
170
+ *
171
+ * @param string $text the source string.
172
+ * @param string $target the new translation string.
173
+ * @param string $comments comments
174
+ * @param string $catalogue the catalogue of the translation.
175
+ * @return boolean true if translation was updated, false otherwise.
176
+ */
132
177
public function update ($ text , $ target , $ comments , $ catalogue = 'messages ' )
133
178
{
134
179
// Only update one message source
@@ -143,6 +188,13 @@ public function update($text, $target, $comments, $catalogue = 'messages')
143
188
return false ;
144
189
}
145
190
191
+ /**
192
+ * Deletes a particular message from the specified catalogue.
193
+ *
194
+ * @param string $message the source message to delete.
195
+ * @param string $catalogue the catalogue to delete from.
196
+ * @return boolean true if deleted, false otherwise.
197
+ */
146
198
public function delete ($ message , $ catalogue = 'messages ' )
147
199
{
148
200
$ retval = false ;
@@ -157,6 +209,14 @@ public function delete($message, $catalogue = 'messages')
157
209
return $ retval ;
158
210
}
159
211
212
+ /**
213
+ * Saves the list of untranslated blocks to the translation source.
214
+ * If the translation was not found, you should add those
215
+ * strings to the translation source via the <b>append()</b> method.
216
+ *
217
+ * @param string $catalogue the catalogue to add to
218
+ * @return boolean true if saved successfuly, false otherwise.
219
+ */
160
220
public function save ($ catalogue = 'messages ' )
161
221
{
162
222
$ retval = false ;
@@ -182,6 +242,11 @@ public function getId()
182
242
return md5 ($ id );
183
243
}
184
244
245
+ /**
246
+ * Returns a list of catalogue as key and all it variants as value.
247
+ *
248
+ * @return array list of catalogues
249
+ */
185
250
public function catalogues ()
186
251
{
187
252
throw new sfException ('The "catalogues()" method is not implemented for this message source. ' );
0 commit comments