1

I want to make my application available in many languages. I started using Resource Files, but there is a little problem with them. I want other people to have access to these files. Visual Studio creates .dll for each file and that is not very easy to use. I want people to be able to see language files in an easy way.

My application is modular, so people can create their own plugins. Letting them translate my application to different languages seems obvious, but I can't find any way to let them do it.

1

On your .resx file right click > properties and choose 'Content' for Build Action. Build your application.

Right click the project node in solution explorer > Open Folder in File Explorer. Inside the Properties folder your .resx files will be located. Open it in your editor of choice and modify it. Restart your application and presto!

  • Yes it builds, and I can modify these files, but my application cannot start, because it cannot find resources that I've just set to Content. It gives me System.Resources.MissingManifestResourceException. Any workaround on that? – FCin Dec 4 '16 at 8:09
  • Figured it out. I used ResourceManager to load files from assembly. – FCin Dec 4 '16 at 10:00
0

You could use Lexical.Localization¹ as localization solution for modular parts, such as class libraries. The localization will work independently for each library. Libraries can both A) embed their own localizations within, and B) have localizations be published along as files.

If you write your class libraries initially for just one or two languages, you can inline the strings right into the code, even use $string_interpolation.

And when the deployer of your class library wants to expand with their own localization (Application supplying localizations). They can add localization as files.. or provide one within the Program.cs code as simple lines, such as Dictionary.

public class MyClass
{
    /// <summary>
    /// Localization root for this class.
    /// </summary>
    static ILine localization = LineRoot.Global.Type<MyClass>();

    /// <summary>
    /// Localization key "Ok" with a default string
    /// </summary>
    static ILine ok = localization.Key("Success").Text("Success");

    /// <summary>
    /// Localization key "Error" with a default string.
    /// </summary>
    static ILine error = localization.Key("Error").Format("Error (Code=0x{0:X8})");

    public void DoOk()
    {
        Console.WriteLine( ok );
    }

    public void DoError()
    {
        Console.WriteLine( error.Value(0x100) );
    }
}

Localization file can be written as .xml, .json, .ini, .resx, or with your own format.

[Type:MyClass:Culture:fi]
Key:Ok = Onnistui
Key:Error = Virhe (0x{0:X8})

¹ (I'm maintainer of that library)

  • are you affiliated with that "lexical.fi" site linked to in this answer? If yes, then please provide proper disclosure as explained eg here – gnat Jun 11 '19 at 20:28
  • I see, and yes, and now disclosed. Thanks for sharing the light on it. I hope it wasn't considered rude. – Tag Jun 12 '19 at 21:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.