Changeset 1591


Ignore:
Timestamp:
1/19/2010 2:49:02 AM (5 years ago)
Author:
lowjoel
Message:

Fixed CA1704 : Microsoft.Naming : In method 'S._(string)', correct the spelling of 'str' in parameter name 'str' or remove it entirely if it represents any sort of Hungarian notation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/CodeReview/Eraser.Util/Localisation.cs

    r1485 r1591  
    4545        /// <param name="str">The string to localise.</param> 
    4646        /// <returns>A localised string, or str if no localisation exists.</returns> 
    47         public static string _(string str) 
    48         { 
    49             return TranslateText(str, Assembly.GetCallingAssembly()); 
    50         } 
    51  
    52         /// <summary> 
    53         /// Translates the localisable string to the localised string, formatting all 
     47        public static string _(string text) 
     48        { 
     49            return TranslateText(text, Assembly.GetCallingAssembly()); 
     50        } 
     51 
     52        /// <summary> 
     53        /// Translates the localisable text to the localised text, formatting all 
    5454        /// placeholders using composite formatting. This is shorthand for 
    55         /// <code>string.Format(S._(str), args)</code> 
    56         /// </summary> 
    57         /// <param name="str">The string to localise.</param> 
     55        /// <code>string.Format(S._(text), args)</code> 
     56        /// </summary> 
     57        /// <param name="text">The text to localise.</param> 
    5858        /// <param name="args">Arguments for the composite formatting call.</param> 
    5959        /// <returns>The formatted and localised string.</returns> 
    6060        /// <remarks>The localised string is retrieved before formatting.</remarks> 
    61         public static string _(string str, params object[] args) 
     61        public static string _(string text, params object[] args) 
    6262        { 
    6363            //Get the localised version of the input string. 
    64             string localStr = TranslateText(str, Assembly.GetCallingAssembly()); 
     64            string localStr = TranslateText(text, Assembly.GetCallingAssembly()); 
    6565 
    6666            //Format the string. 
     
    7676        { 
    7777            if (control == null) 
    78                 return CultureInfo.CurrentCulture.TextInfo.IsRightToLeft; 
     78                throw new ArgumentNullException("control"); 
    7979 
    8080            switch (control.RightToLeft) 
     
    9292        /// Translates the localisable string to the set localised string. 
    9393        /// </summary> 
    94         /// <param name="str">The string to localise.</param> 
     94        /// <param name="text">The string to localise.</param> 
    9595        /// <param name="assembly">The assembly from which localised resource satellite 
    9696        /// assemblies should be loaded from.</param> 
    9797        /// <returns>A localised string, or str if no localisation exists.</returns> 
    98         public static string TranslateText(string str, Assembly assembly) 
     98        public static string TranslateText(string text, Assembly assembly) 
    9999        { 
    100100            //If the string is empty, forget it! 
    101             if (str.Length == 0) 
    102                 return str; 
     101            if (text.Length == 0) 
     102                return text; 
    103103 
    104104            //First get the dictionary mapping assemblies and ResourceManagers (i.e. pick out 
     
    132132                res = assemblies[assembly]; 
    133133 
    134             string result = res.GetString(Escape(str), Thread.CurrentThread.CurrentUICulture); 
     134            string result = res.GetString(Escape(text), Thread.CurrentThread.CurrentUICulture); 
    135135#if DEBUG 
    136             return string.IsNullOrEmpty(result) ? str : Unescape(result); 
     136            return string.IsNullOrEmpty(result) ? text : Unescape(result); 
    137137#else 
    138             return string.IsNullOrEmpty(result) || result == "(Untranslated)" ? str : Unescape(result); 
     138            return string.IsNullOrEmpty(result) || result == "(Untranslated)" ? text : Unescape(result); 
    139139#endif 
    140140        } 
Note: See TracChangeset for help on using the changeset viewer.