EnzoC Posted May 8, 2018 Author Posted May 8, 2018 3 hours ago, Aiwa said: Since I'm a nice guy, I'll throw you a bone. 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. In the %s replacement, there is a space in front, even though it doesn't look like it in the AdminCP. <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?
EnzoC Posted May 8, 2018 Author Posted May 8, 2018 Just now, Martin A. said: How on earth did you read that from @Aiwa's reply?? Explain it to me, let's do it first.
Martin A. Posted May 8, 2018 Posted May 8, 2018 I'm not going to explain you anything, it clearly doesn't work.
Aiwa Posted May 8, 2018 Posted May 8, 2018 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.
Martin A. Posted May 8, 2018 Posted May 8, 2018 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 .".
EnzoC Posted May 8, 2018 Author Posted May 8, 2018 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.
Martin A. Posted May 8, 2018 Posted May 8, 2018 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...
Aiwa Posted May 8, 2018 Posted May 8, 2018 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.
EnzoC Posted May 8, 2018 Author Posted May 8, 2018 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?
Aiwa Posted May 8, 2018 Posted May 8, 2018 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.
EnzoC Posted May 8, 2018 Author Posted May 8, 2018 Ok, I thank you, but now I'm going to bed, here in Italy it's 1:25. Hello
Recommended Posts
Archived
This topic is now archived and is closed to further replies.