Development

HowToGenerateI18NFiles: sfIMessageSource.class.php

You must first sign up to be able to contribute.

HowToGenerateI18NFiles: sfIMessageSource.class.php

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