public static string GetString(string domain, string msgid) { IntPtr msgid_ptr = UnixMarshal.StringToHeap(msgid); IntPtr domain_ptr = domain == null ? IntPtr.Zero : UnixMarshal.StringToHeap(domain); if (domain == null) { // FIXME banshee-1? IntPtr ptr = UnixMarshal.StringToHeap("banshee"); UnixMarshal.FreeHeap(ptr); } try { IntPtr ret_ptr = domain_ptr == IntPtr.Zero ? gettext(msgid_ptr) : dgettext(domain_ptr, msgid_ptr); if (msgid_ptr != ret_ptr) { return(UnixMarshal.PtrToStringUnix(ret_ptr)); } return(msgid); } finally { UnixMarshal.FreeHeap(msgid_ptr); if (domain_ptr != IntPtr.Zero) { UnixMarshal.FreeHeap(domain_ptr); } } }
public static string GetString(string domain, string msgid, string msgidPlural, int n) { IntPtr msgid_ptr = UnixMarshal.StringToHeap(msgid); IntPtr msgid_plural_ptr = UnixMarshal.StringToHeap(msgidPlural); IntPtr domain_ptr = domain == null ? IntPtr.Zero : UnixMarshal.StringToHeap(domain); try { IntPtr ret_ptr = domain_ptr == IntPtr.Zero ? ngettext(msgid_ptr, msgid_plural_ptr, n) : dngettext(domain_ptr, msgid_ptr, msgid_plural_ptr, n); if (ret_ptr == msgid_ptr) { return(msgid); } else if (ret_ptr == msgid_plural_ptr) { return(msgidPlural); } return(UnixMarshal.PtrToStringUnix(ret_ptr)); } finally { UnixMarshal.FreeHeap(msgid_ptr); UnixMarshal.FreeHeap(msgid_plural_ptr); if (domain_ptr != IntPtr.Zero) { UnixMarshal.FreeHeap(domain_ptr); } } }