Linux 软件免费装

Theme and plugin translation for Polylang (TTfP)

开发者 marcinkazmierski
更新时间 2024年2月16日 02:56
PHP版本: 7.0 及以上
WordPress版本: 6.4
版权: GPL2

标签

translate theme language multilanguage polylang timber twig translation translator localization international multilingual languages

下载

详情介绍:

What is "Theme and plugin translation for Polylang"? Extension for Polylang plugin (Polylang is an extension to make multilingual WordPress websites.). Plugin is needed to translate the WordPress themes and plugins by Polylang. How to configure it? Select themes and plugins to find texts for translation by Polylang. In admin dashboard: Languages -> TTfP Settings How it is work? "Theme and plugin translation for Polylang" automatically searches all files of WordPress themes and plugins. It chooses from this file only those files with extensions: In addition, is implemented the integration with Timber library (read more: http://timber.upstatement.com) – which allows to translate twig's skins in simple way. Plugin in searched skins or plugins chooses texts from Polylang functions, such as: In your function.php, themes or plugins. For example: <p><?php pll_e('My text'); ?></p> <p><?php _e('My another text', 'my_theme'); ?></p> On the timber context declare this functions like: $context['pll_e'] = TimberHelper::function_wrapper('pll_e'); $context['pll_'] = TimberHelper::function_wrapper('pll_'); See more on: https://polylang.wordpress.com/documentation/documentation-for-developers/functions-reference/ These functions are defined by Polylang plugin for printing translations. Thanks "Theme and plugin translation for Polylang" you can find these strings to translate and add to Polylang register on very simple way. And then you can translate these texts from the admin dashboard. The scan result can be seen on the tab with translations: Settings -> Languages -> String translation or Languages -> String translation You don't need programs like poedit – you don't change files with extensions like: .pot, .po, .mo. "Theme and plugin translation for Polylang" is highly efficient because the scanner is worked only on admin dashboard in tab: In dashboard: Settings -> Languages -> String translation or Languages -> String translation Export and import string translation In dashboard: Languages -> TTfP Settings Filter reference ttfp_domains Allows plugins and themes (in functions.php) to modify list of text domains (unique identifier for retrieving translated strings). List of text domains is displayed on "TTfP Settings" page to select them for translation by polylang engine. Example: add_filter('ttfp_domains', 'custom_ttfp_domains', 10, 1); function custom_ttfp_domains(array $domains):array { $domains[] = "my-custom-domain"; return $domains; } Filter reference ttfp_translation_access Returns whether the user has capability to view and edit translations provided by TTfP. Example: 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'); }

安装:

This plugin requires to be installed and activated the Polylang plugin, This plugin requires PHP 5.0
  1. Upload the "Theme and plugin translation for Polylang" folder to the /wp-content/plugins/ directory on your web server.
  2. Activate the plugin through the Plugins menu in WordPress.
  3. In Dashboard go to the Settings -> Languages -> String translation or Languages -> String translation and find your texts.
Use <?php pll_e('My string'); // similar to _e(); // or: $var = pll_('My string'); // similar to __(); // or: _e('My string', 'my_theme'); // or: $var = __('My string', 'my_theme'); How to enable Twig extension with "Theme and plugin translation for Polylang"? [Timber plugin] In functions.php add: `if (!class_exists('Timber')) { add_action('admin_notices', function () { echo ' Timber not activated. Make sure you activate the plugin in ' . esc_url(admin_url('plugins.php')) . ''; }); return; } function timber_context() { $context = Timber::get_context(); $post = Timber::query_post(); $context['post'] = $post; $context['pll_e'] = TimberHelper::function_wrapper('pll_e'); $context['pll__'] = TimberHelper::function_wrapper('pll__'); return $context; } Timber::$dirname = array('templates', 'views'); // directory names with twig templates timber_context();` Next, for example in index.php add: <?php $context = timber_context(); $templates = array('home.twig', 'index.twig'); // twig files for render Timber::render($templates, $context); Then you can use in twig templates polylang functions like this (in templates/home.twig): {% extends "base.twig" %} {% block content %} <p> {{ pll_e("Test text on TWIG template 1.") }} </p> <p> {{ pll__("Test text on TWIG template 2.") }} </p> {% endblock %}

屏幕截图:

  • Export/import translations as CSV file with "Theme and plugin translation for Polylang".
  • Settings - Select area to be scanned in Strigs translations polylang tab.

更新日志:

3.4.2 - 2024/02/15 3.4.1 - 2024/01/16 3.4.0 - 2023/08/03 3.3.5 - 2023/04/24 3.3.4 - 2023/04/03 3.3.3 - 2023/01/26 3.3.2 - 2022/12/27 3.3.1 - 2022/12/15 3.3.0 - 2022/12/15 3.2.23 - 2022/12/12 3.2.22 - 2022/12/12 3.2.21 - 2022/12/12 3.2.20 - 2022/12/10 3.2.19 - 2022/11/17 3.2.18 - 2022/11/17 3.2.17 - 2022/11/08 3.2.16 - 2022/11/04 3.2.15 - 2022/11/04 3.2.14 - 2022/11/03 3.2.13 - 2022/05/26 3.2.12 - 2021/06/15 3.2.11 - 2021/05/17 3.2.10 - 2021/05/10 3.2.9 - 2021/05/04 3.2.8 - 2021/05/03 3.2.7 - 2021/05/03 3.2.6 - 2021/04/27 3.2.5 - 2021/02/20 3.2.4 - 2020/09/13 3.2.3 - 2020/03/26 3.2.2 - 2020/02/02 3.2.1 - 2019/12/07 3.2.0 - 2019/09/26 3.1.1 - 2019/09/20 3.1.0 - 2019/09/13 3.0.0 - 2019/05/12 2.0.4 - 2018/12/10 2.0.3 - 2018/07/04 2.0.2 - 2018/01/02 2.0.1 - 2017/10/03 2.0.0 - 2017/03/05 1.4.0 - 2017/01/29 1.3.3 - 2017/01/09 1.3.2 - 2016/09/07 1.3.1 - 2016/06/07 1.3 - 2016/05/15 1.2 - 2016/03/27 1.1 - 2016/02/03