Question

The project is a GNOME aplication not a ASP.NET. I need to load a welcome.html file into the main page of the UI. Just like MonoDevelop does. But I dont know how to make international versions that will load ased on locality. And I dont know how to bundle it into the binary using some sort of resource management.

Was it helpful?

Solution

MonoDevelop used to use HTML for the welcome page, but at the time (about 18 months ago) we found a GTK+ web browser to be an awkward dependency for cross-platform use, so switched to plain GTK# with some custom background rendering.

That said, it's pretty easy to use HTML using Webkit-GTK & the Webkit# wrapper. Create a WebKit.WebView widget, then use the LoadHtml method to load HTML from a string.

Reading an embedded text resource from an assembly is pretty easy:

string text;
using (var stream = typeof(SomeTypeInYourAssembly).Assembly.GetManifestResourceStream (resourceId))
    using (var sr = new StreamReader (stream))
        text = sr.ReadToEnd ();

This will read a resource embedded with the C# compiler argument /res:FILE[,ID] or using the "Embedded Resource" build action in MonoDevelop. You can set the resource ID in MD using the proeprty pad if you don't like the default.

Localisation is trickier. The ".NET way" would be to use localised satellite assemblies containing localised resources. However, we what we did in MD was to use an XSLT file to convert an XML file into HTML. We could then localise the XML file quite easily, using Gettext and the XML DOM classes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top