This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/Translation/MessageCatalogueInterface.php

173 lines
4.1 KiB
PHP
Raw Normal View History

2010-09-27 08:45:29 +01:00
<?php
/*
* This file is part of the Symfony package.
2010-09-27 08:45:29 +01:00
*
* (c) Fabien Potencier <fabien@symfony.com>
2010-09-27 08:45:29 +01:00
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
2010-09-27 08:45:29 +01:00
*/
namespace Symfony\Component\Translation;
use Symfony\Component\Config\Resource\ResourceInterface;
2010-09-27 08:45:29 +01:00
/**
* MessageCatalogueInterface.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @api
2010-09-27 08:45:29 +01:00
*/
interface MessageCatalogueInterface
{
/**
* Gets the catalogue locale.
*
* @return string The locale
*
* @api
2010-09-27 08:45:29 +01:00
*/
2012-07-09 13:50:58 +01:00
public function getLocale();
2010-09-27 08:45:29 +01:00
/**
* Gets the domains.
2010-10-16 13:42:42 +01:00
*
* @return array An array of domains
*
* @api
2010-09-27 08:45:29 +01:00
*/
2012-07-09 13:50:58 +01:00
public function getDomains();
2010-09-27 08:45:29 +01:00
/**
* Gets the messages within a given domain.
*
* If $domain is null, it returns all messages.
*
* @param string $domain The domain name
*
2010-10-16 11:32:57 +01:00
* @return array An array of messages
*
* @api
2010-09-27 08:45:29 +01:00
*/
2012-07-09 13:50:58 +01:00
public function all($domain = null);
2010-09-27 08:45:29 +01:00
/**
* Sets a message translation.
*
* @param string $id The message id
* @param string $translation The messages translation
* @param string $domain The domain name
*
* @api
2010-09-27 08:45:29 +01:00
*/
2012-07-09 13:50:58 +01:00
public function set($id, $translation, $domain = 'messages');
2010-09-27 08:45:29 +01:00
/**
* Checks if a message has a translation.
*
* @param string $id The message id
* @param string $domain The domain name
*
2014-11-30 13:33:44 +00:00
* @return bool true if the message has a translation, false otherwise
*
* @api
2010-09-27 08:45:29 +01:00
*/
2012-07-09 13:50:58 +01:00
public function has($id, $domain = 'messages');
2010-09-27 08:45:29 +01:00
/**
* Checks if a message has a translation (it does not take into account the fallback mechanism).
*
* @param string $id The message id
* @param string $domain The domain name
*
2014-11-30 13:33:44 +00:00
* @return bool true if the message has a translation, false otherwise
*
* @api
*/
2012-07-09 13:50:58 +01:00
public function defines($id, $domain = 'messages');
2010-09-27 08:45:29 +01:00
/**
* Gets a message translation.
*
* @param string $id The message id
* @param string $domain The domain name
*
* @return string The message translation
*
* @api
2010-09-27 08:45:29 +01:00
*/
2012-07-09 13:50:58 +01:00
public function get($id, $domain = 'messages');
2010-09-27 08:45:29 +01:00
/**
* Sets translations for a given domain.
*
* @param array $messages An array of translations
2010-09-27 08:45:29 +01:00
* @param string $domain The domain name
*
* @api
2010-09-27 08:45:29 +01:00
*/
2012-07-09 13:50:58 +01:00
public function replace($messages, $domain = 'messages');
2010-09-27 08:45:29 +01:00
/**
* Adds translations for a given domain.
*
* @param array $messages An array of translations
2010-09-27 08:45:29 +01:00
* @param string $domain The domain name
*
* @api
2010-09-27 08:45:29 +01:00
*/
2012-07-09 13:50:58 +01:00
public function add($messages, $domain = 'messages');
2010-09-27 08:45:29 +01:00
/**
* Merges translations from the given Catalogue into the current one.
*
2010-10-31 21:33:08 +00:00
* The two catalogues must have the same locale.
*
2010-09-27 08:45:29 +01:00
* @param MessageCatalogueInterface $catalogue A MessageCatalogueInterface instance
*
* @api
2010-09-27 08:45:29 +01:00
*/
2012-07-09 13:50:58 +01:00
public function addCatalogue(MessageCatalogueInterface $catalogue);
2010-09-27 08:45:29 +01:00
2010-10-31 21:33:08 +00:00
/**
* Merges translations from the given Catalogue into the current one
* only when the translation does not exist.
*
* This is used to provide default translations when they do not exist for the current locale.
*
* @param MessageCatalogueInterface $catalogue A MessageCatalogueInterface instance
*
* @api
2010-10-31 21:33:08 +00:00
*/
2012-07-09 13:50:58 +01:00
public function addFallbackCatalogue(MessageCatalogueInterface $catalogue);
2010-10-31 21:33:08 +00:00
2011-09-28 15:46:33 +01:00
/**
* Gets the fallback catalogue.
*
* @return MessageCatalogueInterface|null A MessageCatalogueInterface instance or null when no fallback has been set
2011-09-28 15:46:33 +01:00
*
* @api
*/
2012-07-09 13:50:58 +01:00
public function getFallbackCatalogue();
2011-09-28 15:46:33 +01:00
2010-09-27 08:45:29 +01:00
/**
* Returns an array of resources loaded to build this collection.
*
* @return ResourceInterface[] An array of resources
*
* @api
2010-09-27 08:45:29 +01:00
*/
2012-07-09 13:50:58 +01:00
public function getResources();
2010-09-27 08:45:29 +01:00
/**
* Adds a resource for this collection.
*
* @param ResourceInterface $resource A resource instance
*
* @api
2010-09-27 08:45:29 +01:00
*/
2012-07-09 13:50:58 +01:00
public function addResource(ResourceInterface $resource);
2010-09-27 08:45:29 +01:00
}