summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/language/language.module
diff options
context:
space:
mode:
authorNathaniel Catchpole <catch@35733.no-reply.drupal.org>2015-07-24 12:21:01 +0100
committerNathaniel Catchpole <catch@35733.no-reply.drupal.org>2015-07-24 12:21:01 +0100
commitfe4cd2cf01ab9d8d4e384d514008b12757fa4d66 (patch)
treecd2afb64e8929f284ab2133b2502d66adc29d7dd /core/modules/language/language.module
parentf678e370ff269267d3eca2d9307b46d2d41db7ee (diff)
downloaddrupal-fe4cd2cf01ab9d8d4e384d514008b12757fa4d66.tar.gz
drupal-fe4cd2cf01ab9d8d4e384d514008b12757fa4d66.zip
Issue #2497275 by borisson_, alexpott: ~50 calls to t() for two strings in LanguageManager() on every request
Diffstat (limited to 'core/modules/language/language.module')
-rw-r--r--core/modules/language/language.module49
1 files changed, 13 insertions, 36 deletions
diff --git a/core/modules/language/language.module b/core/modules/language/language.module
index 342e7302d8a..29c93d2cf9e 100644
--- a/core/modules/language/language.module
+++ b/core/modules/language/language.module
@@ -283,42 +283,6 @@ function language_get_default_langcode($entity_type, $bundle) {
}
/**
- * Implements hook_language_types_info().
- *
- * Defines the three core language types:
- * - Interface language is the only configurable language type in core. It is
- * used by t() as the default language if none is specified.
- * - Content language is by default non-configurable and inherits the interface
- * language negotiated value. It is used by the Field API to determine the
- * display language for fields if no explicit value is specified.
- * - URL language is by default non-configurable and is determined through the
- * URL language negotiation method or the URL fallback language negotiation
- * method if no language can be detected. It is used by l() as the default
- * language if none is specified.
- */
-function language_language_types_info() {
- return array(
- LanguageInterface::TYPE_INTERFACE => array(
- 'name' => t('Interface text'),
- 'description' => t('Order of language detection methods for interface text. If a translation of interface text is available in the detected language, it will be displayed.'),
- 'locked' => TRUE,
- ),
- LanguageInterface::TYPE_CONTENT => array(
- 'name' => t('Content'),
- 'description' => t('Order of language detection methods for content. If a version of content is available in the detected language, it will be displayed.'),
- 'fixed' => array(LanguageNegotiationUI::METHOD_ID),
- 'locked' => TRUE,
- ),
- LanguageInterface::TYPE_URL => array(
- 'name' => t('URL'),
- 'description' => t('Order of language detection methods for URLs. The detected language will be used as the default when generating URLs for internal links on the site.'),
- 'fixed' => array(LanguageNegotiationUrl::METHOD_ID, LanguageNegotiationUrlFallback::METHOD_ID),
- 'locked' => TRUE,
- ),
- );
-}
-
-/**
* Reads language prefixes and uses the langcode if no prefix is set.
*/
function language_negotiation_url_prefixes() {
@@ -540,3 +504,16 @@ function language_tour_tips_alter(array &$tour_tips, EntityInterface $entity) {
}
}
}
+
+/**
+ * Implements hook_language_types_info_alter().
+ *
+ * We can't set the fixed properties in \Drupal\Core\Language\LanguageManager,
+ * where the rest of the properties for the default language types are defined.
+ * The LanguageNegation classes are only loaded when the language module is
+ * enabled and we can't be sure of that in the LanguageManager.
+ */
+function language_language_types_info_alter(array &$language_types) {
+ $language_types[LanguageInterface::TYPE_CONTENT]['fixed'] = [LanguageNegotiationUI::METHOD_ID];
+ $language_types[LanguageInterface::TYPE_URL]['fixed'] = [LanguageNegotiationUrl::METHOD_ID, LanguageNegotiationUrlFallback::METHOD_ID];
+}