When using Text::_() I often find I want a space before or after the translated string when it is not possible to use Text::sprintf()` - for example when using two successive translations to make a composite phrase.
echo Text::_('FOO').' '.Text::_('BAR');
Of course you could simply make a separate translation string for each specific case but that seems like a lot of unnecessary effort. Under J3 you were allowed to have a space at the end of a string, but not any longer.
Equally when the words or values being joined are coming from variables echo $foo.' '.$bar; it would be nice just to set a flag that they should be joined with a space.
Or another case I often find I have a language string defined as XB_FOO="bar" and I want it echoed with an initial capital "Bar". Yes, you can simply echo lcfirst(Text::_('FOO'); but it would be simpler to just have an flag parameter to Text::_() to tell it make make an initial capital, or all uppercase, or the opposite. Likewise often I want to enclose a variable in single or double quotes, or if writing it to a file follow it with a newline.
So I have made an alternative Helper class to use instead of Text::_() called Xbtext::_() which takes a bitmapped value as a second parameter to modify or add to the simple language translation.
Comments powered by CComment