Jump to content

Can you explain the difference?


EnzoC

Recommended Posts

Posted
3 hours ago, Aiwa said:

Since I'm a nice guy, I'll throw you a bone.   

1820684442_Monosnap2018-05-0810-29-37.png.1edd6f9b22cba2fcfbd2d62c6c7c1a46.png

There is a space there because the %s is an imploded array of secondary group names that is programmatically generated. 


// Creates an array of the new groups.
$k = explode( ',', $jsonValue['data']['new'] );

/**
	 * Format List
	 * Takes an array and returns a string, appropriate for the language (e.g. "a, b and c")
	 *
	 * Relies on the _list_format_ language string which should be an example list of three items using the keys a, b and c.
	 * Any can be capitalised to run ucfirst on that item
	 *
	 * Examples if $items = array( 'foo', 'bar', 'baz', 'moo' );
	 *	If _list_format_ is this:			Output will be this:
	 *	a, b and c							foo, bar, baz and moo
	 *	A, B und C							Foo, Bar, Baz und Moo
	 *	a; b; c.							foo; bar; baz; moo.
	 *
	 * @param	array	$items	The items for the list
	 * @param	string	$format	If provided, will override _list_format_
	 * @return	string
	 */
	public function formatList( $items, $format=NULL )

//Formats that array into a string
$new = \IPS\Member::loggedIn()->language()->formatList( $k );
return \IPS\Member::loggedIn()->language()->addToStack( 'history_group_legacy_mgroup_others', FALSE, array( 'htmlsprintf' => array( $new ) ) );

Secondary groups set to group1, group2, group3 (In English)

For the latter.

1822091961_Monosnap2018-05-0810-27-27.png.0b355b9c66301d25f0ffb5d5873e12f7.png

In the %s replacement, there is a space in front, even though it doesn't look like it in the AdminCP.  

1484560225_Monosnap2018-05-0810-38-04.png.e8754dc633a3038ca627ea4fde8d3125.png

1140678164_Monosnap2018-05-0810-37-42.png.e44d28d0cbf8115b97b2f0278095b355.png


<word key="history_by_admin" js="0"> by %s</word>
<word key="history_by_member" js="0"> by member</word>

$byMember = \IPS\Member::loggedIn()->language()->addToStack('history_by_member');
$byStaff = \IPS\Member::loggedIn()->language()->addToStack('history_by_admin', FALSE, array( 'sprintf' => array( \IPS\Member::load( $row['log_by'] )->name ) ) );

//Takes your language string and tacks on either ' by member' or ' by <admin name>' 
return \IPS\Member::loggedIn()->language()->addToStack( $jsonValue['optout'] ? 'history_mfa_optout' : 'history_mfa_optin', FALSE, array( 'sprintf' => array( $byMember ?: $byStaff ) ) );

So, you wanted an explanation of the difference... There you go.  The replacement string for the former is a code generated list of values where adding the space would have to be manually done via the code.  The latter is the insertion of yet another language string where the space can be added via the replacement string.

It ultimately comes down to where IPS decides to squeeze the balloon, put it in the first string, or put it in the second string. 

Now, had you given me that information when I asked for it the first time, or even the second or third, this conversation would have gone a WHOLE lot smoother.  But alas, you ignorance of why I asked for those details and your assumption that my questions where meaningless now shines bright. 

Good day. 

In practice you are telling me that IPS was wrong to insert the symbol %s attached and that I should unplug it in AdminCP? Did I get it right?

Posted
12 minutes ago, EnzoC said:

In practice you are telling me that IPS was wrong to insert the symbol %s attached and that I should unplug it in AdminCP? Did I get it right?

No, IPS was neither right or wrong. They chose a method, and I'd hope it's consistent throughout the suite. 

The space MUST exist in ONE of the two strings. Picking which is neither right nor wrong, it's making a decision. 

Posted
10 minutes ago, Aiwa said:

No, IPS was neither right or wrong. They chose a method, and I'd hope it's consistent throughout the suite. 

The space MUST exist in ONE of the two strings. Picking which is neither right nor wrong, it's making a decision.  

This is precisely the problem, because the Italian language is very special and does not allow mistakes. This time you have been clear and I thank you.

9 minutes ago, Martin A. said:

The space isn't there in "history_mfa_optin" because the replacement string can be empty. Then the printed string would be "Opt out from two factor authentication reset .".

Sorry, but then what's the point of adding the %s symbol to the afine, I'm really confused in this case.

Posted

It can be empty, not saying that it always is or always isn't. But in some cases, like old display name records, %s will be empty, as there is no record of who created the log entry.

 

And I wasn't supposed to be sucked into this...

Posted
1 hour ago, EnzoC said:

Sorry, but then what's the point of adding the %s symbol to the afine, I'm really confused in this case.

For the Opt out reset, IPS is using up to 2 language strings to construct the sentence.

Opt out of two factor authentication reset%s.

For an older log where it is undetermined if the reset was done by the user or an admin, the %s is replaced with an empty string. Thus simply removing %s from the string entirely. 

When it is known who has performed the reset, a second language string is put in place of the %s. Since the first language bit is designed to work with an empty string, when there IS a replacement, the space MUST be added by the replacement. 

 

Posted
47 minutes ago, Aiwa said:

For the Opt out reset, IPS is using up to 2 language strings to construct the sentence.

Opt out of two factor authentication reset%s.

For an older log where it is undetermined if the reset was done by the user or an admin, the %s is replaced with an empty string. Thus simply removing %s from the string entirely. 

When it is known who has performed the reset, a second language string is put in place of the %s. Since the first language bit is designed to work with an empty string, when there IS a replacement, the space MUST be added by the replacement.  

 

Excuse me, but if I understand correctly depends on how the language is set in AdminCP?

Posted
6 minutes ago, EnzoC said:

Excuse me, but if I understand correctly depends on how the language is set in AdminCP?

Yes, if the order structure of the sentence is different in your language then you'd need to adjust where the space is accordingly to accommodate the scenario described. 

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...