Skip to:
Content
Pages
Categories
Search
Top
Bottom

Extending BB_Locale

  • Is there a way to extend BB_Locale?

    Today, BB_Locale calls init and that’s that. No hooks/event handling at all, as far as I can tell.

    In method init, among other things, the following loads:

    $this->datetime_formatstring['datetime'] = __('F j, Y - h:i A');

    $this->datetime_formatstring['date'] = __('F j, Y');

    $this->datetime_formatstring['time'] = __('h:i A');

    The Question

    What if anything can I do if I want to have a datetime_formatstring['special-date'] = __('Y F j - h'); added to BB_Locale. I’m using the three existing formats as listed above already and I want to add a fourth alternative without adding a row in core BB-files.

    Just to be clear, I want to be able to do this:

    _e("Today's date, formatted in a special way is:") . bb_datetime_format_i18n( bb_current_time(), 'special-date' );

    Am I missing something obvious here or is the only solution right now to modify the locale.php file?

    Appreciate the help.

Viewing 1 replies (of 1 total)
  • Well, just to tell anyone who – in the future – might be stuck on the same or a similar problem.

    I went with the following workaround:

    Find a hook (action/filter) that gets called early in the process like bb_location.

    Define a filter function for it.

    In that function, add the following peace of code.

    global $bb_locale;

    $bb_locale->datetime_formatstring = __(‘j M, Y’);

    Obviously, you can call your time format something else.

    Not the prettiest of solutions, but it works and I get to keep my bb_press installation free of code that I’ll surely forget to update.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar