Marcin Kazmierski
Forum Replies Created
-
I understand your worries. It surprises me too. Also, I will try to look into this problem again at my free time.
I think it is the same issue:
<?php print __( 'text' ); ?> <?php print __( 'text', 'twentytwenty' ); ?> <?php print __( 'text', 'my_theme' ); ?> <?php print __( 'text', 'acf' ); ?>
if you translate “text” via Polylang, above each function will return the same translation, because Polylang plugin does not support domains in text translations from the admin panel (in my opinion).
Yes exactly.
I tried to implement this in my plugin, but I failed to do that.
This is an interesting problem. Perhaps I need to read more code of the Polylang plugin and find some filter or action to fix this?
But I need more time ??Great, thank you for your tip!
hello @steviek13, I need more details ?? Can you provide screenshots and a PHP code snippet?
@pavelmares Is this the same problem as in this issue?
@pavelmares thanks for your issue – good issue ??
I spent a lot of time to fix this…
But the problem is on the side of the Polylang plugin.Polylang string registration function does not support the domain:
pll_register_string
[@param string $context Optional, the group in which the string is registered, defaults to 'polylang'.
]
This optional $context is not the same as context in the class Translations (from WordPress core):Translations()->translate( $singular, $context = null )
In Translations context means the domain of the text.To fix this I need to make changes inside Polylang plugin- I think.
In summary, Polylang plugin does not support domains in text translations from the admin panel.
hello @2candela2 and thank you for your issue.
Can you describe your problem in more detail?
I can hide the menu for users who do not have access – will it be enough ?
@vorlando if you have time, please add some review ??
https://www.ads-software.com/support/plugin/theme-translation-for-polylang/reviews/
@xellagm if you have time, please add some review ??
https://www.ads-software.com/support/plugin/theme-translation-for-polylang/reviews/
Hi @xellagm ,
I have added filter and at now you can manage it in your function.php like:
add_filter('ttfp_translation_access', 'custom_ttfp_translation_access', 10, 1); function custom_ttfp_translation_access(bool $hasAccess):bool { return current_user_can('edit_posts'); }
Please update plugin to latest the version: 3.4.0.
@vorlando I fixed it.
You can disable force translation of admin dashboard using latest version of plugin: 3.4.0. (/wp-admin/admin.php?page=mlang_import_export_strings -> switch to “None”)
Sorry for the delay…
@nic727 I apologise for the delay. This is already a problem with Polylang plugin. Please use:
pll_register_string
Allows plugins to add their own strings in the “strings translation” panel. The function must be called on admin side (the functions.php file is OK for themes). It is possible to register empty strings (for example when they come from options) but they won’t appear in the list table.
From documentation: https://polylang.pro/doc/function-reference/
Same example: https://gist.github.com/dworkz/688c5ff12f193b1d0534
@vorlando what settings you have saved here:
/wp-admin/admin.php?page=mlang_import_export_strings ?
do you have option “Force translate admin dashboard” disabled?Forum: Plugins
In reply to: [Theme and plugin translation for Polylang (TTfP)] esc_html__ translate?@loosie94 scanner in plugin searches for esc_html__ functions:
// find wp functions: esc_html_e, esc_html, esc_html__, esc_attr, esc_attr_e, esc_attr__ preg_match_all("/[\s=\(\.]+(esc_html|esc_attr)[_e]*[\s]*\([\s]*[\'](.*?)[\'][\s]*[,]*[\s]*[\']*(.*?)[\']*[\s]*\)/s", $content, $matches); if (!empty($matches[2])) { $strings = array_merge($strings, $matches[2]); }
please confirm the problem with an example ??