[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Pnet-developers] RFC: GNU gettext support for C#
From: |
Rhys Weatherley |
Subject: |
Re: [Pnet-developers] RFC: GNU gettext support for C# |
Date: |
Wed, 31 Dec 2003 07:48:13 +1000 |
User-agent: |
KMail/1.4.3 |
On Wednesday 31 December 2003 12:46 am, Bruno Haible wrote:
> If you want a shortcut, you would define it in each class:
>
> private static GettextResourceManager res = Util.MyResourceManager;
> private static String _(String s) { return res.GetString(s); }
>
> Then the calls look like this:
>
> Console.WriteLine(_("Completed."));
Seems a little long-winded, having the duplicate the resource stuff in every
class. What I normally do (in assemblies other than "mscorlib" which is a
special case) is define a class called "S", which takes care of loading the
string resources and defining the "_" method. Then the idiom is:
Console.WriteLine(S._("Completed"));
You could define such an "S" class in your C# gettext library, and use
"Assembly.GetCallingAssembly()" to figure out which assembly to fetch gettext
resources for.
Cheers,
Rhys.