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

Localize option tries to localize already localized strings breaking the patters. #632

Closed
matiasbenedetto opened this issue May 13, 2024 · 1 comment · Fixed by #641
Closed
Assignees
Labels
bug Something isn't working

Comments

@matiasbenedetto
Copy link
Contributor

What

The localize option tries to localize already localized strings, breaking the patterns.

Example output of saving TT4 theme using 'Localize Text' option enabled:

<!-- wp:paragraph {"align":"left"} -->
<p class="has-text-align-left"><?php echo __('Experience the fusion of imagination and expertise with Études <?php echo __('Architectural Solutions', 'twentytwentyfour');?>.', 'twentytwentyfour');?></p>
<!-- /wp:paragraph --></div>

Please observe that an echo statement is inside another echo statement, which will result in a parse error. This breaks the pattern where this is included.

Expected

The localize functionality should not try to localize already localized text.

@matiasbenedetto matiasbenedetto added the bug Something isn't working label May 13, 2024
@matiasbenedetto matiasbenedetto self-assigned this May 13, 2024
@matiasbenedetto
Copy link
Contributor Author

Adding more details:

What's the bug? 'Localize text' functionality collects the strings that should be translated in a theme as a list. Example:

  • "Hi!"
  • "Hi! I'm glad you chose My Theme"
  • "Good bye"

Having that it tries to add translation marks to each of those strings in the templates. Example:

<?php echo __("Hi!", "my-theme"); ?>
<?php echo __("Good bye!", "my-theme"); ?>

The problem arises when a longer string contains a shorter string present in other element. In those cases the output is invalid PHP so the templates break.

<?php echo __("<?php echo __("Hi!", "my-theme"); ?> I'm glad you chose My Theme", "my-theme"); ?>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant