添加水平RESX文件 [英] Adding levels to RESX files
问题描述
目前我使用的资源文件在一个标准的键/值的方式来定位MVC4项目。现在,我寻找到最佳的解决方案,以单独的基于控制器/动作,他们属于某个键。总是有创造键,如Home.Index.Title原料的解决方案,但是这只是解决方法。有没有办法用,他们可以设计成具有父/子节点,其中最高点是控制器,然后行动,最后现场RESX文件工作,使他们能够通过LINQ查询?
Currently I'm using resources files to localize MVC4 project in a standard key/value way. I'm now looking into best solution to separate some keys based on controller/action they belong to. There is always raw solution in creating keys such as Home.Index.Title but that's just workaround. Is there a way to work with resx files where they could be designed with parent/child nodes, where highest node would be Controller, then Action and finally Field, so that they can be queried by LINQ?
推荐答案
RESX文件总是有一个简单的键/值结构。如果目的是组织资源,使他们很容易找到维修,我可以建议一些其他的方法。
Resx files always have a simple key/value structure. If the aim is to organise the resources and make them easy to locate for maintenance, I can suggest a couple of other approaches.
如果有问题的资源是在视图中使用,可以在App_LocalResources文件夹视图文件夹中创建每个视图一个资源文件,并组织他们的方式,间接地链接到特定的控制器和动作。
If the resources in question are for use in views, you can create one resource file per view in an App_LocalResources folder within the view folder and organise them that way, indirectly linked to a specific controller and action.
如果资源是在控制器本身使用,您可以创建重新presents控制器和在每个,每个动作一个资源文件(比如说)〜/资源文件夹内的文件夹。通过这种方式,资源命名空间将指示控制器/动作,其中资源被消耗。
If the resources are for use in the controller itself, you can create a set of folders within (say) a ~/Resources folder that represents the controllers and within each, a resource file for each action. That way, the resource namespaces will indicate the controller/action where the resources are consumed.
这篇关于添加水平RESX文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!