I've read a bit about the gettext. I believe it's a nice tool.
I've seen it's possible to use it with PHP projects.
I wonder if it is possible to use gettext also in with C#?
I've read a bit about the gettext. I believe it's a nice tool.
I've seen it's possible to use it with PHP projects.
I wonder if it is possible to use gettext also in with C#?
There is a C# version as well and it can be used with both .resource
and .dll
files. Sample use with a 'singleton' type of approach:
Define a static holding the ResourceManager instance:
public static GettextResourceManager MyResourceManager =
new GettextResourceManager("domain-name");
All classes containing internationalized strings then contain
private static String _(String s) { return Util.MyResourceManager.GetString(s); }
and this lets you use it like this, quite clean:
Console.WriteLine(_("Operation completed."));
Note that it needs some exception handling etc. and also introduces a lot of code duplication, which you can sort in different ways.
You can find all the usage details and context in the manual itself:
https://www.gnu.org/software/gettext/manual/html_node/C_0023.html#C_0023