8000 symfony/src/Symfony/Component/Translation/Translator.php at 2.7 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
< 8000 script type="application/json" data-target="react-app.embeddedData">{"payload":{"allShortcutsEnabled":false,"fileTree":{"src/Symfony/Component/Translation":{"items":[{"name":"Catalogue","path":"src/Symfony/Component/Translation/Catalogue","contentType":"directory"},{"name":"DataCollector","path":"src/Symfony/Component/Translation/DataCollector","contentType":"directory"},{"name":"Dumper","path":"src/Symfony/Component/Translation/Dumper","contentType":"directory"},{"name":"Exception","path":"src/Symfony/Component/Translation/Exception","contentType":"directory"},{"name":"Extractor","path":"src/Symfony/Component/Translation/Extractor","contentType":"directory"},{"name":"Loader","path":"src/Symfony/Component/Translation/Loader","contentType":"directory"},{"name":"Tests","path":"src/Symfony/Component/Translation/Tests","contentType":"directory"},{"name":"Writer","path":"src/Symfony/Component/Translation/Writer","contentType":"directory"},{"name":".gitignore","path":"src/Symfony/Component/Translation/.gitignore","contentType":"file"},{"name":"CHANGELOG.md","path":"src/Symfony/Component/Translation/CHANGELOG.md","contentType":"file"},{"name":"DataCollectorTranslator.php","path":"src/Symfony/Component/Translation/DataCollectorTranslator.php","contentType":"file"},{"name":"IdentityTranslator.php","path":"src/Symfony/Component/Translation/IdentityTranslator.php","contentType":"file"},{"name":"Interval.php","path":"src/Symfony/Component/Translation/Interval.php","contentType":"file"},{"name":"LICENSE","path":"src/Symfony/Component/Translation/LICENSE","contentType":"file"},{"name":"LoggingTranslator.php","path":"src/Symfony/Component/Translation/LoggingTranslator.php","contentType":"file"},{"name":"MessageCatalogue.php","path":"src/Symfony/Component/Translation/MessageCatalogue.php","contentType":"file"},{"name":"MessageCatalogueInterface.php","path":"src/Symfony/Component/Translation/MessageCatalogueInterface.php","contentType":"file"},{"name":"MessageSelector.php","path":"src/Symfony/Component/Translation/MessageSelector.php","contentType":"file"},{"name":"MetadataAwareInterface.php","path":"src/Symfony/Component/Translation/MetadataAwareInterface.php","contentType":"file"},{"name":"PluralizationRules.php","path":"src/Symfony/Component/Translation/PluralizationRules.php","contentType":"file"},{"name":"README.md","path":"src/Symfony/Component/Translation/README.md","contentType":"file"},{"name":"Translator.php","path":"src/Symfony/Component/Translation/Translator.php","contentType":"file"},{"name":"TranslatorBagInterface.php","path":"src/Symfony/Component/Translation/TranslatorBagInterface.php","contentType":"file"},{"name":"TranslatorInterface.php","path":"src/Symfony/Component/Translation/TranslatorInterface.php","contentType":"file"},{"name":"composer.json","path":"src/Symfony/Component/Translation/composer.json","contentType":"file"},{"name":"phpunit.xml.dist","path":"src/Symfony/Component/Translation/phpunit.xml.dist","contentType":"file"}],"totalCount":26},"src/Symfony/Component":{"items":[{"name":"Asset","path":"src/Symfony/Component/Asset","contentType":"directory"},{"name":"BrowserKit","path":"src/Symfony/Component/BrowserKit","contentType":"directory"},{"name":"ClassLoader","path":"src/Symfony/Component/ClassLoader","contentType":"directory"},{"name":"Config","path":"src/Symfony/Component/Config","contentType":"directory"},{"name":"Console","path":"src/Symfony/Component/Console","contentType":"directory"},{"name":"CssSelector","path":"src/Symfony/Component/CssSelector","contentType":"directory"},{"name":"Debug","path":"src/Symfony/Component/Debug","contentType":"directory"},{"name":"DependencyInjection","path":"src/Symfony/Component/DependencyInjection","contentType":"directory"},{"name":"DomCrawler","path":"src/Symfony/Component/DomCrawler","contentType":"directory"},{"name":"EventDispatcher","path":"src/Symfony/Component/EventDispatcher","contentType":"directory"},{"name":"ExpressionLanguage","path":"src/Symfony/Component/ExpressionLanguage","contentType":"directory"},{"name":"Filesystem","path":"src/Symfony/Component/Filesystem","contentType":"directory"},{"name":"Finder","path":"src/Symfony/Component/Finder","contentType":"directory"},{"name":"Form","path":"src/Symfony/Component/Form","contentType":"directory"},{"name":"HttpFoundation","path":"src/Symfony/Component/HttpFoundation","contentType":"directory"},{"name":"HttpKernel","path":"src/Symfony/Component/HttpKernel","contentType":"directory"},{"name":"Intl","path":"src/Symfony/Component/Intl","contentType":"directory"},{"name":"Locale","path":"src/Symfony/Component/Locale","contentType":"directory"},{"name":"OptionsResolver","path":"src/Symfony/Component/OptionsResolver","contentType":"directory"},{"name":"Process","path":"src/Symfony/Component/Process","contentType":"directory"},{"name":"PropertyAccess","path":"src/Symfony/Component/PropertyAccess","contentType":"directory"},{"name":"Routing","path":"src/Symfony/Component/Routing","contentType":"directory"},{"name":"Security","path":"src/Symfony/Component/Security","contentType":"directory"},{"name":"Serializer","path":"src/Symfony/Component/Serializer","contentType":"directory"},{"name":"Stopwatch","path":"src/Symfony/Component/Stopwatch","contentType":"directory"},{"name":"Templating","path":"src/Symfony/Component/Templating","contentType":"directory"},{"name":"Translation","path":"src/Symfony/Component/Translation","contentType":"directory"},{"name":"Validator","path":"src/Symfony/Component/Validator","contentType":"directory"},{"name":"VarDumper","path":"src/Symfony/Component/VarDumper","contentType":"directory"},{"name":"Yaml","path":"src/Symfony/Component/Yaml","contentType":"directory"}],"totalCount":30},"src/Symfony":{"items":[{"name":"Bridge","path":"src/Symfony/Bridge","contentType":"directory"},{"name":"Bundle","path":"src/Symfony/Bundle","contentType":"directory"},{"name":"Component","path":"src/Symfony/Component","contentType":"directory"}],"totalCount":3},"src":{"items":[{"name":"Symfony","path":"src/Symfony","contentType":"directory"}],"totalCount":1},"":{"items":[{"name":".composer","path":".composer","contentType":"directory"},{"name":".github","path":".github","contentType":"directory"},{"name":"src","path":"src","contentType":"directory"},{"name":".appveyor.yml","path":".appveyor.yml","contentType":"file"},{"name":".editorconfig","path":".editorconfig","contentType":"file"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":".php_cs.dist","path":".php_cs.dist","contentType":"file"},{"name":".travis.yml","path":".travis.yml","contentType":"file"},{"name":"CHANGELOG-2.2.md","path":"CHANGELOG-2.2.md","contentType":"file"},{"name":"CHANGELOG-2.3.md","path":"CHANGELOG-2.3.md","contentType":"file"},{"name":"CHANGELOG-2.4.md","path":"CHANGELOG-2.4.md","contentType":"file"},{"name":"CHANGELOG-2.5.md","path":"CHANGELOG-2.5.md","contentType":"file"},{"name":"CHANGELOG-2.6.md","path":"CHANGELOG-2.6.md","contentType":"file"},{"name":"CHANGELOG-2.7.md","path":"CHANGELOG-2.7.md","contentType":"file"},{"name":"CONTRIBUTING.md","path":"CONTRIBUTING.md","contentType":"file"},{"name":"CONTRIBUTORS.md","path":"CONTRIBUTORS.md","contentType":"file"},{"name":"LICENSE","path":"LICENSE","contentType":"file"},{"name":"README.md","path":"README.md","contentType":"file"},{"name":"UPGRADE-2.1.md","path":"UPGRADE-2.1.md","contentType":"file"},{"name":"UPGRADE-2.2.md","path":"UPGRADE-2.2.md","contentType":"file"},{"name":"UPGRADE-2.3.md","path":"UPGRADE-2.3.md","contentType":"file"},{"name":"UPGRADE-2.4.md","path":"UPGRADE-2.4.md","contentType":"file"},{"name":"UPGRADE-2.5.md","path":"UPGRADE-2.5.md","contentType":"file"},{"name":"UPGRADE-2.6.md","path":"UPGRADE-2.6.md","contentType":"file"},{"name":"UPGRADE-2.7.md","path":"UPGRADE-2.7.md","contentType":"file"},{"name":"UPGRADE-3.0.md","path":"UPGRADE-3.0.md","contentType":"file"},{"name":"composer.json","path":"composer.json","contentType":"file"},{"name":"link","path":"link","contentType":"file"},{"name":"phpunit","path":"phpunit","contentType":"file"},{"name":"phpunit.xml.dist","path":"phpunit.xml.dist","contentType":"file"}],"totalCount":30}},"fileTreeProcessingTime":37.286254,"foldersToFetch":[],"incompleteFileTree":false,"repo":{"id":458058,"defaultBranch":"7.3","name":"symfony","ownerLogin":"symfony","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2010-01-04T14:21:21.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/143937?v=4","public":true,"private":false,"isOrgOwned":true},"codeLineWrapEnabled":false,"symbolsExpanded":false,"treeExpanded":true,"refInfo":{"name":"2.7","listCacheKey":"v0:1746879009.0","canEdit":false,"refType":"branch","currentOid":"4d0899c5e3b30b3be591f8349ce92529d79bee93"},"path":"src/Symfony/Component/Translation/Translator.php","currentUser":null,"blob":{"rawLines":["\u003c?php","","/*"," * This file is part of the Symfony package."," *"," * (c) Fabien Potencier \u003cfabien@symfony.com\u003e"," *"," * For the full copyright and license information, please view the LICENSE"," * file that was distributed with this source code."," */","","namespace Symfony\\Component\\Translation;","","use Symfony\\Component\\Translation\\Loader\\LoaderInterface;","use Symfony\\Component\\Translation\\Exception\\NotFoundResourceException;","use Symfony\\Component\\Config\\ConfigCacheInterface;","use Symfony\\Component\\Config\\ConfigCacheFactoryInterface;","use Symfony\\Component\\Config\\ConfigCacheFactory;","","/**"," * @author Fabien Potencier \u003cfabien@symfony.com\u003e"," */","class Translator implements TranslatorInterface, TranslatorBagInterface","{"," /**"," * @var MessageCatalogueInterface[]"," */"," protected $catalogues = array();",""," /**"," * @var string"," */"," protected $locale;",""," /**"," * @var array"," */"," private $fallbackLocales = array();",""," /**"," * @var LoaderInterface[]"," */"," private $loaders = array();",""," /**"," * @var array"," */"," private $resources = array();",""," /**"," * @var MessageSelector"," */"," private $selector;",""," /**"," * @var string"," */"," private $cacheDir;",""," /**"," * @var bool"," */"," private $debug;",""," /**"," * @var ConfigCacheFactoryInterface|null"," */"," private $configCacheFactory;",""," /**"," * @param string $locale The locale"," * @param MessageSelector|null $selector The message selector for pluralization"," * @param string|null $cacheDir The directory to use for the cache"," * @param bool $debug Use cache in debug mode ?"," *"," * @throws \\InvalidArgumentException If a locale contains invalid characters"," */"," public function __construct($locale, MessageSelector $selector = null, $cacheDir = null, $debug = false)"," {"," $this-\u003esetLocale($locale);"," $this-\u003eselector = $selector ?: new MessageSelector();"," $this-\u003ecacheDir = $cacheDir;"," $this-\u003edebug = $debug;"," }",""," public function setConfigCacheFactory(ConfigCacheFactoryInterface $configCacheFactory)"," {"," $this-\u003econfigCacheFactory = $configCacheFactory;"," }",""," /**"," * Adds a Loader."," *"," * @param string $format The name of the loader (@see addResource())"," * @param LoaderInterface $loader A LoaderInterface instance"," */"," public function addLoader($format, LoaderInterface $loader)"," {"," $this-\u003eloaders[$format] = $loader;"," }",""," /**"," * Adds a Resource."," *"," * @param string $format The name of the loader (@see addLoader())"," * @param mixed $resource The resource name"," * @param string $locale The locale"," * @param string $domain The domain"," *"," * @throws \\InvalidArgumentException If the locale contains invalid characters"," */"," public function addResource($format, $resource, $locale, $domain = null)"," {"," if (null === $domain) {"," $domain = 'messages';"," }",""," $this-\u003eassertValidLocale($locale);",""," $this-\u003eresources[$locale][] = array($format, $resource, $domain);",""," if (in_array($locale, $this-\u003efallbackLocales)) {"," $this-\u003ecatalogues = array();"," } else {"," unset($this-\u003ecatalogues[$locale]);"," }"," }",""," /**"," * {@inheritdoc}"," */"," public function setLocale($locale)"," {"," $this-\u003eassertValidLocale($locale);"," $this-\u003elocale = $locale;"," }",""," /**"," * {@inheritdoc}"," */"," public function getLocale()"," {"," return $this-\u003elocale;"," }",""," /**"," * Sets the fallback locale(s)."," *"," * @param string|array $locales The fallback locale(s)"," *"," * @throws \\InvalidArgumentException If a locale contains invalid characters"," *"," * @deprecated since version 2.3, to be removed in 3.0. Use setFallbackLocales() instead"," */"," public function setFallbackLocale($locales)"," {"," @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0. Use the setFallbackLocales() method instead.', E_USER_DEPRECATED);",""," $this-\u003esetFallbackLocales(is_array($locales) ? $locales : array($locales));"," }",""," /**"," * Sets the fallback locales."," *"," * @param array $locales The fallback locales"," *"," * @throws \\InvalidArgumentException If a locale contains invalid characters"," */"," public function setFallbackLocales(array $locales)"," {"," // needed as the fallback locales are linked to the already loaded catalogues"," $this-\u003ecatalogues = array();",""," foreach ($locales as $locale) {"," $this-\u003eassertValidLocale($locale);"," }",""," $this-\u003efallbackLocales = $locales;"," }",""," /**"," * Gets the fallback locales."," *"," * @return array $locales The fallback locales"," */"," public function getFallbackLocales()"," {"," return $this-\u003efallbackLocales;"," }",""," /**"," * {@inheritdoc}"," */"," public function trans($id, array $parameters = array(), $domain = null, $locale = null)"," {"," if (null === $domain) {"," $domain = 'messages';"," }",""," return strtr($this-\u003egetCatalogue($locale)-\u003eget((string) $id, $domain), $parameters);"," }",""," /**"," * {@inheritdoc}"," */"," public function transChoice($id, $number, array $parameters = array(), $domain = null, $locale = null)"," {"," if (null === $domain) {"," $domain = 'messages';"," }",""," $id = (string) $id;"," $catalogue = $this-\u003egetCatalogue($locale);"," $locale = $catalogue-\u003egetLocale();"," while (!$catalogue-\u003edefines($id, $domain)) {"," if ($cat = $catalogue-\u003egetFallbackCatalogue()) {"," $catalogue = $cat;"," $locale = $catalogue-\u003egetLocale();"," } else {"," break;"," }"," }",""," return strtr($this-\u003eselector-\u003echoose($catalogue-\u003eget($id, $domain), (int) $number, $locale), $parameters);"," }",""," /**"," * {@inheritdoc}"," */"," public function getCatalogue($locale = null)"," {"," if (null === $locale) {"," $locale = $this-\u003egetLocale();"," } else {"," $this-\u003eassertValidLocale($locale);"," }",""," if (!isset($this-\u003ecatalogues[$locale])) {"," $this-\u003eloadCatalogue($locale);"," }",""," return $this-\u003ecatalogues[$locale];"," }",""," /**"," * Gets the loaders."," *"," * @return array LoaderInterface[]"," */"," protected function getLoaders()"," {"," return $this-\u003eloaders;"," }",""," /**"," * Collects all messages for the given locale."," *"," * @param string|null $locale Locale of translations, by default is current locale"," *"," * @return array[array] indexed by catalog"," */"," public function getMessages($locale = null)"," {"," $catalogue = $this-\u003egetCatalogue($locale);"," $messages = $catalogue-\u003eall();"," while ($catalogue = $catalogue-\u003egetFallbackCatalogue()) {"," $messages = array_replace_recursive($catalogue-\u003eall(), $messages);"," }",""," return $messages;"," }",""," /**"," * @param string $locale"," */"," protected function loadCatalogue($locale)"," {"," if (null === $this-\u003ecacheDir) {"," $this-\u003einitializeCatalogue($locale);"," } else {"," $this-\u003einitializeCacheCatalogue($locale);"," }"," }",""," /**"," * @param string $locale"," */"," protected function initializeCatalogue($locale)"," {"," $this-\u003eassertValidLocale($locale);",""," try {"," $this-\u003edoLoadCatalogue($locale);"," } catch (NotFoundResourceException $e) {"," if (!$this-\u003ecomputeFallbackLocales($locale)) {"," throw $e;"," }"," }"," $this-\u003eloadFallbackCatalogues($locale);"," }",""," /**"," * @param string $locale"," */"," private function initializeCacheCatalogue($locale)"," {"," if (isset($this-\u003ecatalogues[$locale])) {"," /* Catalogue already initialized. */"," return;"," }",""," $this-\u003eassertValidLocale($locale);"," $self = $this; // required for PHP 5.3 where \"$this\" cannot be use()d in anonymous functions. Change in Symfony 3.0."," $cache = $this-\u003egetConfigCacheFactory()-\u003ecache($this-\u003egetCatalogueCachePath($locale),"," function (ConfigCacheInterface $cache) use ($self, $locale) {"," $self-\u003edumpCatalogue($locale, $cache);"," }"," );",""," if (isset($this-\u003ecatalogues[$locale])) {"," /* Catalogue has been initialized as it was written out to cache. */"," return;"," }",""," /* Read catalogue from cache. */"," $this-\u003ecatalogues[$locale] = include $cache-\u003egetPath();"," }",""," /**"," * This method is public because it needs to be callable from a closure in PHP 5.3. It should be made protected (or even private, if possible) in 3.0."," *"," * @internal"," */"," public function dumpCatalogue($locale, ConfigCacheInterface $cache)"," {"," $this-\u003einitializeCatalogue($locale);"," $fallbackContent = $this-\u003egetFallbackContent($this-\u003ecatalogues[$locale]);",""," $content = sprintf(\u003c\u003c\u003cEOF","\u003c?php","","use Symfony\\Component\\Translation\\MessageCatalogue;","","\\$catalogue = new MessageCatalogue('%s', %s);","","%s","return \\$catalogue;","","EOF"," ,"," $locale,"," var_export($this-\u003ecatalogues[$locale]-\u003eall(), true),"," $fallbackContent"," );",""," $cache-\u003ewrite($content, $this-\u003ecatalogues[$locale]-\u003egetResources());"," }",""," private function getFallbackContent(MessageCatalogue $catalogue)"," {"," $fallbackContent = '';"," $current = '';"," $replacementPattern = '/[^a-z0-9_]/i';"," $fallbackCatalogue = $catalogue-\u003egetFallbackCatalogue();"," while ($fallbackCatalogue) {"," $fallback = $fallbackCatalogue-\u003egetLocale();"," $fallbackSuffix = ucfirst(preg_replace($replacementPattern, '_', $fallback));"," $currentSuffix = ucfirst(preg_replace($replacementPattern, '_', $current));",""," $fallbackContent .= sprintf(\u003c\u003c\u003c'EOF'","$catalogue%s = new MessageCatalogue('%s', %s);","$catalogue%s-\u003eaddFallbackCatalogue($catalogue%s);","","EOF"," ,"," $fallbackSuffix,"," $fallback,"," var_export($fallbackCatalogue-\u003eall(), true),"," $currentSuffix,"," $fallbackSuffix"," );"," $current = $fallbackCatalogue-\u003egetLocale();"," $fallbackCatalogue = $fallbackCatalogue-\u003egetFallbackCatalogue();"," }",""," return $fallbackContent;"," }",""," private function getCatalogueCachePath($locale)"," {"," return $this-\u003ecacheDir.'/catalogue.'.$locale.'.'.sha1(serialize($this-\u003efallbackLocales)).'.php';"," }",""," private function doLoadCatalogue($locale)"," {"," $this-\u003ecatalogues[$locale] = new MessageCatalogue($locale);",""," if (isset($this-\u003eresources[$locale])) {"," foreach ($this-\u003eresources[$locale] as $resource) {"," if (!isset($this-\u003eloaders[$resource[0]])) {"," throw new \\RuntimeException(sprintf('The \"%s\" translation loader is not registered.', $resource[0]));"," }"," $this-\u003ecatalogues[$locale]-\u003eaddCatalogue($this-\u003eloaders[$resource[0]]-\u003eload($resource[1], $locale, $resource[2]));"," }"," }"," }",""," private function loadFallbackCatalogues($locale)"," {"," $current = $this-\u003ecatalogues[$locale];",""," foreach ($this-\u003ecomputeFallbackLocales($locale) as $fallback) {"," if (!isset($this-\u003ecatalogues[$fallback])) {"," $this-\u003einitializeCatalogue($fallback);"," }",""," $fallbackCatalogue = new MessageCatalogue($fallback, $this-\u003ecatalogues[$fallback]-\u003eall());"," foreach ($this-\u003ecatalogues[$fallback]-\u003egetResources() as $resource) {"," $fallbackCatalogue-\u003eaddResource($resource);"," }"," $current-\u003eaddFallbackCatalogue($fallbackCatalogue);"," $current = $fallbackCatalogue;"," }"," }",""," protected function computeFallbackLocales($locale)"," {"," $locales = array();"," foreach ($this-\u003efallbackLocales as $fallback) {"," if ($fallback === $locale) {"," continue;"," }",""," $locales[] = $fallback;"," }",""," if (false !== strrchr($locale, '_')) {"," array_unshift($locales, substr($locale, 0, -strlen(strrchr($locale, '_'))));"," }",""," return array_unique($locales);"," }",""," /**"," * Asserts that the locale is valid, throws an Exception if not."," *"," * @param string $locale Locale to tests"," *"," * @throws \\InvalidArgumentException If the locale contains invalid characters"," */"," protected function assertValidLocale($locale)"," {"," if (1 !== preg_match('/^[a-z0-9@_\\\\.\\\\-]*$/i', $locale)) {"," throw new \\InvalidArgumentException(sprintf('Invalid \"%s\" locale.', $locale));"," }"," }",""," /**"," * Provides the ConfigCache factory implementation, falling back to a"," * default implementation if necessary."," *"," * @return ConfigCacheFactoryInterface $configCacheFactory"," */"," private function getConfigCacheFactory()"," {"," if (!$this-\u003econfigCacheFactory) {"," $this-\u003econfigCacheFactory = new ConfigCacheFactory($this-\u003edebug);"," }",""," return $this-\u003econfigCacheFactory;"," }","}"],"stylingDirectives":null,"colorizedLines":null,"csv":null,"csvError":null,"dependabotInfo":{"showConfigurationBanner":false,"configFilePath":null,"networkDependabotPath":"/symfony/symfony/network/updates","dismissConfigurationNoticePath":"/settings/dismiss-notice/dependabot_configuration_notice","configurationNoticeDismissed":null},"displayName":"Translator.php","displayUrl":"https://github.com/symfony/symfony/blob/2.7/src/Symfony/Component/Translation/Translator.php?raw=true","headerInfo":{"blobSize":"13.1 KB","deleteTooltip":"You must be signed in to make or propose changes","editTooltip":"You must be signed in to make or propose changes","ghDesktopPath":"https://desktop.github.com","isGitLfs":false,"onBranch":true,"shortPath":"b06d497","siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Fsymfony%2Fsymfony%2Fblob%2F2.7%2Fsrc%2FSymfony%2FComponent%2FTranslation%2FTranslator.php","isCSV":false,"isRichtext":false,"toc":null,"lineInfo":{"truncatedLoc":"472","truncatedSloc":"403"},"mode":"file"},"image":false,"isCodeownersFile":null,"isPlain":false,"isValidLegacyIssueTemplate":false,"issueTemplate":null,"discussionTemplate":null,"language":"PHP","languageID":272,"large":false,"planSupportInfo":{"repoIsFork":null,"repoOwnedByCurrentUser":null,"requestFullPath":"/symfony/symfony/blob/2.7/src/Symfony/Component/Translation/Translator.php","showFreeOrgGatedFeatureMessage":null,"showPlanSupportBanner":null,"upgradeDataAttributes":null,"upgradePath":null},"publishBannersInfo":{"dismissActionNoticePath":"/settings/dismiss-notice/publish_action_from_dockerfile","releasePath":"/symfony/symfony/releases/new?marketplace=true","showPublishActionBanner":false},"rawBlobUrl":"https://github.com/symfony/symfony/raw/refs/heads/2.7/src/Symfony/Component/Translation/Translator.php","renderImageOrRaw":false,"richText":null,"renderedFileInfo":null,"shortPath":null,"symbolsEnabled":true,"tabSize":8,"topBannersInfo":{"overridingGlobalFundingFile":false,"globalPreferredFundingPath":"/symfony/.github/blob/6f2ca452c856184a28812bb364b4e34ed50309da/FUNDING.yml","showInvalidCitationWarning":false,"citationHelpUrl":"https://docs.github.com/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-citation-files","actionsOnboardingTip":null},"truncated":false,"viewable":true,"workflowRedirectUrl":null,"symbols":{"timed_out":false,"not_analyzed":false,"symbols":[{"name":"Symfony\\Component\\Translation","kind":"module","ident_start":248,"ident_end":277,"extent_start":238,"extent_end":278,"fully_qualified_name":"Symfony\\Component\\Translation","ident_utf16":{"start":{"line_number":11,"utf16_col":10},"end":{"line_number":11,"utf16_col":39}},"extent_utf16":{"start":{"line_number":11,"utf16_col":0},"end":{"line_number":11,"utf16_col":40}}},{"name":"Translator","kind":"class","ident_start":631,"ident_end":641,"extent_start":625,"extent_end":13396,"fully_qualified_name":"Translator","ident_utf16":{"start":{"line_number":22,"utf16_col":6},"end":{"line_number":22,"utf16_col":16}},"extent_utf16":{"start":{"line_number":22,"utf16_col":0},"end":{"line_number":471,"utf16_col":1}}},{"name":"TranslatorInterface","kind":"implementation","ident_start":653,"ident_end":672,"extent_start":642,"extent_end":696,"fully_qualified_name":"Translator.TranslatorInterface","ident_utf16":{"start":{"line_number":22,"utf16_col":28},"end":{"line_number":22,"utf16_col":47}},"extent_utf16":{"start":{"line_number":22,"utf16_col":17},"end":{"line_number":22,"utf16_col":71}}},{"name":"TranslatorBagInterface","kind":"implementation","ident_start":674,"ident_end":696,"extent_start":642,"extent_end":696,"fully_qualified_name":"Translator.TranslatorInterface.TranslatorBagInterface","ident_utf16":{"start":{"line_number":22,"utf16_col":49},"end":{"line_number":22,"utf16_col":71}},"extent_utf16":{"start":{"line_number":22,"utf16_col":17},"end":{"line_number":22,"utf16_col":71}}},{"name":"catalogues","kind":"field","ident_start":770,"ident_end":780,"extent_start":759,"extent_end":791,"fully_qualified_name":"Translator.catalogues","ident_utf16":{"start":{"line_number":27,"utf16_col":15},"end":{"line_number":27,"utf16_col":25}},"extent_utf16":{"start":{"line_number":27,"utf16_col":4},"end":{"line_number":27,"utf16_col":36}}},{"name":"locale","kind":"field","ident_start":843,"ident_end":849,"extent_start":832,"extent_end":850,"fully_qualified_name":"Translator.locale","ident_utf16":{"start":{"line_number":32,"utf16_col":15},"end":{"line_number":32,"utf16_col":21}},"extent_utf16":{"start":{"line_number":32,"utf16_col":4},"end":{"line_number":32,"utf16_col":22}}},{"name":"fallbackLocales","kind":"field","ident_start":899,"ident_end":914,"extent_start":890,"extent_end":925,"fully_qualified_name":"Translator.fallbackLocales","ident_utf16":{"start":{"line_number":37,"utf16_col":13},"end":{"line_number":37,"utf16_col":28}},"extent_utf16":{"start":{"line_number":37,"utf16_col":4},"end":{"line_number":37,"utf16_col":39}}},{"name":"loaders","kind":"field","ident_start":986,"ident_end":993,"extent_start":977,"extent_end":1004,"fully_qualified_name":"Translator.loaders","ident_utf16":{"start":{"line_number":42,"utf16_col":13},"end":{"line_number":42,"utf16_col":20}},"extent_utf16":{"start":{"line_number":42,"utf16_col":4},"end":{"line_number":42,"utf16_col":31}}},{"name":"resources","kind":"field","ident_start":1053,"ident_end":1062,"extent_start":1044,"extent_end":1073,"fully_qualified_name":"Translator.resources","ident_utf16":{"start":{"line_number":47,"utf16_col":13},"end":{"line_number":47,"utf16_col":22}},"extent_utf16":{"start":{"line_number":47,"utf16_col":4},"end":{"line_number":47,"utf16_col":33}}},{"name":"selector","kind":"field","ident_start":1132,"ident_end":1140,"extent_start":1123,"extent_end":1141,"fully_qualified_name":"Translator.selector","ident_utf16":{"start":{"line_number":52,"utf16_col":13},"end":{"line_number":52,"utf16_col":21}},"extent_utf16":{"start":{"line_number":52,"utf16_col":4},"end":{"line_number":52,"utf16_col":22}}},{"name":"cacheDir","kind":"field","ident_start":1191,"ident_end":1199,"extent_start":1182,"extent_end":1200,"fully_qualified_name":"Translator.cacheDir","ident_utf16":{"start":{"line_number":57,"utf16_col":13},"end":{"line_number":57,"utf16_col":21}},"extent_utf16":{"start":{"line_number":57,"utf16_col":4},"end":{"line_number":57,"utf16_col":22}}},{"name":"debug","kind":"field","ident_start":1248,"ident_end":1253,"extent_start":1239,"extent_end":1254,"fully_qualified_name":"Translator.debug","ident_utf16":{"start":{"line_number":62,"utf16_col":13},"end":{"line_number":62,"utf16_col":18}},"extent_utf16":{"start":{"line_number":62,"utf16_col":4},"end":{"line_number":62,"utf16_col":19}}},{"name":"configCacheFactory","kind":"field","ident_start":1330,"ident_end":1348,"extent_start":1321,"extent_end":1349,"fully_qualified_name":"Translator.configCacheFactory","ident_utf16":{"start":{"line_number":67,"utf16_col":13},"end":{"line_number":67,"utf16_col":31}},"extent_utf16":{"start":{"line_number":67,"utf16_col":4},"end":{"line_number":67,"utf16_col":32}}},{"name":"__construct","kind":"method","ident_start":1766,"ident_end":1777,"extent_start":1750,"extent_end":2031,"fully_qualified_name":"Translator.__construct","ident_utf16":{"start":{"line_number":77,"utf16_col":20},"end":{"line_number":77,"utf16_col":31}},"extent_utf16":{"start":{"line_number":77,"utf16_col":4},"end":{"line_number":83,"utf16_col":5}}},{"name":"setConfigCacheFactory","kind":"method","ident_start":2053,"ident_end":2074,"extent_start":2037,"extent_end":2192,"fully_qualified_name":"Translator.setConfigCacheFactory","ident_utf16":{"start":{"line_number":85,"utf16_col":20},"end":{"line_number":85,"utf16_col":41}},"extent_utf16":{"start":{"line_number":85,"utf16_col":4},"end":{"line_number":88,"utf16_col":5}}},{"name":"addLoader","kind":"method","ident_start":2406,"ident_end":2415,"extent_start":2390,"extent_end":2504,"fully_qualified_name":"Translator.addLoader","ident_utf16":{"start":{"line_number":96,"utf16_col":20},"end":{"line_number":96,"utf16_col":29}},"extent_utf16":{"start":{"line_number":96,"utf16_col":4},"end":{"line_number":99,"utf16_col":5}}},{"name":"addResource","kind":"method","ident_start":2869,"ident_end":2880,"extent_start":2853,"extent_end":3305,"fully_qualified_name":"Translator.addResource","ident_utf16":{"start":{"line_number":111,"utf16_col":20},"end":{"line_number":111,"utf16_col":31}},"extent_utf16":{"start":{"line_number":111,"utf16_col":4},"end":{"line_number":126,"utf16_col":5}}},{"name":"setLocale","kind":"method","ident_start":3364,"ident_end":3373,"extent_start":3348,"extent_end":3470,"fully_qualified_name":"Translator.setLocale","ident_utf16":{"start":{"line_number":131,"utf16_col":20},"end":{"line_number":131,"utf16_col":29}},"extent_utf16":{"start":{"line_number":131,"utf16_col":4},"end":{"line_number":135,"utf16_col":5}}},{"name":"getLocale","kind":"method","ident_start":3529,"ident_end":3538,"extent_start":3513,"extent_end":3582," 4A95 fully_qualified_name":"Translator.getLocale","ident_utf16":{"start":{"line_number":140,"utf16_col":20},"end":{"line_number":140,"utf16_col":29}},"extent_utf16":{"start":{"line_number":140,"utf16_col":4},"end":{"line_number":143,"utf16_col":5}}},{"name":"setFallbackLocale","kind":"method","ident_start":3910,"ident_end":3927,"extent_start":3894,"extent_end":4211,"fully_qualified_name":"Translator.setFallbackLocale","ident_utf16":{"start":{"line_number":154,"utf16_col":20},"end":{"line_number":154,"utf16_col":37}},"extent_utf16":{"start":{"line_number":154,"utf16_col":4},"end":{"line_number":159,"utf16_col":5}}},{"name":"setFallbackLocales","kind":"method","ident_start":4428,"ident_end":4446,"extent_start":4412,"extent_end":4739,"fully_qualified_name":"Translator.setFallbackLocales","ident_utf16":{"start":{"line_number":168,"utf16_col":20},"end":{"line_number":168,"utf16_col":38}},"extent_utf16":{"start":{"line_number":168,"utf16_col":4},"end":{"line_number":178,"utf16_col":5}}},{"name":"getFallbackLocales","kind":"method","ident_start":4869,"ident_end":4887,"extent_start":4853,"extent_end":4940,"fully_qualified_name":"Translator.getFallbackLocales","ident_utf16":{"start":{"line_number":185,"utf16_col":20},"end":{"line_number":185,"utf16_col":38}},"extent_utf16":{"start":{"line_number":185,"utf16_col":4},"end":{"line_number":188,"utf16_col":5}}},{"name":"trans","kind":"method","ident_start":4999,"ident_end":5004,"extent_start":4983,"extent_end":5252,"fully_qualified_name":"Translator.trans","ident_utf16":{"start":{"line_number":193,"utf16_col":20},"end":{"line_number":193,"utf16_col":25}},"extent_utf16":{"start":{"line_number":193,"utf16_col":4},"end":{"line_number":200,"utf16_col":5}}},{"name":"transChoice","kind":"method","ident_start":5311,"ident_end":5322,"extent_start":5295,"extent_end":5992,"fully_qualified_name":"Translator.transChoice","ident_utf16":{"start":{"line_number":205,"utf16_col":20},"end":{"line_number":205,"utf16_col":31}},"extent_utf16":{"start":{"line_number":205,"utf16_col":4},"end":{"line_number":224,"utf16_col":5}}},{"name":"getCatalogue","kind":"method","ident_start":6051,"ident_end":6063,"extent_start":6035,"extent_end":6387,"fully_qualified_name":"Translator.getCatalogue","ident_utf16":{"start":{"line_number":229,"utf16_col":20},"end":{"line_number":229,"utf16_col":32}},"extent_utf16":{"start":{"line_number":229,"utf16_col":4},"end":{"line_number":242,"utf16_col":5}}},{"name":"getLoaders","kind":"method","ident_start":6499,"ident_end":6509,"extent_start":6480,"extent_end":6554,"fully_qualified_name":"Translator.getLoaders","ident_utf16":{"start":{"line_number":249,"utf16_col":23},"end":{"line_number":249,"utf16_col":33}},"extent_utf16":{"start":{"line_number":249,"utf16_col":4},"end":{"line_number":252,"utf16_col":5}}},{"name":"getMessages","kind":"method","ident_start":6791,"ident_end":6802,"extent_start":6775,"extent_end":7102,"fully_qualified_name":"Translator.getMessages","ident_utf16":{"start":{"line_number":261,"utf16_col":20},"end":{"line_number":261,"utf16_col":31}},"extent_utf16":{"start":{"line_number":261,"utf16_col":4},"end":{"line_number":270,"utf16_col":5}}},{"name":"loadCatalogue","kind":"method","ident_start":7172,"ident_end":7185,"extent_start":7153,"extent_end":7376,"fully_qualified_name":"Translator.loadCatalogue","ident_utf16":{"start":{"line_number":275,"utf16_col":23},"end":{"line_number":275,"utf16_col":36}},"extent_utf16":{"start":{"line_number":275,"utf16_col":4},"end":{"line_number":282,"utf16_col":5}}},{"name":"initializeCatalogue","kind":"method","ident_start":7446,"ident_end":7465,"extent_start":7427,"extent_end":7795,"fully_qualified_name":"Translator.initializeCatalogue","ident_utf16":{"start":{"line_number":287,"utf16_col":23},"end":{"line_number":287,"utf16_col":42}},"extent_utf16":{"start":{"line_number":287,"utf16_col":4},"end":{"line_number":299,"utf16_col":5}}},{"name":"initializeCacheCatalogue","kind":"method","ident_start":7863,"ident_end":7887,"extent_start":7846,"extent_end":8720,"fully_qualified_name":"Translator.initializeCacheCatalogue","ident_utf16":{"start":{"line_number":304,"utf16_col":21},"end":{"line_number":304,"utf16_col":45}},"extent_utf16":{"start":{"line_number":304,"utf16_col":4},"end":{"line_number":326,"utf16_col":5}}},{"name":"dumpCatalogue","kind":"method","ident_start":8937,"ident_end":8950,"extent_start":8921,"extent_end":9515,"fully_qualified_name":"Translator.dumpCatalogue","ident_utf16":{"start":{"line_number":333,"utf16_col":20},"end":{"line_number":333,"utf16_col":33}},"extent_utf16":{"start":{"line_number":333,"utf16_col":4},"end":{"line_number":356,"utf16_col":5}}},{"name":"getFallbackContent","kind":"method","ident_start":9538,"ident_end":9556,"extent_start":9521,"extent_end":10582,"fully_qualified_name":"Translator.getFallbackContent","ident_utf16":{"start":{"line_number":358,"utf16_col":21},"end":{"line_number":358,"utf16_col":39}},"extent_utf16":{"start":{"line_number":358,"utf16_col":4},"end":{"line_number":386,"utf16_col":5}}},{"name":"getCatalogueCachePath","kind":"method","ident_start":10605,"ident_end":10626,"extent_start":10588,"extent_end":10752,"fully_qualified_name":"Translator.getCatalogueCachePath","ident_utf16":{"start":{"line_number":388,"utf16_col":21},"end":{"line_number":388,"utf16_col":42}},"extent_utf16":{"start":{"line_number":388,"utf16_col":4},"end":{"line_number":391,"utf16_col":5}}},{"name":"doLoadCatalogue","kind":"method","ident_start":10775,"ident_end":10790,"extent_start":10758,"extent_end":11346,"fully_qualified_name":"Translator.doLoadCatalogue","ident_utf16":{"start":{"line_number":393,"utf16_col":21},"end":{"line_number":393,"utf16_col":36}},"extent_utf16":{"start":{"line_number":393,"utf16_col":4},"end":{"line_number":405,"utf16_col":5}}},{"name":"loadFallbackCatalogues","kind":"method","ident_start":11369,"ident_end":11391,"extent_start":11352,"extent_end":12034,"fully_qualified_name":"Translator.loadFallbackCatalogues","ident_utf16":{"start":{"line_number":407,"utf16_col":21},"end":{"line_number":407,"utf16_col":43}},"extent_utf16":{"start":{"line_number":407,"utf16_col":4},"end":{"line_number":423,"utf16_col":5}}},{"name":"computeFallbackLocales","kind":"method","ident_start":12059,"ident_end":12081,"extent_start":12040,"extent_end":12501,"fully_qualified_name":"Translator.computeFallbackLocales","ident_utf16":{"start":{"line_number":425,"utf16_col":23},"end":{"line_number":425,"utf16_col":45}},"extent_utf16":{"start":{"line_number":425,"utf16_col":4},"end":{"line_number":441,"utf16_col":5}}},{"name":"assertValidLocale","kind":"method","ident_start":12753,"ident_end":12770,"extent_start":12734,"extent_end":12959,"fully_qualified_name":"Translator.assertValidLocale","ident_utf16":{"start":{"line_number":450,"utf16_col":23},"end":{"line_number":450,"utf16_col":40}},"extent_utf16":{"start":{"line_number":450,"utf16_col":4},"end":{"line_number":455,"utf16_col":5}}},{"name":"getConfigCacheFactory","kind":"method","ident_start":13186,"ident_end":13207,"extent_start":13169,"extent_end":13394,"fully_qualified_name":"Translator.getConfigCacheFactory","ident_utf16":{"start":{"line_number":463,"utf16_col":21},"end":{"line_number":463,"utf16_col":42}},"extent_utf16":{"start":{"line_number":463,"utf16_col":4},"end":{"line_number":470,"utf16_col":5}}}]}},"copilotInfo":null,"copilotAccessAllowed":false,"modelsAccessAllowed":false,"modelsRepoIntegrationEnabled":false,"csrf_tokens":{"/symfony/symfony/branches":{"post":"pMrGYsMEJi1lZHBeJY6M9pST707fegSEcWpSk0gqgh3OcLV1YMbAIfl71Yjc-xPKw5GPJgnvOnjoXto7XaPRTg"},"/repos/preferences":{"post":"9eNkcUnkRiWppr6gnZknobtEvA8bf5TNqcH9rjI9Mcwm8WGRCRpEbLouIWKAmzTkHzmxl762kuGsxqBmC_TytQ"}}},"title":"symfony/src/Symfony/Component/Translation/Translator.php at 2.7 · symfony/symfony","appPayload":{"helpUrl":"https://docs.github.com","findFileWorkerPath":"/assets-cdn/worker/find-file-worker-7d7eb7c71814.js","findInFileWorkerPath":"/assets-cdn/worker/find-in-file-worker-f84d09b5f529.js","githubDevUrl":null,"enabled_features":{"code_nav_ui_events":false,"react_blob_overlay":false,"accessible_code_button":true,"github_models_repo_integration":false}}}
0