[Mono-bugs] [Bug 65672][Wis] New - CurrentCulture problem reading from resx file through ResourceManager
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Fri, 10 Sep 2004 06:27:34 -0400 (EDT)
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by barbara@idealnet.com.
http://bugzilla.ximian.com/show_bug.cgi?id=65672
--- shadow/65672 2004-09-10 06:27:34.000000000 -0400
+++ shadow/65672.tmp.6777 2004-09-10 06:27:34.000000000 -0400
@@ -0,0 +1,149 @@
+Bug#: 65672
+Product: Mono: Runtime
+Version: unspecified
+OS: Red Hat 9.0
+OS Details: Red Hat 9 with Mono 1.0
+Status: NEW
+Resolution:
+Severity: Unknown
+Priority: Wishlist
+Component: misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: barbara@idealnet.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: CurrentCulture problem reading from resx file through ResourceManager
+
+Description of Problem:
+Having an Asp.Net application running on Red Hat/Apache/Mono where the
+user has to logg in and then the next page displays the information
+depending on the language of the user. I set the CurrentCulture at the
+login and read the language-dependent strings from the corresponding resx
+file. Eg. when user with culture de-DE -> read from dictionary.de-
+DE.resx, culture it-IT -> read from dictionary.it-IT.resx.
+
+I do it with the System.Resources.ResourceManager
+
+The strange thing is, that - after starting mod_mono -, when I go to the
+page and connect as User X it works and reads from the corresponding resx
+file. But, when I try to connect as another user with different culture -
+all empty strings - it is not read. Trying again to logg in as the first
+user who logged in to the system after starting it, it works again.
+
+So: after starting mod_mono/apache, reading from the language dependend
+resx files works only for the culture of the 1st user who is logging in..
+has it something to do with the session? Strange is, that is works on
+Windows/IIS, where the right language depending on the user settings is
+displayed.
+
+Steps to reproduce the problem:
+1. start mod_mono and point to log in page
+2. log in as user X, lets say culture de-DE
+3. ok, information on next page is displayed in german
+4. logg out, logg in as user Y, culture en-US
+5. EMPTY strings are displayed, where english one should be
+6. logg out, try user Z, culture it-IT
+7. also EMPTY strings are displayed
+8. try again as user X, ok german strings are displayed correctly
+9. shutdown mod_mono + apache
+10. start again
+11. logg in as user Z with culture it-IT
+12. Italian strings are displayed!!!
+13. trying as user X and Y -- empty strings
+
+Actual Results:
+only the string of the culture of the first user to connect to the system
+are displayed
+
+Expected Results:
+should read each time from resx file depending on user's culture
+
+How often does this happen?
+each time
+
+
+Additional Information:
+I access the resource manager so:
+lblTest.Text = ship.BusinessTier.Config.getConfig().getString("test");
+
+// class where resource manager is instantiated
+// CLASS FOR SETTING CONFIG FOR EACH USER / when user logs in I call
+initConfig()
+using System;
+using System.Globalization;
+using System.Resources;
+
+namespace ship.BusinessTier
+{
+ /// <summary>
+ /// Summary description for Config.
+ /// </summary>
+ public class Config
+ {
+ private static Config currentConfig;
+ private System.Resources.ResourceManager pResourceManager;
+ private System.Globalization.CultureInfo pCurrentCulture;
+
+ //private constructor
+ private Config(string culture)
+ {
+ try
+ {
+ System.Reflection.Assembly assembly =
+System.Reflection.Assembly.Load("ship.PresentationTier");
+ pResourceManager = new
+System.Resources.ResourceManager
+("ship.PresentationTier.resources.dictionary", assembly);
+
+ pCurrentCulture = new
+System.Globalization.CultureInfo(culture);
+ }
+ catch (Exception configEx) {
+ ship.Log.LogFile log = new
+ship.Log.LogFile();
+ log.Write(configEx.Message,
+configEx.StackTrace);
+ }
+ }
+
+ /// <summary>
+ /// Returns the value of the current culture in the resx
+file
+ /// </summary>
+ /// <param name="key"></param>
+ /// <returns></returns>
+ public string getString(string key) {
+ try
+ {
+ return pResourceManager.GetString(key,
+pCurrentCulture);}
+ catch (Exception getStringFromResourceEx)
+ {
+ ship.Log.LogFile log = new
+ship.Log.LogFile();
+ log.Write
+(getStringFromResourceEx.Message, getStringFromResourceEx.StackTrace);
+ return "ERROR reading from Resource";
+ }
+ }
+
+ public static void initConfig(string culture) {
+ currentConfig = new Config(culture);
+ }
+
+ public static Config getConfig() {
+ return currentConfig;
+ }
+
+ #region property CurrentCulture
+ public CultureInfo CurrCulture
+ {
+ get { return pCurrentCulture; }
+ set { pCurrentCulture = value; }
+ }
+ #endregion
+
+ }
+}