BBCode with Language Variable

Get help developing custom BBCodes or request one.
Post Reply
Tarantino
Registered User
Posts: 874
Joined: Sat Feb 18, 2012 1:51 pm

BBCode with Language Variable

Post by Tarantino »

Hi there, is it possible to use language variables on the creation of a BBCode? That way the help text could be multi-language as the title html atribute.

Best regards
User avatar
JoshyPHP
Code Contributor
Posts: 1288
Joined: Mon Jul 11, 2011 12:28 am

Re: BBCode with Language Variable

Post by JoshyPHP »

Can you provide an example of the thing?
I wrote the library that handles markup in phpBB 3.2+.
Tarantino
Registered User
Posts: 874
Joined: Sat Feb 18, 2012 1:51 pm

Re: BBCode with Language Variable

Post by Tarantino »

Sure.
Example:

Right now I've this:
BBCode: [anchor={INTTEXT1} goto={INTTEXT2}]{TEXT}[/anchor]
HTML: <a id="quoted{INTTEXT1}" href="#quoted{INTTEXT2}" class="anchor postlink-local" title="Go to Anchor {INTTEXT2}">{TEXT}</a>
Explanation: [anchor=Identifier goto=Identifier] Some Text [/anchor]

But I wanted to know how can I've something like this:
BBCode: [anchor={INTTEXT1} goto={INTTEXT2}]{TEXT}[/anchor]
HTML: <a id="quoted{INTTEXT1}" href="#quoted{INTTEXT2}" class="anchor postlink-local" title="{L_LANGUAGE_VARIABLE_1} {INTTEXT2}">{TEXT}</a>
Explanation: [anchor={L_LANGUAGE_VARIABLE_2}goto={L_LANGUAGE_VARIABLE_3}] {L_LANGUAGE_VARIABLE_4} [/anchor]

And in some file, maybe language/common.php? we could add the {L_LANGUAGE_VARIABLE_1} so it would appear Go to Anchor for users with english language and in another language if we've a different one. :)
User avatar
JoshyPHP
Code Contributor
Posts: 1288
Joined: Mon Jul 11, 2011 12:28 am

Re: BBCode with Language Variable

Post by JoshyPHP »

I didn't know how that was handled within phpBB so I searched for bbcode_helpline in the source and it seems like it's already supported in a way. The whole helpline is replaced if it matches a translatable string. It's in display_custom_bbcodes()
I wrote the library that handles markup in phpBB 3.2+.
Tarantino
Registered User
Posts: 874
Joined: Sat Feb 18, 2012 1:51 pm

Re: BBCode with Language Variable

Post by Tarantino »

Just the helpline then, the html it dont get replaced? I'll make some tests soon on a test forum when I've more time.
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco
Contact:

Re: BBCode with Language Variable

Post by 3Di »

ACP

BBcode helpline: MY_LANG_KEY (uppercase)

Lang file, IE.: my_ext_common.php

Code: Select all

'MY_LANG_KEY'		=>	'[anchor=Identifier goto=Identifier] Some Text [/anchor]',
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
ViolaF
I've Been Banned!
Posts: 1609
Joined: Tue Aug 14, 2012 11:52 pm

Re: BBCode with Language Variable

Post by ViolaF »

This little example should do it:
viewtopic.php?p=12861373#p12861373

So each switching (and all php) is possible in BBCodes and {LANG_VARIBLES} ...
User avatar
ViolaF
I've Been Banned!
Posts: 1609
Joined: Tue Aug 14, 2012 11:52 pm

Re: BBCode with Language Variable

Post by ViolaF »

'lol - 3Di was faster ...
Tarantino
Registered User
Posts: 874
Joined: Sat Feb 18, 2012 1:51 pm

Re: BBCode with Language Variable

Post by Tarantino »

3Di wrote: Sat Jan 13, 2018 5:53 pm ACP

BBcode helpline: MY_LANG_KEY (uppercase)

Lang file, IE.: my_ext_common.php

Code: Select all

'MY_LANG_KEY'		=>	'[anchor=Identifier goto=Identifier] Some Text [/anchor]',
Just that without { } ? And without the L_ ? is that it?

And about the HTML, do you know something about it?
User avatar
ViolaF
I've Been Banned!
Posts: 1609
Joined: Tue Aug 14, 2012 11:52 pm

Re: BBCode with Language Variable

Post by ViolaF »

Code: Select all

'MY_LANG_KEY'		=>	'[anchor=Identifier goto=Identifier] Some Text [/anchor]',
Just vice versa: 'MY_LANG_KEY' is {L_MY_LANG_KEY} in BBCode
User avatar
ViolaF
I've Been Banned!
Posts: 1609
Joined: Tue Aug 14, 2012 11:52 pm

Re: BBCode with Language Variable

Post by ViolaF »

ACP > POSTING > BBCodes > [Add a new BBCode] wrote:
Within the HTML replacement you can also use any language string present in your language/ directory like this: {L_<STRINGNAME>} where <STRINGNAME> is the name of the translated string you want to add. For example, {L_WROTE} will be displayed as "wrote" or its translation according to user’s locale.
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco
Contact:

Re: BBCode with Language Variable

Post by 3Di »

Tarantino wrote: Sat Jan 13, 2018 6:14 pm
3Di wrote: Sat Jan 13, 2018 5:53 pm ACP

BBcode helpline: MY_LANG_KEY (uppercase)

Lang file, IE.: my_ext_common.php

Code: Select all

'MY_LANG_KEY'		=>	'[anchor=Identifier goto=Identifier] Some Text [/anchor]',
Just that without { } ? And without the L_ ? is that it?

And about the HTML, do you know something about it?
As it is.

About the HTML, you should be able to use Twig

title="{{ lang('MY_LANG_KEY') }}"
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
ViolaF
I've Been Banned!
Posts: 1609
Joined: Tue Aug 14, 2012 11:52 pm

Re: BBCode with Language Variable

Post by ViolaF »

Yes, twig is the future, so we can use it instead.
Tarantino
Registered User
Posts: 874
Joined: Sat Feb 18, 2012 1:51 pm

Re: BBCode with Language Variable

Post by Tarantino »

I see, it makes sense. In the HTML the HTML syntax works, in the helpline just the text works. Perfect! I'll try soon. Thank you for the information. I'm glad that this works :)
Post Reply

Return to “Custom BBCode Development and Requests”