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

Translating account tabs #10

Open
hazirahs opened this issue Jan 4, 2024 · 1 comment
Open

Translating account tabs #10

hazirahs opened this issue Jan 4, 2024 · 1 comment

Comments

@hazirahs
Copy link

hazirahs commented Jan 4, 2024

Hi, how do I translate the account tabs (title plus the content from shortcode) using polylang or poedit? I translated the UM profile aside from the tabs through Poedit with no problem.

@umdevelopera
Copy link
Owner

umdevelopera commented Jan 10, 2024

Hello @hazirahs

Custom account tabs cannot be translated using multilingual plugins. This is the same problem as translating custom profile tabs.

Custom tabs can only be translated using hooks and custom functions. Use hook um_account_page_default_tabs_hook for account tabs.

Example

function my_translate_account_tabs( $tabs ) {
	$lang  = pll_current_language();

	$texts = array(
		'Account' => array(
			'en' => 'Account',
			'es' => 'Cuenta',
		),
		'Change Password' => array(
			'en' => 'Change Password',
			'es' => 'Cambiar la contraseña',
		),
		'Custom fields' => array(
			'en' => 'Custom fields',
			'es' => 'Campos Personalizados',
		),
		'Social fields' => array(
			'en' => 'Social fields',
			'es' => 'Campos sociales',
		),
	);

	foreach ( $tabs as $p => $tab ) {
		foreach ( $tab as $k => $tabdata ) {
			if ( isset( $tabdata['title'] ) ) {
				$t = $tabdata['title'];
				if ( array_key_exists( $t, $texts ) ) {
					if ( array_key_exists( $lang, $texts[ $t ] ) ) {
						$tabs[ $p ][ $k ]['title'] = $texts[ $t ][ $lang ];
					}
				}
			}
		}
	}
	return $tabs;
}
add_filter( 'um_account_page_default_tabs_hook', 'my_translate_account_tabs', 110, 1 );

There are many texts in UM that can not be easily translated. I want to add a tool for translating such texts to the extension for Polylang integration but this requires a lot of time because every place needs a specific hook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants