From e8df1cd6911b8f5a75e67a731fcb44b36581b8b4 Mon Sep 17 00:00:00 2001
From: Angie Byron <webchick@24967.no-reply.drupal.org>
Date: Wed, 28 Apr 2010 05:12:43 +0000
Subject: [PATCH] #654726 by bdurbin, sun, plach, et al: Fixed Installing
 Drupal 7 in non-English language doesn't pick up st() installation lists.

---
 includes/install.inc       |  8 ++++++--
 modules/locale/locale.test | 38 ++++++++++++++++++++++++++++++++++----
 2 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/includes/install.inc b/includes/install.inc
index 11b1a35c2b9b..23a7137b8367 100644
--- a/includes/install.inc
+++ b/includes/install.inc
@@ -849,10 +849,14 @@ function install_goto($path) {
  * @see t()
  * @ingroup sanitization
  */
-function st($string, $args = array()) {
+function st($string, array $args = array(), array $options = array()) {
   static $locale_strings = NULL;
   global $install_state;
 
+  if (empty($options['context'])) {
+    $options['context'] = '';
+  }
+
   if (!isset($locale_strings)) {
     $locale_strings = array();
     if (isset($install_state['parameters']['profile']) && isset($install_state['parameters']['locale'])) {
@@ -883,7 +887,7 @@ function st($string, $args = array()) {
       case '!':
     }
   }
-  return strtr((!empty($locale_strings[$string]) ? $locale_strings[$string] : $string), $args);
+  return strtr((!empty($locale_strings[$options['context']][$string]) ? $locale_strings[$options['context']][$string] : $string), $args);
 }
 
 /**
diff --git a/modules/locale/locale.test b/modules/locale/locale.test
index a2add4610424..6f82b9e3e61d 100644
--- a/modules/locale/locale.test
+++ b/modules/locale/locale.test
@@ -957,6 +957,35 @@ EOF;
 
 }
 
+/**
+ * Tests for the st() function.
+ */
+class LocaleInstallTest extends DrupalWebTestCase {
+  public static function getInfo() {
+    return array(
+      'name' => 'String translation using st()',
+      'description' => 'Tests that st() works like t().',
+      'group' => 'Locale',
+    );
+  }
+
+  function setUp() {
+    parent::setUp('locale');
+
+    // st() lives in install.inc, so ensure that it is loaded for all tests.
+    require_once DRUPAL_ROOT . '/includes/install.inc';
+  }
+
+  /**
+   * Verify that function signatures of t() and st() are equal.
+   */
+  function testFunctionSignatures() {
+    $reflector_t = new ReflectionFunction('t');
+    $reflector_st = new ReflectionFunction('st');
+    $this->assertEqual($reflector_t->getParameters(), $reflector_st->getParameters(), t('Function signatures of t() and st() are equal.'));
+  }
+}
+
 /**
  * Locale uninstall with English UI functional test.
  */
@@ -1106,7 +1135,7 @@ class LocaleUninstallFrenchFunctionalTest extends LocaleUninstallFunctionalTest
 /**
  * Functional tests for the language switching feature.
  */
-class LanguageSwitchingFunctionalTest extends DrupalWebTestCase {
+class LocaleLanguageSwitchingFunctionalTest extends DrupalWebTestCase {
 
   public static function getInfo() {
     return array(
@@ -1280,7 +1309,7 @@ class LocaleUserLanguageFunctionalTest extends DrupalWebTestCase {
 /**
  * Functional test for language handling during user creation.
  */
-class LocalUserCreationTest extends DrupalWebTestCase {
+class LocaleUserCreationTest extends DrupalWebTestCase {
 
   public static function getInfo() {
     return array(
@@ -1606,7 +1635,7 @@ class LocaleContentFunctionalTest extends DrupalWebTestCase {
  *        http://example.cn/admin/config
  *          UI language in Chinese
  */
-class UILanguageNegotiationTest extends DrupalWebTestCase {
+class LocaleUILanguageNegotiationTest extends DrupalWebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'UI language negotiation',
@@ -1904,7 +1933,7 @@ class LocaleMultilingualFieldsFunctionalTest extends DrupalWebTestCase {
 /**
  * Functional tests for localizing date formats.
  */
-class LocalizeDateFormatsFunctionalTest extends DrupalWebTestCase {
+class LocaleDateFormatsFunctionalTest extends DrupalWebTestCase {
 
   public static function getInfo() {
     return array(
@@ -1969,3 +1998,4 @@ class LocalizeDateFormatsFunctionalTest extends DrupalWebTestCase {
     $this->assertText($french_date, t('French date format appears'));
   }
 }
+
-- 
GitLab