Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 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 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
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 retrieve 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    symfony
32
 * @subpackage i18n
33
 */
34
interface sfIMessageSource
35
{
36
  /**
37
   * Loads the translation table for this particular catalogue.
38
   * The translation should be loaded in the following order.
39
   *  # [1] call getCatalogueList($catalogue) to get a list of variants for for the specified $catalogue.
40
   *  # [2] for each of the variants, call getSource($variant) to get the resource, could be a file or catalogue ID.
41
   *  # [3] verify that this resource is valid by calling isValidSource($source)
42
   *  # [4] try to get the messages from the cache
43
   *  # [5] if a cache miss, call load($source) to load the message array
44
   *  # [6] store the messages to cache.
45
   *  # [7] continue with the foreach loop, e.g. goto [2].
46
   *
47
   * @param string $catalogue a catalogue to load
48
   * @return boolean true if loaded, false otherwise.
49
   */
50
  function load($catalogue = 'messages');
51
 
52
  /**
53
   * Gets the translation table. This includes all the loaded sections.
54
   * It must return a 2 level array of translation strings.
55
   * # "catalogue+variant" the catalogue and its variants.
56
   * # "source string" translation keys, and its translations.
57
   * <code>
58
   *   array('catalogue+variant' =>
59
   *       array('source string' => 'target string', ...)
60
   *             ...),
61
   *        ...);
62
   * </code>
63
   *
64
   * @return array 2 level array translation table.
65
   */
66
  function read();
67
 
68
  /**
69
   * Saves the list of untranslated blocks to the translation source.
70
   * If the translation was not found, you should add those
71
   * strings to the translation source via the <b>append()</b> method.
72
   *
73
   * @param string $catalogue the catalogue to add to
74
   * @return boolean true if saved successfuly, false otherwise.
75
   */
76
  function save($catalogue = 'messages');
77
 
78
  /**
79
   * Adds a untranslated message to the source. Need to call save()
80
   * to save the messages to source.
81
   *
82
   * @param string $message message to add
83
   * @return void
84
   */
85
  function append($message);
86
 
87
  /**
88
   * Deletes a particular message from the specified catalogue.
89
   *
90
   * @param string $message   the source message to delete.
91
   * @param string $catalogue the catalogue to delete from.
92
   * @return boolean true if deleted, false otherwise.
93
   */
94
  function delete($message, $catalogue = 'messages');
95
 
96
  /**
97
   * Updates the translation.
98
   *
99
   * @param string $text      the source string.
100
   * @param string $target    the new translation string.
101
   * @param string $comments  comments
102
   * @param string $catalogue the catalogue of the translation.
103
   * @return boolean true if translation was updated, false otherwise.
104
   */
105
  function update($text, $target, $comments, $catalogue = 'messages');
106
 
107
  /**
108
   * Returns a list of catalogue as key and all it variants as value.
109
   *
110
   * @return array list of catalogues
111
   */
112
  function catalogues();
113
 
114
  /**
115
   * Set the culture for this particular message source.
116
   *
117
   * @param string $culture the Culture name.
118
   */
119
  function setCulture($culture);
120
 
121
  /**
122
   * Get the culture identifier for the source.
123
   *
124
   * @return string culture identifier.
125
   */
126
  function getCulture();
127
 
128
  /**
129
   * Returns a unique identifier for the current message source.
130
   */
131
  function getId();
132
}