Search code examples
visual-studio-2015tfslocaledevelopment-environmentt4mvc

How to force Visual Studio or T4MVC to use English locale instead of system-wide one?


The situation: Some members of our development team use Czech Windows, some (me including) use English OS.

The problem is when we use T4MVC templates to generate some code automatically. The way it works is that the tool outputs the generated members sorted lexicographically (which is of course good), but since there are differences in alphabetical order between Czech and English, we keep getting changed order when syncing with TFS source control.

The difference is in letter CH which does not exist in English (and that's good), but Czech daddys wanted this letter so we do have it and it comes after H.

So, English order A-B-C-D-E-F-G-H-I... is mangled in Czech like this: A-B-C-D-E-F-G-H-CH-I...

In consequence differences like these happen in the generated code:

public class _ViewNamesClass
{
    public readonly string _CommonGrid = "_CommonGrid";
    public readonly string _CommonChart = "_CommonChart";
    public readonly string _CommonStat = "_CommonStat";
    public readonly string _CommonView = "_CommonView";
}

as opposed to:

public class _ViewNamesClass
{
    public readonly string _CommonChart = "_CommonChart";
    public readonly string _CommonGrid = "_CommonGrid";
    public readonly string _CommonStat = "_CommonStat";
    public readonly string _CommonView = "_CommonView";
}

So my question is: How do I get either T4MVC or better the whole Visual Studio to use English locale. The IDE is in English for everyone anyway so this Czech sorting does not make any sense.

We are using Visual Studio 2015.

T4MVC is this: https://github.com/T4MVC/T4MVC


Solution

  • I think we can fix this in T4MVC.tt. Try making the following change at line 1034. Change:

    foreach (var viewPair in viewsFolder.Views)
    

    to

    foreach (var viewPair in viewsFolder.Views.OrderBy(pair => pair.Key, StringComparer.OrdinalIgnoreCase))
    

    If that works, we can make the change in the main template. Please open issue on https://github.com/T4MVC/T4MVC to track.