Posted: September 18, 2020 at 10:54 am
September 18, 2020 at 10:54 am Greetings – I have a “gettext” filter in my plugin php code used to change some of the text on the EE pages. The text strings seem to support certain codes to do things like start a new line, add an asterisk, etc. Do you have a list of all these code that are supported? I am trying to add a blank line, add bold, and add underlining to one of my text strings and can’t get any of them to work. At a minimum can you tell me what codes I need to insert for these OR give me a complete list of the codes that gettext supports? Thanks in advance – Mark |
|
Hi Mark, It’s not gettext that is providing those string replacements, its sprintf() but again, its not the function itself that support specific strings, it’s whatever is passed into the function as part of the call. To explain a little better, here’s an example I’ve just pulled from EE’s codebase:
The only thing there that is passed to gettext is Then sprint off parses the string and replaces the placesholders for the the strings (we use HTML but it doesn’t need to be) in the order the places holders are in the string (or you can define the order yourself). So in this example, the first placeholder is The 1st string passed to sprintf is This is basically an easier way to allow translations to include HTML in the string without translations breaking the HTML itself. — So to answer your question:
No, because that’s no how it works. If you have a string that already has those strings passed into it in a different order than you want you can use them in different locations within the string but you can’t pass anything into the string itself to automatically create them, unless you add the HTML tags into the string itself. Which specific string is this? |
|
September 21, 2020 at 12:31 pm The specific string that I am trying to get to display correctly is this one: FROM THIS: TO THIS BUT I want a blank line between the 1st sentence and the 2nd/3rd sentence AND I would like the 2nd/3rd sentences to be in Bold. So I want it to look like this on-screen: In order to initiate a profile, please complete all of the fields below. Refer to the instructions in Success Factors for the code. The code is CaSe SeNsItIvE. Make sense? |
|
September 21, 2020 at 12:47 pm So if you search for that original string in the codebase you’ll get:
The first additional parameter passed to sprintf() is
Note the above is untested. |
|
Close. The blank line is now displaying but the strong tags are printing out literally like this: ********* Refer to the instructions in Success Factors for the code. The code is CaSe SeNsItIvE. I don’t see any info on the net about putting html tags in sprintf statements. |
|
So to find these original strings do you always just look in the source code for them? For example for this one I did a search and found it in the file EE_SPCO_Reg_step_Attendee_Information.class.php on line 72 in the method translate_js_strings(). There is shows the extra space in the beginning (which I did not think needed to be included, but it does obviously. Is this how you do it? That worked by the way THANKS!!! |
|
In that case you wont be able to use them in that string.
Huh? Why would you find info on it with sprintf?
Yes, I search for a partial string and find it from there.
The string you input for translation must match exactly, it’s the reason I prefer to search the source for them as you can easily spot spaces etc.
Yep and you’re welcome 🙂 |
|
The support post ‘Is there a list of the "gettext" filter codes that are used within the strings?’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.