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

FIx/Few string does not translate regarding the Dokan RFQ module. #220 #88

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions dokan-wpml.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ public function plugins_loaded() {
add_action( 'dokan_disable_url_translation', [ $this, 'disable_url_translation' ] );
add_action( 'dokan_enable_url_translation', [ $this, 'enable_url_translation' ] );

// Request rule create/update hooks
add_action('dokan_quote_rule_created', [$this, 'dokan_request_quote_button_text_registration'], 10, 3);
add_action('dokan_quote_rule_updated', [$this, 'dokan_request_quote_button_text_registration'], 10, 3);

// Request quote button text filter

add_filter('dokan_request_quote_button_text', [$this, 'get_translated_dokan_request_quote_button_text'], 10, 2);
add_filter( 'wp', [ $this, 'set_translated_query_var_to_default_query_var' ], 11 );
add_filter( 'dokan_set_store_categories', [ $this, 'set_translated_category' ] );
add_filter( 'dokan_get_store_categories_in_vendor', [ $this, 'get_translated_category' ] );
Expand Down Expand Up @@ -1316,6 +1323,38 @@ public function get_translated_verification_method_title( $title ) {
public function get_translated_verification_method_help_text( $help_text ) {
return $this->get_translated_single_string( $help_text, 'dokan', 'Dokan Vendor Verification Method Help Text: ' . substr( $help_text, 0, 116 ) );
}

/**
* Get the translated text for the Dokan request quote button.
*
* @param string $text The original button text.
* @param object $rule The rule object containing the ID.
*
* @return string The translated button text.
*/
public function get_translated_dokan_request_quote_button_text(string $text, $rule): string
{
return $this->get_translated_single_string($text, 'dokan', 'Dokan Request Quote Button Text: ' . $rule->id);
}

/**
* Registers the request quote button text for translation.
*
* @param bool $action The action status.
* @param array $args The arguments containing the button text.
* @param int $rule_id The ID of the rule.
*
* @return void
*/
public function dokan_request_quote_button_text_registration(bool $action, array $args, int $rule_id)
{
if (! $action) {
return;
}
$button_text = $args['button_text'];
$this->register_single_string('dokan', 'Dokan Request Quote Button Text: ' . $rule_id, $button_text);

}
} // Dokan_WPML

function dokan_load_wpml() { // phpcs:ignore
Expand Down