Click here to Skip to main content
15,896,207 members
Articles / Web Development / ASP.NET

Useful ReSharper plugin for localization

Rate me:
Please Sign up or sign in to vote.
4.94/5 (21 votes)
26 Apr 2007CPOL2 min read 209.1K   375   72   107
This ReSharper plugin contains features that helps you for localization

Image 2

Introduction

This article describes plugin functions.

DT ReSharper Plugin roadmap

Image 3 is available in the latest version
Image 4 is partly available

  • Context actions
    • Image 5 Move strings to resource
    • Image 6 Replace string by property
    • Image 7 Use System.String.Empty instead of ""
    • Image 8 Use System.Environment.NewLine instead of "\r\n"
  • Highlighting
    • Image 9 String literal is invalid
    • Image 10 String could be moved to resource
    • Image 11 String present in a resource
  • Refactoring
    • Image 12 Move strings to resource
    • Image 13 Move all strings from file(s) to resource
    • Move all strings from folder(s) to resource
    • Move all strings from project(s) to resource
    • Move all strings from solution to resource

Context actions

Move strings to resource

Move strings to resource by context action.

Image 14

Replace string by property

If a string exists in project resource files, then use "Replace string by property" context action.

Image 15

Use System.String.Empty instead of ""

For empty strings use System.String.Empty.

Image 16

Use System.Environment.NewLine instead of "\r\n"

For string that contains \r and \n, use System.Environment.NewLine.

Image 17

Highlighting

String literal is invalid

In the ReSharper -> Options you can set "Localization -> String literal is invalid" to "Show as error".

Image 18

An unrecognized escape sequence marked by red wave.

Image 19

String could be moved to resource

In the ReSharper -> Options you can set "Localization -> String literal could be moved to resource" to "Show as warning".

Image 20

All strings underlined by wavy line.

Image 21

Refactoring

Move strings to resource

You can move strings to resource by context action or main menu item.

Image 22

First, you select the resource file and string name.

Image 23

If the checkbox "Apply for all same strings in project {CurrentProjectName}" is true, then you can see all the same strings in this project.

Image 24

Image 25 Current string does not present in this list.

String placed to resource file after action.

Image 26

and string literal replaced by property.

Image 27

If checkbox "Keep modified files open" is true, then you can undo this action.

History

All changes

Visit DT ReSharper plugin homepage.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Belarus Belarus
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralRe: Source Please Pin
hatton2-May-07 3:21
hatton2-May-07 3:21 
QuestionWhat do you think about this plugin? Pin
Alexander Nesterenko28-Apr-07 0:02
Alexander Nesterenko28-Apr-07 0:02 
AnswerRe: What do you think about this plugin? Pin
Chris Maunder29-Apr-07 8:01
cofounderChris Maunder29-Apr-07 8:01 
AnswerRe: What do you think about this plugin? Pin
sting013-May-07 2:47
sting013-May-07 2:47 
QuestionWorks with ReSharper 3.0, too? Pin
Uwe Keim27-Apr-07 21:40
sitebuilderUwe Keim27-Apr-07 21:40 
AnswerRe: Works with ReSharper 3.0, too? Pin
Alexander Nesterenko27-Apr-07 23:52
Alexander Nesterenko27-Apr-07 23:52 
GeneralRe: Works with ReSharper 3.0, too? Pin
Uwe Keim27-Apr-07 23:56
sitebuilderUwe Keim27-Apr-07 23:56 
GeneralGreat plugin ... Pin
sting0127-Apr-07 1:01
sting0127-Apr-07 1:01 
But doesn't work on my box (VS2005, XPSP2, resharper 2.5.376.1)
Generates errors every few seconds.Frown | :(
This is the first:

JetBrains.ReSharper.Util.InternalErrorException: Value does not fall within the expected range.
An exception has occurred during execution of a pending action, originating stack trace
at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
at System.Environment.get_StackTrace()
at JetBrains.ReSharper.Util.Alarm.<>c__DisplayClass2.<addrequest>b__0() in c:\Agent\work\Server\ReSharper2.5\src\Shell\src\Alarm.cs:line 101
at JetBrains.ReSharper.Util.Alarm.OnTimer(Object sender, EventArgs e) in c:\Agent\work\Server\ReSharper2.5\src\Shell\src\Alarm.cs:line 177
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
---> System.ArgumentException: Value does not fall within the expected range.
at EnvDTE.Properties.Item(Object index)
at DT.ReSharperPlugin.Common.CustomToolProperty.GetByProjectFile(IProjectFile projectFile) in D:\MyWork\DT_Projects\DT.ReSharperPlugin\2.5.2\DT.ReSharperPlugin\Common\CustomToolProperty.cs:line 53
at DT.ReSharperPlugin.Visitors.ResxFilesSearcher.VisitProjectFile(IProjectFile projectFile) in D:\MyWork\DT_Projects\DT.ReSharperPlugin\2.5.2\DT.ReSharperPlugin\Visitors\ResxFilesSearcher.cs:line 94
at JetBrains.ReSharper.ProjectModel.Impl.ProjectFileImpl.Accept(ProjectVisitor projectVisitor) in c:\Agent\work\Server\ReSharper2.5\src\ProjectModel\src\impl\ProjectFileImpl.cs:line 128
at JetBrains.ReSharper.ProjectModel.RecursiveProjectVisitor.VisitProjectItem(IProjectItem projectItem) in c:\Agent\work\Server\ReSharper2.5\src\ProjectModel\src\ProjectVisitor.cs:line 77
at JetBrains.ReSharper.ProjectModel.ProjectVisitor.VisitProjectFolder(IProjectFolder projectFolder) in c:\Agent\work\Server\ReSharper2.5\src\ProjectModel\src\ProjectVisitor.cs:line 26
at JetBrains.ReSharper.ProjectModel.Impl.ProjectFolderImpl.Accept(ProjectVisitor projectVisitor) in c:\Agent\work\Server\ReSharper2.5\src\ProjectModel\src\impl\ProjectFolderImpl.cs:line 337
at JetBrains.ReSharper.ProjectModel.RecursiveProjectVisitor.VisitProjectItem(IProjectItem projectItem) in c:\Agent\work\Server\ReSharper2.5\src\ProjectModel\src\ProjectVisitor.cs:line 77
at JetBrains.ReSharper.ProjectModel.ProjectVisitor.VisitProjectFolder(IProjectFolder projectFolder) in c:\Agent\work\Server\ReSharper2.5\src\ProjectModel\src\ProjectVisitor.cs:line 26
at JetBrains.ReSharper.ProjectModel.Impl.ProjectFolderImpl.Accept(ProjectVisitor projectVisitor) in c:\Agent\work\Server\ReSharper2.5\src\ProjectModel\src\impl\ProjectFolderImpl.cs:line 337
at JetBrains.ReSharper.ProjectModel.RecursiveProjectVisitor.VisitProjectItem(IProjectItem projectItem) in c:\Agent\work\Server\ReSharper2.5\src\ProjectModel\src\ProjectVisitor.cs:line 77
at JetBrains.ReSharper.ProjectModel.RecursiveProjectVisitor.VisitProject(IProject project) in c:\Agent\work\Server\ReSharper2.5\src\ProjectModel\src\ProjectVisitor.cs:line 82
at JetBrains.ReSharper.ProjectModel.Impl.ProjectImpl.Accept(ProjectVisitor projectVisitor) in c:\Agent\work\Server\ReSharper2.5\src\ProjectModel\src\impl\ProjectImpl.cs:line 169
at DT.ReSharperPlugin.Visitors.ResxFilesSearcher.FindAll(IProject project) in D:\MyWork\DT_Projects\DT.ReSharperPlugin\2.5.2\DT.ReSharperPlugin\Visitors\ResxFilesSearcher.cs:line 67
at DT.ReSharperPlugin.Utils.ResxFileUtil.FindAllResxFiles(IProject project) in D:\MyWork\DT_Projects\DT.ReSharperPlugin\2.5.2\DT.ReSharperPlugin\Utils\ResxFileUtil.cs:line 112
at DT.ReSharperPlugin.ContextActions.ContextActionsDataBuilder.FindResxFiles(ISolution solution, ITextControl textControl, IUserDataHolder cache) in D:\MyWork\DT_Projects\DT.ReSharperPlugin\2.5.2\DT.ReSharperPlugin\ContextActions\ContextActionsDataBuilder.cs:line 35
at DT.ReSharperPlugin.ContextActions.ContextActionsDataBuilder.Build(ISolution solution, ITextControl textControl, IUserDataHolder cache) in D:\MyWork\DT_Projects\DT.ReSharperPlugin\2.5.2\DT.ReSharperPlugin\ContextActions\ContextActionsDataBuilder.cs:line 21
at JetBrains.ReSharper.Daemon.Impl.ContextActionTableImpl.BuildCacheData(ISolution solution, ITextControl control, IUserDataHolder cache) in c:\Agent\work\Server\ReSharper2.5\src\Daemon\src\Impl\ContextActionTableImpl.cs:line 83
at JetBrains.ReSharper.Daemon.Impl.BulbManagerImpl.AsyncBuildAvailableActionsList(Boolean canShowPopup, Boolean canShowQuickFixes, ITextControl textControl, Boolean async, Int32 interruptTimeStamp, Action afterListShown) in c:\Agent\work\Server\ReSharper2.5\src\Daemon\src\Impl\BulbManagerImpl.cs:line 223
at JetBrains.ReSharper.Daemon.Impl.BulbManagerImpl.<>c__DisplayClass1.<jetbrains.resharper.codeinsight.services.iasynccommitclient.beforecommit>b__0() in c:\Agent\work\Server\ReSharper2.5\src\Daemon\src\Impl\BulbManagerImpl.cs:line 157
at JetBrains.ReSharper.Psi.Impl.AsyncCommitServiceImpl.Commiter.<>c__DisplayClass4.<docommit>b__3() in c:\Agent\work\Server\ReSharper2.5\src\Psi\src\impl\AsyncCommitServiceImpl.cs:line 139
at JetBrains.ReSharper.Psi.Impl.PsiManagerImpl.PsiManagerImpl.AsyncCommitAllDocuments(CheckForInterrupt checkForInterrupt, Action continuation, Action ifInterrupted) in c:\Agent\work\Server\ReSharper2.5\src\Psi\src\impl\PsiManager\PsiManagerImpl.cs:line 606
at JetBrains.ReSharper.Psi.Impl.AsyncCommitServiceImpl.Commiter.DoCommit() in c:\Agent\work\Server\ReSharper2.5\src\Psi\src\impl\AsyncCommitServiceImpl.cs:line 133
at JetBrains.ReSharper.Psi.Impl.AsyncCommitServiceImpl.<>c__DisplayClass1.<onalarm>b__0() in c:\Agent\work\Server\ReSharper2.5\src\Psi\src\impl\AsyncCommitServiceImpl.cs:line 93
at JetBrains.ReSharper.Psi.Impl.AsyncCommitServiceImpl.OnAlarm() in c:\Agent\work\Server\ReSharper2.5\src\Psi\src\impl\AsyncCommitServiceImpl.cs:line 95
at JetBrains.ReSharper.Shell.Invocator.PendingAction.Execute() in c:\Agent\work\Server\ReSharper2.5\src\Shell\src\Invocator.cs:line 275
at JetBrains.ReSharper.Shell.Invocator.ProcessQueue() in c:\Agent\work\Server\ReSharper2.5\src\Shell\src\Invocator.cs:line 196
--- End of inner exception stack trace ---

at JetBrains.ReSharper.Util.Logger.LogExceptionEx(Exception, String, Boolean) in c:\Agent\work\Server\ReSharper2.5\src\Util\src\Logger.cs:line 350 column 9
at JetBrains.ReSharper.Util.Logger.LogException(String, Exception) in c:\Agent\work\Server\ReSharper2.5\src\Util\src\Logger.cs:line 367 column 5
at JetBrains.ReSharper.Shell.Invocator.ProcessQueue() in c:\Agent\work\Server\ReSharper2.5\src\Shell\src\Invocator.cs:line 200 column 11
at System.RuntimeMethodHandle._InvokeMethodFast(Object, Object[], SignatureStruct&, MethodAttributes, RuntimeTypeHandle)
at System.RuntimeMethodHandle.InvokeMethodFast(Object, Object[], Signature, MethodAttributes, RuntimeTypeHandle)
at System.Reflection.RuntimeMethodInfo.Invoke(Object, BindingFlags, Binder, Object[], CultureInfo, Boolean)
at System.Delegate.DynamicInvokeImpl(Object[])
at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry)
at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object)
at System.Threading.ExecutionContext.runTryCode(Object)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, Object)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext, ContextCallback, Object)
at System.Threading.ExecutionContext.Run(ExecutionContext, ContextCallback, Object)
at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry)
at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
at System.Windows.Forms.Control.WndProc(Message&)
at System.Windows.Forms.ScrollableControl.WndProc(Message&)
at System.Windows.Forms.ContainerControl.WndProc(Message&)
at System.Windows.Forms.Form.WndProc(Message&)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message&)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message&)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr, Int32, IntPtr, IntPtr)
GeneralRe: Great plugin ... Pin
Alexander Nesterenko27-Apr-07 1:06
Alexander Nesterenko27-Apr-07 1:06 
GeneralRe: Great plugin ... Pin
sting0127-Apr-07 1:12
sting0127-Apr-07 1:12 
GeneralRe: Great plugin ... Pin
Alexander Nesterenko27-Apr-07 1:24
Alexander Nesterenko27-Apr-07 1:24 
GeneralProblem with installation Pin
Michael O.27-Apr-07 0:54
Michael O.27-Apr-07 0:54 
GeneralRe: Problem with installation Pin
Alexander Nesterenko27-Apr-07 1:03
Alexander Nesterenko27-Apr-07 1:03 
GeneralNice work Pin
dchrno27-Apr-07 0:38
dchrno27-Apr-07 0:38 
AnswerRe: Nice work Pin
Alexander Nesterenko27-Apr-07 0:43
Alexander Nesterenko27-Apr-07 0:43 
GeneralGreat work Pin
Sergey Mirvoda26-Apr-07 22:47
Sergey Mirvoda26-Apr-07 22:47 
GeneralRe: Great work Pin
Alexander Nesterenko26-Apr-07 22:49
Alexander Nesterenko26-Apr-07 22:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.