Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't translate wordcamp statuses in logs #1300

Open
dd32 opened this issue Apr 29, 2024 · 0 comments
Open

Don't translate wordcamp statuses in logs #1300

dd32 opened this issue Apr 29, 2024 · 0 comments
Labels
[Component] Reports [Type] Bug [Type] Internationalization Issues related to i18n or handling non-English languages or content

Comments

@dd32
Copy link
Member

dd32 commented Apr 29, 2024

Describe the bug

On https://central.wordcamp.org/reports/wordcamp-status-report/ a PHP Notice is being triggered:

E_NOTICE Undefined index:
File wp-content/plugins/wordcamp-reports/views/html/wordcamp-status.php:41

This is caused by $active_camp containing this data:

array (size=4)
  'name' => string 'WordCamp ......' (length=28)
  'logs' => 
    array (size=1)
      1 => 
        array (size=3)
          'timestamp' => int ..........
          'user_id' => int .........
          'message' => string 'Needs Vetting → 已拒絕' (length=30)
  'latest_log' => 
    array (size=3)
      'timestamp' => int ...........
      'user_id' => int ...........
      'message' => string 'Needs Vetting → 已拒絕' (length=30)
  'latest_status' => string '' (length=0)

'latest_status' is empty, as the new status is extracted from the log text, expecting that it's only in English.

/**
* Determine the ending status of a particular status change event.
*
* E.g. for this event:
*
* Needs Vetting → More Info Requested
*
* The ending status would be "More Info Requested".
*
* @param array $log_entry A status change log entry.
* @param array $status_list List of status_id -> status_name mapping
*
* @return string
*/
protected function get_log_status_result( $log_entry, $status_list ) {
if ( isset( $log_entry['message'] ) ) {
$pieces = explode( ' → ', $log_entry['message'] );
if ( isset( $pieces[1] ) ) {
return $this->get_status_id_from_name( $pieces[1], $status_list );
}
}
return '';
}
/**
* Given the ID of a WordCamp status, determine the ID string.
*
* @param string $status_name A WordCamp status name.
* @param array $status_list List of status_id -> status_name mapping
*
* @return string
*/
protected function get_status_id_from_name( $status_name, $status_list ) {
$statuses = array_flip( $status_list );
if ( isset( $statuses[ $status_name ] ) ) {
return $statuses[ $status_name ];
}
return '';
}

When logging, the post status should use the english non-translated text, or, it should log the IDs in the metadata for it.

This is more than just a PHP Notice; this means that others have to translate the logs to see what changed.

To reproduce

Steps to reproduce the behavior:

  1. Use a locale that has translated the post_status labels
  2. Change status
  3. Note log including translated post status label.

Expected behavior

English logs.

WordCamp

https://central.wordcamp.org/wp-admin/post.php?post=5701004&action=edit

@dd32 dd32 added [Type] Bug [Component] Reports [Type] Internationalization Issues related to i18n or handling non-English languages or content labels Apr 29, 2024
@dd32 dd32 changed the title Don't translate wordcamp statuses Don't translate wordcamp statuses in logs Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Component] Reports [Type] Bug [Type] Internationalization Issues related to i18n or handling non-English languages or content
Projects
None yet
Development

No branches or pull requests

1 participant