c# - How can I implement a label file for regions that integrates well with MVC application structure? -
Background:
I am working on a site that is available In many areas each region can have a different language, or may be spelled differently for the same language. We are planning to use an XML label file that will contain all the text that will be displayed for a given area.
Then Area A Regional Balls. Will load Xml and all its text will come from it. RegionB regionBLabels.xml will load, and similarly.
I plan to implement it by configuring the XML file so that it follows the same structure as my application. For example,
& lt; Base & gt; & Lt; -! BaseController - & gt; & Lt; Home & gt; & Lt; -! HomeController - & gt; & Lt; HomePartial1 & gt; & Lt; LblFirstName & gt; The text for label with id lblFirstName & lt; / LblFirstName & gt; & Lt; LblLastName & gt; The text for label with id lblLastName & lt; / LblLastName & gt; & Lt; / HomePartial1 & gt; & Lt; HomePartial2 & gt; & Lt ;! - A group of labels - & gt; & Lt; / HomePartial2 & gt; & Lt; / Home & gt; & Lt; Accounting & gt; & Lt; AccountsPartial1 & gt; & Lt ;! - A group of labels - & gt; & Lt; / AccountsPartial1 & gt; & Lt; AccountsPartial2 & gt; & Lt ;! - A group of labels - & gt; & Lt; / AccountsPartial2 & gt; & Lt; / Accounting & gt; & Lt; / Base & gt;
The reason is that I want to do it this way because I want to implement the Convention on the configuration, so it becomes embedded in finding text for any partial view.
Using this structure, I can use the link-to-XML to select a text related to partial view which I'm going to render. For example, if I am providing Partial View HomePartial 1, then I can get some labels related to that partial view like:
var nodes = f (Res in this Select the XmlConfiguration candidate ("Base") Reservation.) Select the candidate ("Home") f; Var Home Page 1 label = nodes. Elements ("Home 1"). ToList ();
Question:
So this is the case, basically what I want to ask if someone can tell a clear hole in it Before I try to apply it? Can anyone suggest a better job before anyone?
Also , I have a specific request to present a partial view with many tabs, each of which is displayed in the text & amp; Many results related to that tab For example, I have 3 tabs:
fund company group
If a search does, the tab will display the search term to the number of results If you search for 'JPMorgan', then they become:
Funds (10) // 10 'JPMorgan' companies in funds (12) ) 12 12 Companies named 'JPMorgan' Group (15) / 15 groups include 'JPMorgan', which is named "Fund", "Company" and "Group" Labels. In Ill, I must also supply "(" and ")", which means that I have to use the place holder and change it with the actual value when I partial Therefore, XML will begin to look like this: & lt; Base & gt; & Lt; -! BaseController - & gt; & Lt; Home & gt; & Lt; -! HomeController - & gt; & Lt; Tabs & gt; & Lt; LblFundTab & gt; Fund (# value #) & lt; / Lbl fund tab & gt; & Lt; LblCompanyTab & gt; Company (# value #) & lt; / LblCompanyTab & gt; & Lt; LblGroupTab & gt; Group (# value #) & lt; / LblGroupTab & gt; & Lt; / Tabs & gt; & Lt; / Home & gt; & Lt; / Base & gt;
But I think it's starting to look dirty and a little laugh, can someone give a better suggestion? Thank you.
I had only one thing in a project recently.
I have implemented a LabelService that includes a single array of "labelfile" which was loaded into memory on application_start. So my code looks identical, but is working on memory objects, and XML files without avoiding many potential IO issues (locks, etc.)
If your xml label file is okay, suppose it is an application or potentially a developer, but if it is being edited by the client / non-tech, then to know that the "base" What is it? Or the controller? Etc. Etc - I am a fan of CoC but sometimes it is better to have domain-specific apps close to the domain terminology
Comments
Post a Comment