[Mono-dev] [PATCH] Bind d(n)gettext in Mono.Unix.Catalog

Stephane Delcroix stephane at delcroix.org
Thu Dec 3 15:02:04 EST 2009


	After some thought, this patch isn't a good idea, as you're supposed to
bindtextdomain() prior to d(n)gettext, and even if Catalog.Init () do
the bindtextdomain(), it also does an extra textdomain() call which is
unfortunate in this case.

	So, let's forget about this, we found a solution with lluis earlier
today, reusing MA translation code.

S


On Thu, 2009-12-03 at 13:09 -0500, Jonathan Pryor wrote:
> On Thu, 2009-12-03 at 13:22 +0100, Stephane Delcroix wrote:
> > Here's a patch for Mono.Unix that P/Invoke d(n)gettext in addition to
> > (n)gettext. It's quite useful for writing libraries requiring
> > translations (think of Mono.Addins.Gui), esp. since GNU-gettext doesn't
> > support multiple domains.
> 
> One problem: you're *removing*
> Catalog.GetPluralString(string,string.int).  That's bad. :-)
> 
> Also, for your new GetPluralString() method, instead of using
> MarshalStrings() (with an _ignore argument) +
> UnixMarshal.StringToHeap(), combine the two so that MarshalStrings()
> isn't getting an _ignore argument.
> 
> That aside, it looks good, though I do wonder if the overloading here is
> a good idea.
> 
> Basically, we'll wind up with this:
> 
>         public class Catalog {
>                 public static string GetPluralString (string s, string p, int n);
>                 public static string GetPluralString (string domain, string s, string p, int n);
>                 
>                 public static string GetString (string s);
>                 public static string GetString (string domain, string
>                 s);
>                 // ...
>         }
> 
> Generally, when overloading a method the first arguments should have the
> same meaning, and "optional" arguments should be last.  Thus:
> 
>         public class Catalog { 
>                 public static string GetPluralString (string s, string p, int n);
>                 public static string GetPluralString (string s, string p, int n, string domain);
>                 
>                 public static string GetString (string s);
>                 public static string GetString (string s, string
>                 domain);
>                 // ...
>         }
> 
> "Prior art," as it were, is System.Diagnostics.Trace.WriteLine[0]:
> 
>         public class Trace {
>                 public static void WriteLine (string message);
>                 public static void WriteLine (string message, string
>                 category);
>         }
> 
> So I'm torn as to the "proper" thing to do here, as we have three
> choices:
> 
>      1. Follow convention and make the 'domain' parameter last (above).
>      2. Break convention and make the 'domain' parameter first
>         (original).
>      3. Use different method names, e.g. GetDomainString(),
>         GetPluralDomainString(), and keep 'domain' as the first
>         parameter.
> 
> Of these choices, I'm inclined toward (3) or (1), but could be argued
> either way.
> 
> Thoughts?
> 
>  - Jon
> 
> [0]
> http://msdn.microsoft.com/en-us/library/system.diagnostics.trace.writeline.aspx
> 




More information about the Mono-devel-list mailing list