Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
538 views
in Q2A Core by
edited by

Hi - my first question here.

I'm trying to get my head around some sections of the code to help me resolve some localization issues. There's this function I'd like to understand the purpose of - which would save me time peering into the source code.

The function is:

qa_lang_html_sub($identifier, $htmlparam, $symbol='^')

I see it splitting a message into an array of 3 segments, which are then assigned to a data structure and passed to the theme layer.  But then what - what's the purpose of splitting the message into 3 segments?
Regards - Basel Shishani

 

Correction:

The function is actually:

qa_lang_html_sub_split(...)

as pointed out by Gideon in his answer.

 

1 Answer

+1 vote
by

Actually, it's qa_lang_html_sub_split(...) that splits into 3 sections.

The purpose is to allow a language independent way to combine some data (e.g. a time gap, in bold below) with some padding around that data. For example:

3 days ago (English)

il ya 3 jours (French)

In some languages, the padding comes before the data, and in some languages, it comes after. Some might even have padding on either side. By splitting into 3 sections, the padding can be set in the language string, and everything is passed through as appropriate to the theme layer, in which the output_split(...) function is used to generate the final HTML.

by
Of course the order within the message, or padding as you call it is what we use  placeholders for. But in this case you want to use three different styles for prefix-data-suffix. So for messages with a value placeholders and with a single type of style you use qa_lang_html_sub(...), and for messages with a value placeholder and where you are applying 3 (at most) styles you use qa_lang_html_sub_split(...) - am reading you correctly?! What I'm trying to stay is that this function is not needed to control the order of the value within the message as this is already achieved by qa_lang_html_sub(...), rather you want to control the styling of the segments of the message.
by
Correct. It's there to allow different CSS styling for the data, and for the padding around it.
...