JavaScript strings are never translated, as `wp_set_script_translations` is never called

Abierto
#4,547 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
72/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
php, typescript, wordpress

Línea de trabajo

Empieza inspeccionando las rutas de enqueue en class-editor-sidebar.php, class-dashboard-widget.php, class-post-list-stats.php, class-recommended-widget.php y el código del dashboard y de telemetría. Comprueba cada script handle encolado manualmente y verifica la reproducción en Post Editor con un locale del sitio traducido. Se considera terminado cuando las cadenas de JavaScript de esas superficies están traducidas y el bloque existente de Recommendations y las traducciones de PHP siguen funcionando.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Bug wp-parsely

Describe the bug

The plugin marks its JavaScript strings as translatable and declares Text Domain: wp-parsely, but never calls wp_set_script_translations() for any script it enqueues itself. That call is what loads the .json translation files WordPress delivers for JavaScript, so without it every one of those strings renders in English regardless of the site's language.

There are 359 __() and 7 _n() calls across 74 TypeScript files. By surface:

Location Calls Translated?
src/content-helper 333 No
src/js 4 No
src/blocks 22 Yes

The Recommendations block is fine because it is registered through register_block_type() with a block.json carrying "textdomain": "wp-parsely", and WordPress wires up script translations automatically in that case. Every other surface is enqueued by hand:

  • class-editor-sidebar.php — the Content Intelligence Editor Sidebar
  • class-dashboard-widget.php
  • class-post-list-stats.php
  • class-recommended-widget.php
  • the dashboard page and telemetry scripts

None of them follow their wp_enqueue_script() with a wp_set_script_translations().

PHP strings are unaffected — those load normally.

To Reproduce

  1. Set the site language to any locale with a wp-parsely translation.
  2. Open the Post Editor and expand the Parse.ly sidebar.
  3. Every label, button and message is in English, while the surrounding WordPress UI is translated.

Expected behavior

Strings marked translatable are translated. For a wp.org-distributed plugin this needs no build step and no .pot in the repository — WordPress downloads the JSON from translate.wordpress.org, and each enqueued handle needs:

wp_set_script_translations( static::get_script_id(), 'wp-parsely' );

If translating the JavaScript UI is deliberately not a goal, the opposite is worth doing: the __() wrappers are misleading as they stand, since they imply a translation path that does not exist.

Environment

  • wp-parsely 3.23.7 and earlier

Additional context

This is the mechanism behind #4546. The tone and persona labels were always marked translatable, but lived in JavaScript where translation is inert, so they were always English in practice. #4492 makes PHP the source of that vocabulary, where translation does work — which is what turned Formal into Formell and made a long-dormant inconsistency suddenly depend on the site's locale.

Lenguaje dominante
PHP
Estrellas
67
Forks
38
Merge medio
1 d 5 h
PR fusionados (30 d)
79

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Parsely/wp-parsely

Todos los issues de Parsely/wp-parsely

Issues similares

Más issues de PHP

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.