Info
- 2 posts
- 1 voice
- Started 3 years ago by andersson
- Latest reply from andersson
- This topic is resolved
Extending BB_Locale
-
- Posted 3 years ago #
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 adatetime_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.
-
- Posted 3 years ago #
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['MY_TIME_FORMAT'] = __('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.
-
You must log in to post.