#7275 closed defect (bug) (fixed)
bp_core_enqueue_livestamp() results can't be properly translated
Reported by: | slaFFik | Owned by: | r-a-y |
---|---|---|---|
Milestone: | 2.7 | Priority: | normal |
Severity: | normal | Version: | |
Component: | I18N | Keywords: | has-patch |
Cc: |
Description
bp_core_enqueue_livestamp()
was introduced in 2.7. It has this array, which includes both singular and plurals:
array( 'future' => __( 'in %s', 'buddypress' ), 'past' => __( '%s ago', 'buddypress' ), 's' => __( 'a few seconds', 'buddypress' ), 'm' => __( 'a minute', 'buddypress' ), 'mm' => __( '%d minutes', 'buddypress' ), 'h' => __( 'an hour', 'buddypress' ), 'hh' => __( '%d hours', 'buddypress' ), 'd' => __( 'a day', 'buddypress' ), 'dd' => __( '%d days', 'buddypress' ), 'M' => __( 'a month', 'buddypress' ), 'MM' => __( '%d months', 'buddypress' ), 'y' => __( 'a year', 'buddypress' ), 'yy' => __( '%d years', 'buddypress' ), )
In Russian (and some other languages) plural like '%d years' can have 2 forms, for 2-4 (22-24 etc) items, and 5+ (25-30 etc). The word "years" in this case will be translated differently: "года" and "лет". Same for months/days/etc.
It seems we need to use _n()
or translate_nooped_plural()
with _n_noop()
.
Attachments (1)
Change History (11)
This ticket was mentioned in Slack in #buddypress by r-a-y. View the logs.
8 years ago
This ticket was mentioned in Slack in #buddypress by djpaul. View the logs.
8 years ago
#4
@
8 years ago
I don't think I have enough skill with this issue to meaningful contribute, but if we do add the javascript, we'll need to remember to check each release for updated upstream javascripts (something we ought to get in the habit of anyway -- maybe something for a beta checklist).
#5
@
8 years ago
I don't think I have enough skill with this issue to meaningful contribute
@DJPaul - Thanks for looking.
Can still use your feedback on directory structure. I've placed the moment.js locales in /bp-core/js/vendor/moment-locales/
, but perhaps you have a better suggestion?
we'll need to remember to check each release for updated upstream javascripts (something we ought to get in the habit of anyway -- maybe something for a beta checklist).
For sure.
This ticket was mentioned in Slack in #buddypress by r-a-y. View the logs.
8 years ago
This ticket was mentioned in Slack in #buddypress by mercime. View the logs.
8 years ago
#9
@
8 years ago
- Owner set to r-a-y
- Resolution set to fixed
- Status changed from new to closed
In 11191:
#10
@
8 years ago
@slaFFik - Thanks for the feedback you gave in today's dev chat.
Regarding filtering the moment.js
locale file, I decided not to introduce a new filter for this. Instead, you should be able to use the already, existing 'bp_core_register_commons_scripts'
filter.
Here's a quick code snippet:
<?php add_filter( 'bp_core_register_common_scripts', function( $retval ) { if ( isset( $retval['bp-moment-locale'] ) ) { $retval['bp-moment-locale']['file'] = 'hxxp://NEWLINK.com/moment-custom-locale.js'; } return $retval; } );
Let me know if you see anything else that needs addressing.
Attached is a patch that includes all of moment.js' locales as separate files and tries to dynamically load the right moment.js locale based on the current WordPress locale.
Warning: It's a large patch. Let me know if it applies cleanly.