In the application I'm developing, the same software package serves many industries, and those industries have different vocabulary for what is essentially the same thing. The application is a C# server, to which a WPF desktop app makes socket-based XML requests.

For example, some customers may call something an "Item", some call it a "Part", or some call it a "SKU".

The goal is for the application to be able to relabel itself based on a "Vocabulary" setting that we create for the user. Typically, a given customer's vocabulary will only differ by perhaps 5-25 words/phrases out of the entire application. These custom vocabularies are specific to/created by the customer, and wouldn't be kept with the main application distribution.

My initial thought was to do this with custom CultureInfo, (e.g. "en-AC" for "Acme" company), supply just values that differ from the base en-US in that resource file.

The en-AC.resx resource could be kept on the server, loaded by the server, and also transmitted for loading into the WPF client app.

Problem with that thus far seems to be that the ResourceManager does not correctly pick strings for custom cultures, a'la this thread, and I've not been able to solve that yet. As well, as the app is ClickOnce deployed, we may not have permission to register a new culture.

My next thought, since the number of phrases to modify is so small, was to replace the resource value at runtime, but that seems to be a bit of a no-no as well, searching around.

So, thought I would ask the community for their suggestions on how to handle this.

Open to suggestions and ideas...

没有正确的解决方案

其他提示

Because it's only about a few words I think I'd do it via a naming convention. Suppose you defined the string key "MyCompany". You usually access this way:

string myString1 = Properties.Resource.MyCompany;

But it is also ok to Access it that way:

string myString2 = Properties.Resource.ResourceManager.GetString ("MyCompany")

It's exactly the same (but dealing with strings as identifiers - which is somewhat error prone). What you now can do is to check for a special name first that you syntesize like "MyCompany_AC". The drawback is you need your own wrapper for each string:

    string MyCompany
    {
      get
      {
        string myString = Properties.Resource.ResourceManager.GetString ("MyCompany_" + theCompanyPostfix);

        if (myString == null)
        {
            myString = Properties.Resource.ResourceManager.GetString ("MyCompany");
        }

        return myString;
      }
    }
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top