Move to resource - ArgumentNullException

Hi,

Move to resources shows an action and a warning that "throw new ArgumentNullException("myProperty")" can be localized.
I assume this doesn't make any sense for this case since the method property is never localized.

In general I would be happy if there is an option where I can define that System Exceptions (Namspace System) are excluded from the validation since we never translate them in our case .

Also Log4net is something we never translate. So it would be helpfull if there is a mecanisme like Annotations (base on attributes or xml) can define rules to exlude things from localization.

I know that a method itself can be excluded from the validation but if I add a new string I would not be warned , would I?

Regards
Martyn

7 comments

We will use our external annotations with the LocalizableAttribute for this cases.


R# will provide annotations for .NET Framework assemblies, but you could provide annotations for other assemblies.
0

Any chance to get an example for the external annotation.. I'm not so familiar with the xml. Especialy I would like to know how to declare correctly the LocaizationAttribute(false).
Is this example correct?

  <member name="M:System.ArgumentException(System.String)">
     <attribute ctor="M:System.ComponentModel.LocalizableAttribute.#ctor(System.Boolean)">
     <argument>false</argument>
     </attribute>
  </member>


BTW: Is this file also located in the user settings somewhere since it is not that easy to extend it in Vista.

0

1. Please download last nightly build and looking for file mscorlib.I18n.xml at the folder %ProgrammFiles%\JetBrains\ReSharper\v5.0\Bin\ExternalAnnotations\mscorlib
2. You should use JetBrains.Annotations.LocalizableAttribute instead of System.ComponentModel.LocalizableAttribute in the external annotations.

0

This annotation from mscorlib.18n.xml for the System.ArgumentException

  <member name="M:System.ArgumentException.#ctor(System.String,System.String)">
    <parameter name="message">
      <attribute ctor="M:JetBrains.Annotations.LocalizableAttribute.#ctor(System.Boolean)">
        <argument>true</argument>
      </attribute>
    </parameter>
    <parameter name="paramName">
      <attribute ctor="M:JetBrains.Annotations.LocalizableAttribute.#ctor(System.Boolean)">
        <argument>false</argument>
      </attribute>
    </parameter>
  </member>

0

I assume there is no way to have a Annotation to exlude this construct?

throw new ArgumentException(string.Format("Profile {0} not found", profileName));

0

The next expression is value for the parameter message, and IMHO it will be translated.

string.Format("Profile {0} not found", profileName)
0

I just found another issue.

Resharper also shows issues for strings like "{0} \ -1" or "^" or " ". But there is no reason to localize a string like this.

I would suggest a new option for the localization feature.

The developer could specify an regular expression to define text which shouldn't be localized.
Default: "[^A-za-z]"
Remove all matches from the string and if there is any char left, then the string must be localized

or a regex for strings which should be localized. If the regex matches, then the string should be localized. But i think this is not so usefull.
Default would then be: "[A-za-z]"

also a new option in the alt+enter would make sense: (I assume this takes longer to actualize)
add string to "localize ignore list".

Just some ideas.

Regards
Martyn

0

Please sign in to leave a comment.