Plugin Developer Discussion

Discussion for FogBugz Plugin developers

Using CLocalizer format strings

Some strings in the CLocalizer have format instructions %N in them, such as CLocalizer.Current.FB_PROMPT_DATE_FORMAT (which I'd like to use in my plugin):
"Enter the completion date as %1 or enter (%2)"

Now the problem is that %1 should be replaced with the date format used on the user's side and %2 with the NULL value text, which is "(none)" in English.

Is there a function which does the formatting for me, and where do I find the text to insert?
Arsène von Wyss Send private email
Wednesday, November 4, 2009
 
 
Hi Arsène,
You're right -- the function is called SwapN, and we don't expose it in the Plugin API. That's a bug. Here is a simple C# implementation that should work for you until we expose it:

    public static string SwapN(string s, params string[] rgs)
    {
        string sReplaced = s;
          for (int i = 1; i <= rgs.Length; i++)
        {
              sReplaced = sReplaced.Replace("%" + i.ToString(), rgs[i-1]);
        }
        return sReplaced;
    }

Sound okay?
Thanks!
Brett
Brett Kiefer Send private email
Wednesday, November 4, 2009
 
 
Thanks, that's a good starting point.

However, where do I get the appropriate strings, especially the correct date format to be entered and the NULL placeholder?
Arsène von Wyss Send private email
Wednesday, November 4, 2009
 
 
Hi Arsène-
It's the just the current localized DateTime format. We don't expose this right now, but our implementation just constructs a DateTime(2011, 11, 22), and replaces 2001 with "YYYY", 11 with "MM", and 22 with "DD".
Thanks!
Brett
Brett Kiefer Send private email
Wednesday, November 4, 2009
 
 
Okay, so are both
Thread.CurrentUICulture
and
Thread.CurrentCulture correctly set to the current users locale when inside API calls, for all calls including RawPage/AJAX?

If not, can I easily get the CultureInfo which I should use for formatting and parsing?

Because the locale returned by api.Person.GetCurrentPerson().sLocale may be "*" fpr the current browser locale, so that I'd have to go and look up the browser's locale, I'm pretty sure that you have already coded this and it would be great if I could just reuse your implementation.
Arsène von Wyss Send private email
Wednesday, November 4, 2009
 
 
Yes, the culture is set within FogBugz based on the request and account, and that is still set for plugins.
Brett Kiefer Send private email
Wednesday, November 4, 2009
 
 
Great, perfect!

Do you also know where I can get the "none" string? Because in the CLocalizer, there's FB_NONE but that's "None" and not "none" or "(none)".
Arsène von Wyss Send private email
Wednesday, November 4, 2009
 
 
Hi Arsène-
That's not available right now - in fact, the FogBugz code just assumes that the parens are not part of the internationalization and just inserts them around the FB_NONE string. Can you work with that?
Thanks!
Brett
Brett Kiefer Send private email
Friday, November 6, 2009
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz