• 0
Diana

Sub menu items translation [FluxCP]

Question

I'm developing a multi-language FluxCP

And now in the Sub-menu items I can find that I can use only the word in one language that I can translate

An example : 

image.png

The login word If I want to translate it to the both English and Español 

If you looked here at application.conf you will find :- 

// Sub-menu items that are displayed for any action belonging to a
	// particular module. The format it simple.
		'account'		=> array(
			'login'			=> 'Login',
			'create'		=> 'Register',
			'resetpass'		=> 'Reset Password',
			'resend'		=> 'Resend E-mail Confirmation'
		),

I can't make it get the word from language config file ( It shows only the word " Login " ) 

Can I make it with php to get the word from the Language config file like :-  

<?php echo htmlspecialchars(Flux::message('LoginHeading')) ?>

to show the user the word " Login " if he's using English language and show " Iniciar Sesión "  if he's using Español 

Any help to make it get the word from the language config file?

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0
On 5/14/2019 at 10:47 PM, Diana said:

I'm developing a multi-language FluxCP

And now in the Sub-menu items I can find that I can use only the word in one language that I can translate

An example : 

image.png

The login word If I want to translate it to the both English and Español 

If you looked here at application.conf you will find :- 

// Sub-menu items that are displayed for any action belonging to a
	// particular module. The format it simple.
		'account'		=> array(
			'login'			=> 'Login',
			'create'		=> 'Register',
			'resetpass'		=> 'Reset Password',
			'resend'		=> 'Resend E-mail Confirmation'
		),

I can't make it get the word from language config file ( It shows only the word " Login " ) 

Can I make it with php to get the word from the Language config file like :-  

<?php echo htmlspecialchars(Flux::message('LoginHeading')) ?>

to show the user the word " Login " if he's using English language and show " Iniciar Sesión "  if he's using Español 

Any help to make it get the word from the language config file?

I think the simple way to change main/submenu.php:
htmlspecialchars($menuItem['name']) to
htmlspecialchars(Flux::message('Submenu_'.$menuItem['module'].'_'.$menuItem['action'])

here we call messege from lang file for (module_name+action_name) like account+index = Submenu_account_index

<?php if (!defined('FLUX_ROOT')) exit; ?>
<?php $subMenuItems = $this->getSubMenuItems(); $menus = array() ?>
<?php if (!empty($subMenuItems)): ?>
	<div id="submenu"><?php echo htmlspecialchars(Flux::message('Submenu_name')) ?>:
	<?php foreach ($subMenuItems as $menuItem): ?>
		<?php $menus[] = sprintf('<a href="%s" class="sub-menu-item%s">%s</a>',
			$this->url($menuItem['module'], $menuItem['action']),
			$params->get('module') == $menuItem['module'] && $params->get('action') == $menuItem['action'] ? ' current-sub-menu' : '',
			htmlspecialchars(Flux::message('Submenu_'.$menuItem['module'].'_'.$menuItem['action']))) ?>
	<?php endforeach ?>
	<?php echo implode(' / ', $menus) ?>
	</div>
<?php endif ?>

and add in lang file that you need new lines like:

	'Submenu_name'							=> 'Menu',

	'Submenu_history_gamelogin'				=> 'Game Logins',
	'Submenu_history_cplogin'				=> 'CP Logins',
	'Submenu_history_emailchange'			=> 'E-Mail Changes',
	'Submenu_history_passchange'			=> 'Password Changes',
	'Submenu_history_passreset'				=> 'Password Resets',

	'Submenu_account_index'					=> 'List Accounts',
	'Submenu_account_view'					=> 'View Account',
	'Submenu_account_changepass'			=> 'Change Password',
	'Submenu_account_changemail'			=> 'Change E-mail',
	'Submenu_account_changesex'				=> 'Change Gender',
	'Submenu_account_transfer'				=> 'Transfer Credits',
	'Submenu_account_xferlog'				=> 'Credit Transfer History',
	'Submenu_account_cart'					=> 'Go to Shopping Cart',
	'Submenu_account_login'					=> 'Login',
	'Submenu_account_create'				=> 'Register',
	'Submenu_account_resetpass'				=> 'Reset Password',
	'Submenu_account_resend'				=> 'Resend E-mail Confirmation',

	'Submenu_guild_index'					=> 'List Guilds',
	'Submenu_guild_export'					=> 'Export Guild Emblems',

	'Submenu_server_status'					=> 'View Status',
	'Submenu_server_status-xml'				=> 'View Status as XML',

	'Submenu_logdata_branch'				=> 'Branches',
	'Submenu_logdata_char'					=> 'Characters',
	'Submenu_logdata_cashpoints'			=> 'CashPoints',
	'Submenu_logdata_chat'					=> 'Chat Messages',
	'Submenu_logdata_command'				=> 'Commands',
	'Submenu_logdata_feeding'				=> 'Feeding',
	'Submenu_logdata_inter'					=> 'Interactions',
	'Submenu_logdata_pick'					=> 'Item Picks',
	'Submenu_logdata_login'					=> 'Logins',
	'Submenu_logdata_mvp'					=> 'MVP',
	'Submenu_logdata_npc'					=> 'NPC',
	'Submenu_logdata_zeny'					=> 'Zeny',

	'Submenu_cplog_paypal'					=> 'PayPal Transactions',
	'Submenu_cplog_create'					=> 'Account Registrations',
	'Submenu_cplog_login'					=> 'Logins',
	'Submenu_cplog_resetpass'				=> 'Password Resets',
	'Submenu_cplog_changepass'				=> 'Password Changes',
	'Submenu_cplog_changemail'				=> 'E-mail Changes',
	'Submenu_cplog_ban'						=> 'Account Bans',
	'Submenu_cplog_ipban'					=> 'IP Bans',

	'Submenu_purchase_index'				=> 'Shop',
	'Submenu_purchase_cart'					=> 'Go to Cart',
	'Submenu_purchase_checkout'				=> 'Checkout',
	'Submenu_purchase_clear'				=> 'Empty Cart',
	'Submenu_purchase_pending'				=> 'Pending Redemption',

	'Submenu_donate_index'					=> 'Make a Donation',
	'Submenu_donate_history'				=> 'Donation History',
	'Submenu_donate_trusted'				=> 'Trusted PayPal E-mails',

	'Submenu_ipban_index'					=> 'IP Ban List',
	'Submenu_ipban_add'						=> 'Add IP Ban',

	'Submenu_ranking_character'				=> 'Characters',
	'Submenu_ranking_death'					=> 'Deaths',
	'Submenu_ranking_alchemist'				=> 'Alchemists',
	'Submenu_ranking_blacksmith'			=> 'Blacksmiths',
	'Submenu_ranking_homunculus'			=> 'Homunculus',
	'Submenu_ranking_mvp'					=> 'MVPs',
	'Submenu_ranking_guild'					=> 'Guilds',
	'Submenu_ranking_zeny'					=> 'Zeny',

	'Submenu_item_index'					=> 'List Items',
	'Submenu_item_add'						=> 'Add Item',
	'Submenu_item_iteminfo'					=> 'Add Item Info',

	'Submenu_pages_index'					=> 'Manage Pages',
	'Submenu_pages_add'						=> 'Add New Page',

	'Submenu_news_index'					=> 'Latest News',
	'Submenu_news_manage'					=> 'Manage',
	'Submenu_news_add'						=> 'Add News',

	'Submenu_servicedesk_staffindex'		=> 'View Active',
	'Submenu_servicedesk_staffviewclosed'	=> 'View Closed',
	'Submenu_servicedesk_staffsettings'		=> 'Staff Settings',
	'Submenu_servicedesk_catcontrol'		=> 'Category Control',

	'Submenu_vending_index'					=> 'Vendors',

	'Submenu_buyingstore_index'				=> 'Buyers',

and other for each action in modules...

Edited by Balfear

Share this post


Link to post
Share on other sites
  • 0
11 hours ago, Balfear said:

I think the simple way to change main/submenu.php:
htmlspecialchars($menuItem['name']) to
htmlspecialchars(Flux::message('Submenu_'.$menuItem['module'].'_'.$menuItem['action'])

here we call messege from lang file for (module_name+action_name) like account+index = Submenu_account_index

<?php if (!defined('FLUX_ROOT')) exit; ?>
<?php $subMenuItems = $this->getSubMenuItems(); $menus = array() ?>
<?php if (!empty($subMenuItems)): ?>
	<div id="submenu"><?php echo htmlspecialchars(Flux::message('Submenu_name')) ?>:
	<?php foreach ($subMenuItems as $menuItem): ?>
		<?php $menus[] = sprintf('<a href="%s" class="sub-menu-item%s">%s</a>',
			$this->url($menuItem['module'], $menuItem['action']),
			$params->get('module') == $menuItem['module'] && $params->get('action') == $menuItem['action'] ? ' current-sub-menu' : '',
			htmlspecialchars(Flux::message('Submenu_'.$menuItem['module'].'_'.$menuItem['action']))) ?>
	<?php endforeach ?>
	<?php echo implode(' / ', $menus) ?>
	</div>
<?php endif ?>

and add in lang file that you need new lines like:

	'Submenu_name'							=> 'Menu',

	'Submenu_history_gamelogin'				=> 'Game Logins',
	'Submenu_history_cplogin'				=> 'CP Logins',
	'Submenu_history_emailchange'			=> 'E-Mail Changes',
	'Submenu_history_passchange'			=> 'Password Changes',
	'Submenu_history_passreset'				=> 'Password Resets'

	'Submenu_account_index'					=> 'List Accounts',
	'Submenu_account_view'					=> 'View Account',
	'Submenu_account_changepass'			=> 'Change Password',
	'Submenu_account_changemail'			=> 'Change E-mail',
	'Submenu_account_changesex'				=> 'Change Gender',
	'Submenu_account_transfer'				=> 'Transfer Credits',
	'Submenu_account_xferlog'				=> 'Credit Transfer History',
	'Submenu_account_cart'					=> 'Go to Shopping Cart',
	'Submenu_account_login'					=> 'Login',
	'Submenu_account_create'				=> 'Register',
	'Submenu_account_resetpass'				=> 'Reset Password',
	'Submenu_account_resend'				=> 'Resend E-mail Confirmation'

	'Submenu_guild_index'					=> 'List Guilds',
	'Submenu_guild_export'					=> 'Export Guild Emblems'

	'Submenu_server_status'					=> 'View Status',
	'Submenu_server_status-xml'				=> 'View Status as XML'

	'Submenu_logdata_branch'				=> 'Branches',
	'Submenu_logdata_char'					=> 'Characters',
	'Submenu_logdata_cashpoints'			=> 'CashPoints',
	'Submenu_logdata_chat'					=> 'Chat Messages',
	'Submenu_logdata_command'				=> 'Commands',
	'Submenu_logdata_feeding'				=> 'Feeding',
	'Submenu_logdata_inter'					=> 'Interactions',
	'Submenu_logdata_pick'					=> 'Item Picks',
	'Submenu_logdata_login'					=> 'Logins',
	'Submenu_logdata_mvp'					=> 'MVP',
	'Submenu_logdata_npc'					=> 'NPC',
	'Submenu_logdata_zeny'					=> 'Zeny'

	'Submenu_cplog_paypal'					=> 'PayPal Transactions',
	'Submenu_cplog_create'					=> 'Account Registrations',
	'Submenu_cplog_login'					=> 'Logins',
	'Submenu_cplog_resetpass'				=> 'Password Resets',
	'Submenu_cplog_changepass'				=> 'Password Changes',
	'Submenu_cplog_changemail'				=> 'E-mail Changes',
	'Submenu_cplog_ban'						=> 'Account Bans',
	'Submenu_cplog_ipban'					=> 'IP Bans'

	'Submenu_purchase_index'				=> 'Shop',
	'Submenu_purchase_cart'					=> 'Go to Cart',
	'Submenu_purchase_checkout'				=> 'Checkout',
	'Submenu_purchase_clear'				=> 'Empty Cart',
	'Submenu_purchase_pending'				=> 'Pending Redemption'

	'Submenu_donate_index'					=> 'Make a Donation',
	'Submenu_donate_history'				=> 'Donation History',
	'Submenu_donate_trusted'				=> 'Trusted PayPal E-mails'

	'Submenu_ipban_index'					=> 'IP Ban List',
	'Submenu_ipban_add'						=> 'Add IP Ban'

	'Submenu_ranking_character'				=> 'Characters',
	'Submenu_ranking_death'					=> 'Deaths',
	'Submenu_ranking_alchemist'				=> 'Alchemists',
	'Submenu_ranking_blacksmith'			=> 'Blacksmiths',
	'Submenu_ranking_homunculus'			=> 'Homunculus',
	'Submenu_ranking_mvp'					=> 'MVPs',
	'Submenu_ranking_guild'					=> 'Guilds',
	'Submenu_ranking_zeny'					=> 'Zeny'

	'Submenu_item_index'					=> 'List Items',
	'Submenu_item_add'						=> 'Add Item',
	'Submenu_item_iteminfo'					=> 'Add Item Info',

	'Submenu_pages_index'					=> 'Manage Pages',
	'Submenu_pages_add'						=> 'Add New Page',

	'Submenu_news_index'					=> 'Latest News',
	'Submenu_news_manage'					=> 'Manage',
	'Submenu_news_add'						=> 'Add News',

	'Submenu_servicedesk_staffindex'		=> 'View Active',
	'Submenu_servicedesk_staffviewclosed'	=> 'View Closed',
	'Submenu_servicedesk_staffsettings'		=> 'Staff Settings',
	'Submenu_servicedesk_catcontrol'		=> 'Category Control',

	'Submenu_vending_index'					=> 'Vendors',

	'Submenu_buyingstore_index'				=> 'Buyers',

and other for each action in modules...

 

11 hours ago, Rododark said:

Umm has mirado en la carpeta (lang) es_es.php y se traduce todo a español 😉

Ejemplo: En  /config/application.php

busca y pones es_es 'DefaultLanguage'            => 'es_es',

I'm sorry but both not working with me 

@Balfear I tried what you typed but when reloading the page of account create it not load any thing from the page 

Any help?

Thank you for your replies ❤️

 

Share this post


Link to post
Share on other sites
  • 0
49 minutes ago, Diana said:

 

I'm sorry but both not working with me 

@Balfear I tried what you typed but when reloading the page of account create it not load any thing from the page 

Any help?

Thank you for your replies ❤️

 

Oh, sorry i don`t test it before post, now it works >_<
I fix errors, and update post.
And here updated files:
/lang/submenu.php
/themes/default/main/es_es.php <= need to translate new lines in the end of file

Edited by Balfear

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...