如何强制Visual Studio或T4MVC使用英语区域设置而不是系统范围的区域设置?

时间:2017-06-15 08:18:04

标签: visual-studio-2015 tfs locale development-environment t4mvc

情况: 我们开发团队的一些成员使用捷克语Windows,有些(包括我)使用英语操作系统。

问题是我们使用T4MVC模板自动生成一些代码。它的工作方式是该工具输出按字典顺序排序的生成成员(这当然是好的),但由于捷克语和英语之间的字母顺序存在差异,因此在与TFS源代码控制同步时,我们会不断更改顺序。

区别在于字母CH,这在英语中是不存在的(这很好),但是捷克爸爸想要这封信,所以我们确实拥有它,它来自H。

所以,英语顺序A-B-C-D-E-F-G-H-I ......在捷克语中受到严重破坏:A-B-C-D-E-F-G-H- CH -I ...

因此,在生成的代码中会出现类似这样的差异:

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

而不是:

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

所以我的问题是:如何使用T4MVC或更好的整个Visual Studio来使用英语语言环境。无论如何,IDE对于每个人来说都是英文的,所以这种捷克排序没有任何意义。

我们正在使用Visual Studio 2015。

T4MVC是:https://github.com/T4MVC/T4MVC

1 个答案:

答案 0 :(得分:0)

我想我们可以在T4MVC.tt中解决这个问题。尝试在第1034行进行以下更改。更改:

foreach (var viewPair in viewsFolder.Views)

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

如果可行,我们可以在主模板中进行更改。请在https://github.com/T4MVC/T4MVC上打开问题进行跟踪。