Why Some Texts Aren’t Showing Up in Loco Translate as entries

WINW > Prebuilt Software > Wordpress > Why Some Texts Aren’t Showing Up in Loco Translate as entries

Understanding the Issue:

It’s common for some texts to be missing from Loco Translate. This can be due to several reasons:

  • Hardcoded text: Text directly written in PHP or HTML files without using translation functions.
  • Dynamic content: Content generated by scripts or database queries.
  • Theme or plugin limitations: Some themes or plugins might restrict access to certain strings.

Troubleshooting Steps:

  1. Identify the Text:
    • Pinpoint the specific text that’s missing from Loco Translate.
    • Check if it’s part of a theme or plugin, or if it’s custom code.
  2. Inspect the Code:
    • If the text is within a theme or plugin, inspect the code to see how it’s implemented.
    • Look for functions like __(), _e(), esc_html__(), etc., which are used for translations.
    • If the text is hardcoded, you’ll need to modify the code to make it translatable.
  3. Check for Dynamic Content:
    • If the text is generated dynamically, Loco Translate might not be able to capture it.
    • Consider using translation functions within the code to make the text translatable.
  4. Verify Text Domain:
    • Ensure the correct text domain is used in the translation functions.
    • Mismatched text domains can prevent translations from being loaded.
  5. Consider a Different Approach:
    • If you can’t modify the code, you might need to use CSS or JavaScript to replace the text, but this is often not ideal.
    • For complex cases, consider using a plugin like WPML or Polylang, which offer more advanced translation features.

Example:

If you find a text like “Add to Cart” in your theme’s template file without using a translation function, you would need to modify the code to:

<?php echo esc_html__( 'Add to cart', 'your-theme-textdomain' ); ?>

This will make the text translatable using Loco Translate.

Additional Tips:

  • Backup your website before making any code changes.
  • Test thoroughly after making modifications.
  • Consider using a child theme to avoid overwriting the original theme’s code.

By following these steps and carefully analyzing the specific text you want to translate, you should be able to find a solution.

To don’t break plugin or themes, it’s necessary to follow the post below:
https://winw.com.br/2024/08/06/editing-theme-or-plugin-code-without-breaking-updates/

Leave a Reply