0

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

Klímačka
  • 261
  • 1
  • 3
  • 16

1 Answers1

1

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.

David Ebbo
  • 42,443
  • 8
  • 103
  • 117
  • Yes it does the job, but there are more places where similar _foreach_ loops can be seen, e.g. 9 lines below the one you mentioned. I am afraid to break something when I start to edit this template which I know nothing about its' syntax.When I open the issue on GitHub will you guys just do the one-line substitution or you are actually going to revise the whole template and adjust it where appropriate? – Klímačka Jun 20 '17 at 09:26
  • 1
    Most T4MVC changes are user driven. Do your best to find all the locations that matter and send a PR – David Ebbo Jun 20 '17 at 13:34
  • Sorry, but I will not do that. I do not know the language in which it is written so I can't do such adjustments. Most I can do is to open an issue as you mentioned in your answer. – Klímačka Jun 21 '17 at 13:56
  • Yes, start with the issue, and enumerate all the cases where you see this. – David Ebbo Jun 21 '17 at 13:59