Prechádzať zdrojové kódy

[Translation] tagged the guaranteed BC API

Fabien Potencier 14 rokov pred
rodič
commit
34cf511a1d

+ 12 - 0
src/Symfony/Component/Translation/IdentityTranslator.php

@@ -15,6 +15,8 @@ namespace Symfony\Component\Translation;
  * IdentityTranslator does not translate anything.
  *
  * @author Fabien Potencier <fabien@symfony.com>
+ *
+ * @api
  */
 class IdentityTranslator implements TranslatorInterface
 {
@@ -24,6 +26,8 @@ class IdentityTranslator implements TranslatorInterface
      * Constructor.
      *
      * @param MessageSelector $selector The message selector for pluralization
+     *
+     * @api
      */
     public function __construct(MessageSelector $selector)
     {
@@ -32,6 +36,8 @@ class IdentityTranslator implements TranslatorInterface
 
     /**
      * {@inheritdoc}
+     *
+     * @api
      */
     public function setLocale($locale)
     {
@@ -39,6 +45,8 @@ class IdentityTranslator implements TranslatorInterface
 
     /**
      * {@inheritdoc}
+     *
+     * @api
      */
     public function getLocale()
     {
@@ -46,6 +54,8 @@ class IdentityTranslator implements TranslatorInterface
 
     /**
      * {@inheritdoc}
+     *
+     * @api
      */
     public function trans($id, array $parameters = array(), $domain = 'messages', $locale = null)
     {
@@ -54,6 +64,8 @@ class IdentityTranslator implements TranslatorInterface
 
     /**
      * {@inheritdoc}
+     *
+     * @api
      */
     public function transChoice($id, $number, array $parameters = array(), $domain = 'messages', $locale = null)
     {

+ 4 - 0
src/Symfony/Component/Translation/Loader/ArrayLoader.php

@@ -17,11 +17,15 @@ use Symfony\Component\Translation\MessageCatalogue;
  * ArrayLoader loads translations from a PHP array.
  *
  * @author Fabien Potencier <fabien@symfony.com>
+ *
+ * @api
  */
 class ArrayLoader implements LoaderInterface
 {
     /**
      * {@inheritdoc}
+     *
+     * @api
      */
     public function load($resource, $locale, $domain = 'messages')
     {

+ 4 - 0
src/Symfony/Component/Translation/Loader/CsvFileLoader.php

@@ -17,11 +17,15 @@ use Symfony\Component\Config\Resource\FileResource;
  * CsvFileLoader loads translations from CSV files.
  *
  * @author Saša Stamenković <umpirsky@gmail.com>
+ *
+ * @api
  */
 class CsvFileLoader extends ArrayLoader implements LoaderInterface
 {
     /**
      * {@inheritdoc}
+     *
+     * @api
      */
     public function load($resource, $locale, $domain = 'messages')
     {

+ 4 - 0
src/Symfony/Component/Translation/Loader/LoaderInterface.php

@@ -17,6 +17,8 @@ use Symfony\Component\Translation\MessageCatalogue;
  * LoaderInterface is the interface implemented by all translation loaders.
  *
  * @author Fabien Potencier <fabien@symfony.com>
+ *
+ * @api
  */
 interface LoaderInterface
 {
@@ -28,6 +30,8 @@ interface LoaderInterface
      * @param  string $domain   The domain
      *
      * @return MessageCatalogue A MessageCatalogue instance
+     *
+     * @api
      */
     function load($resource, $locale, $domain = 'messages');
 }

+ 4 - 0
src/Symfony/Component/Translation/Loader/PhpFileLoader.php

@@ -17,11 +17,15 @@ use Symfony\Component\Config\Resource\FileResource;
  * PhpFileLoader loads translations from PHP files returning an array of translations.
  *
  * @author Fabien Potencier <fabien@symfony.com>
+ *
+ * @api
  */
 class PhpFileLoader extends ArrayLoader implements LoaderInterface
 {
     /**
      * {@inheritdoc}
+     *
+     * @api
      */
     public function load($resource, $locale, $domain = 'messages')
     {

+ 4 - 0
src/Symfony/Component/Translation/Loader/XliffFileLoader.php

@@ -18,11 +18,15 @@ use Symfony\Component\Config\Resource\FileResource;
  * XliffFileLoader loads translations from XLIFF files.
  *
  * @author Fabien Potencier <fabien@symfony.com>
+ *
+ * @api
  */
 class XliffFileLoader implements LoaderInterface
 {
     /**
      * {@inheritdoc}
+     *
+     * @api
      */
     public function load($resource, $locale, $domain = 'messages')
     {

+ 4 - 0
src/Symfony/Component/Translation/Loader/YamlFileLoader.php

@@ -18,11 +18,15 @@ use Symfony\Component\Yaml\Yaml;
  * YamlFileLoader loads translations from Yaml files.
  *
  * @author Fabien Potencier <fabien@symfony.com>
+ *
+ * @api
  */
 class YamlFileLoader extends ArrayLoader implements LoaderInterface
 {
     /**
      * {@inheritdoc}
+     *
+     * @api
      */
     public function load($resource, $locale, $domain = 'messages')
     {

+ 28 - 0
src/Symfony/Component/Translation/MessageCatalogue.php

@@ -17,6 +17,8 @@ use Symfony\Component\Config\Resource\ResourceInterface;
  * MessageCatalogue.
  *
  * @author Fabien Potencier <fabien@symfony.com>
+ *
+ * @api
  */
 class MessageCatalogue implements MessageCatalogueInterface
 {
@@ -29,6 +31,8 @@ class MessageCatalogue implements MessageCatalogueInterface
      *
      * @param string $locale   The locale
      * @param array  $messages An array of messages classified by domain
+     *
+     * @api
      */
     public function __construct($locale, array $messages = array())
     {
@@ -39,6 +43,8 @@ class MessageCatalogue implements MessageCatalogueInterface
 
     /**
      * {@inheritdoc}
+     *
+     * @api
      */
     public function getLocale()
     {
@@ -47,6 +53,8 @@ class MessageCatalogue implements MessageCatalogueInterface
 
     /**
      * {@inheritdoc}
+     *
+     * @api
      */
     public function getDomains()
     {
@@ -55,6 +63,8 @@ class MessageCatalogue implements MessageCatalogueInterface
 
     /**
      * {@inheritdoc}
+     *
+     * @api
      */
     public function all($domain = null)
     {
@@ -67,6 +77,8 @@ class MessageCatalogue implements MessageCatalogueInterface
 
     /**
      * {@inheritdoc}
+     *
+     * @api
      */
     public function set($id, $translation, $domain = 'messages')
     {
@@ -75,6 +87,8 @@ class MessageCatalogue implements MessageCatalogueInterface
 
     /**
      * {@inheritdoc}
+     *
+     * @api
      */
     public function has($id, $domain = 'messages')
     {
@@ -83,6 +97,8 @@ class MessageCatalogue implements MessageCatalogueInterface
 
     /**
      * {@inheritdoc}
+     *
+     * @api
      */
     public function get($id, $domain = 'messages')
     {
@@ -91,6 +107,8 @@ class MessageCatalogue implements MessageCatalogueInterface
 
     /**
      * {@inheritdoc}
+     *
+     * @api
      */
     public function replace($messages, $domain = 'messages')
     {
@@ -101,6 +119,8 @@ class MessageCatalogue implements MessageCatalogueInterface
 
     /**
      * {@inheritdoc}
+     *
+     * @api
      */
     public function add($messages, $domain = 'messages')
     {
@@ -113,6 +133,8 @@ class MessageCatalogue implements MessageCatalogueInterface
 
     /**
      * {@inheritdoc}
+     *
+     * @api
      */
     public function addCatalogue(MessageCatalogueInterface $catalogue)
     {
@@ -131,6 +153,8 @@ class MessageCatalogue implements MessageCatalogueInterface
 
     /**
      * {@inheritdoc}
+     *
+     * @api
      */
     public function addFallbackCatalogue(MessageCatalogueInterface $catalogue)
     {
@@ -149,6 +173,8 @@ class MessageCatalogue implements MessageCatalogueInterface
 
     /**
      * {@inheritdoc}
+     *
+     * @api
      */
     public function getResources()
     {
@@ -157,6 +183,8 @@ class MessageCatalogue implements MessageCatalogueInterface
 
     /**
      * {@inheritdoc}
+     *
+     * @api
      */
     public function addResource(ResourceInterface $resource)
     {

+ 26 - 0
src/Symfony/Component/Translation/MessageCatalogueInterface.php

@@ -17,6 +17,8 @@ use Symfony\Component\Config\Resource\ResourceInterface;
  * MessageCatalogueInterface.
  *
  * @author Fabien Potencier <fabien@symfony.com>
+ *
+ * @api
  */
 interface MessageCatalogueInterface
 {
@@ -24,6 +26,8 @@ interface MessageCatalogueInterface
      * Gets the catalogue locale.
      *
      * @return string The locale
+     *
+     * @api
      */
     function getLocale();
 
@@ -31,6 +35,8 @@ interface MessageCatalogueInterface
      * Gets the domains.
      *
      * @return array An array of domains
+     *
+     * @api
      */
     function getDomains();
 
@@ -42,6 +48,8 @@ interface MessageCatalogueInterface
      * @param string $domain The domain name
      *
      * @return array An array of messages
+     *
+     * @api
      */
     function all($domain = null);
 
@@ -51,6 +59,8 @@ interface MessageCatalogueInterface
      * @param string $id          The message id
      * @param string $translation The messages translation
      * @param string $domain      The domain name
+     *
+     * @api
      */
     function set($id, $translation, $domain = 'messages');
 
@@ -61,6 +71,8 @@ interface MessageCatalogueInterface
      * @param string $domain The domain name
      *
      * @return Boolean true if the message has a translation, false otherwise
+     *
+     * @api
      */
     function has($id, $domain = 'messages');
 
@@ -71,6 +83,8 @@ interface MessageCatalogueInterface
      * @param string $domain The domain name
      *
      * @return string The message translation
+     *
+     * @api
      */
     function get($id, $domain = 'messages');
 
@@ -79,6 +93,8 @@ interface MessageCatalogueInterface
      *
      * @param string $messages An array of translations
      * @param string $domain   The domain name
+     *
+     * @api
      */
     function replace($messages, $domain = 'messages');
 
@@ -87,6 +103,8 @@ interface MessageCatalogueInterface
      *
      * @param string $messages An array of translations
      * @param string $domain   The domain name
+     *
+     * @api
      */
     function add($messages, $domain = 'messages');
 
@@ -96,6 +114,8 @@ interface MessageCatalogueInterface
      * The two catalogues must have the same locale.
      *
      * @param MessageCatalogueInterface $catalogue A MessageCatalogueInterface instance
+     *
+     * @api
      */
     function addCatalogue(MessageCatalogueInterface $catalogue);
 
@@ -106,6 +126,8 @@ interface MessageCatalogueInterface
      * This is used to provide default translations when they do not exist for the current locale.
      *
      * @param MessageCatalogueInterface $catalogue A MessageCatalogueInterface instance
+     *
+     * @api
      */
     function addFallbackCatalogue(MessageCatalogueInterface $catalogue);
 
@@ -113,6 +135,8 @@ interface MessageCatalogueInterface
      * Returns an array of resources loaded to build this collection.
      *
      * @return ResourceInterface[] An array of resources
+     *
+     * @api
      */
     function getResources();
 
@@ -120,6 +144,8 @@ interface MessageCatalogueInterface
      * Adds a resource for this collection.
      *
      * @param ResourceInterface $resource A resource instance
+     *
+     * @api
      */
     function addResource(ResourceInterface $resource);
 }

+ 4 - 0
src/Symfony/Component/Translation/MessageSelector.php

@@ -15,6 +15,8 @@ namespace Symfony\Component\Translation;
  * MessageSelector.
  *
  * @author Fabien Potencier <fabien@symfony.com>
+ *
+ * @api
  */
 class MessageSelector
 {
@@ -41,6 +43,8 @@ class MessageSelector
      * @param  integer $number The number of items represented for the message
      * @param  string $locale The locale to use for choosing
      * @return string
+     *
+     * @api
      */
     public function choose($message, $number, $locale)
     {

+ 18 - 0
src/Symfony/Component/Translation/Translator.php

@@ -17,6 +17,8 @@ use Symfony\Component\Translation\Loader\LoaderInterface;
  * Translator.
  *
  * @author Fabien Potencier <fabien@symfony.com>
+ *
+ * @api
  */
 class Translator implements TranslatorInterface
 {
@@ -32,6 +34,8 @@ class Translator implements TranslatorInterface
      *
      * @param string          $locale   The locale
      * @param MessageSelector $selector The message selector for pluralization
+     *
+     * @api
      */
     public function __construct($locale = null, MessageSelector $selector)
     {
@@ -47,6 +51,8 @@ class Translator implements TranslatorInterface
      *
      * @param string          $format The name of the loader (@see addResource())
      * @param LoaderInterface $loader A LoaderInterface instance
+     *
+     * @api
      */
     public function addLoader($format, LoaderInterface $loader)
     {
@@ -60,6 +66,8 @@ class Translator implements TranslatorInterface
      * @param mixed  $resource The resource name
      * @param string $locale   The locale
      * @param string $domain   The domain
+     *
+     * @api
      */
     public function addResource($format, $resource, $locale, $domain = 'messages')
     {
@@ -72,6 +80,8 @@ class Translator implements TranslatorInterface
 
     /**
      * {@inheritdoc}
+     *
+     * @api
      */
     public function setLocale($locale)
     {
@@ -80,6 +90,8 @@ class Translator implements TranslatorInterface
 
     /**
      * {@inheritdoc}
+     *
+     * @api
      */
     public function getLocale()
     {
@@ -90,6 +102,8 @@ class Translator implements TranslatorInterface
      * Sets the fallback locale.
      *
      * @param string $locale The fallback locale
+     *
+     * @api
      */
     public function setFallbackLocale($locale)
     {
@@ -101,6 +115,8 @@ class Translator implements TranslatorInterface
 
     /**
      * {@inheritdoc}
+     *
+     * @api
      */
     public function trans($id, array $parameters = array(), $domain = 'messages', $locale = null)
     {
@@ -117,6 +133,8 @@ class Translator implements TranslatorInterface
 
     /**
      * {@inheritdoc}
+     *
+     * @api
      */
     public function transChoice($id, $number, array $parameters = array(), $domain = 'messages', $locale = null)
     {

+ 10 - 0
src/Symfony/Component/Translation/TranslatorInterface.php

@@ -15,6 +15,8 @@ namespace Symfony\Component\Translation;
  * TranslatorInterface.
  *
  * @author Fabien Potencier <fabien@symfony.com>
+ *
+ * @api
  */
 interface TranslatorInterface
 {
@@ -27,6 +29,8 @@ interface TranslatorInterface
      * @param string $locale     The locale
      *
      * @return string The translated string
+     *
+     * @api
      */
     function trans($id, array $parameters = array(), $domain = null, $locale = null);
 
@@ -40,6 +44,8 @@ interface TranslatorInterface
      * @param string  $locale     The locale
      *
      * @return string The translated string
+     *
+     * @api
      */
     function transChoice($id, $number, array $parameters = array(), $domain = null, $locale = null);
 
@@ -47,6 +53,8 @@ interface TranslatorInterface
      * Sets the current locale.
      *
      * @param string $locale The locale
+     *
+     * @api
      */
     function setLocale($locale);
 
@@ -54,6 +62,8 @@ interface TranslatorInterface
      * Returns the current locale.
      *
      * @return string The locale
+     *
+     * @api
      */
     function getLocale();
 }