Custom BBCodes localization

Discussion of general topics related to the new version and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
Forum rules
Discussion of general topics related to the new release and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
Post Reply
User avatar
-=ET=-
Registered User
Posts: 211
Joined: Mon May 26, 2003 1:35 pm
Location: France

Custom BBCodes localization

Post by -=ET=- » Mon Aug 17, 2009 10:06 pm

Hi,

I hope it's the best place to post this suggestion, otherwise just tell me where I should post it :)

My concern is that following the installation of some few custom BBCodes, I wanted (like for "Font colour") to be able to...
  1. choose a different button label than the BBCode tag,
  2. localize the button label,
  3. and localize the button help line.
So I've posted a request here...
http://www.phpbb.com/community/viewtopi ... &t=1743555
...but in fact it seems it's not possible by default, but easy to implement.

That's why I'm posting this suggestion here :)

In fact, in includes/functions_display.php, we can find...

Code: Select all

            'BBCODE_TAG'        => $row['bbcode_tag'],
            'BBCODE_HELPLINE'    => $row['bbcode_helpline'],  
...and replace these 2 lines with...

Code: Select all

            'BBCODE_TAG'        => ($user->lang['BBCODE_'.strtoupper($row['bbcode_tag'])]) ? $user->lang['BBCODE_'.strtoupper($row['bbcode_tag'])] : $row['bbcode_tag'],
            'BBCODE_HELPLINE'    => ($user->lang['BBCODE_'.strtoupper($row['bbcode_tag']).'_HELP']) ? $user->lang['BBCODE_'.strtoupper($row['bbcode_tag']).'_HELP'] : $row['bbcode_helpline'],  
That's all! :)

By default nothing changes, as if no specific language string exists, it will continue to take what is set in the ACP. But it allows admins to add 2 new language strings by custom BBCode in the posting.php language file of each language...
  • BBCODE_<BBCODE_TAG> where <BBCODE_TAG> is the tag in upper case set in the ACP
  • BBCODE_<BBCODE_TAG>_HELP where <BBCODE_TAG> is the tag in upper case set in the ACP
Example: if you have installed the YouTube custom BBCode, you must have set "[youtube]{IDENTIFIER}[/youtube]" in "BBCode usage". So your tag is "youtube" (all in lower case).

Then for English, you can add the 2 new strings in language/en/posting.php...
  • BBCODE_YOUTUBE => 'YouTube', (using capital letters if you want)
  • BBCODE_YOUTUBE_HELP => 'YouTube video: do this, do that...',
For French the 2 new strings in language/fr/posting.php...
  • BBCODE_YOUTUBE => 'YouTube',
  • BBCODE_YOUTUBE_HELP => 'Vidéo YouTube: faites ceci, faites celà...'
And so on for other languages...

Easy :)

I hope it can be added in a future release.
Thanks!
Eternal newbie

User avatar
ToonArmy
Registered User
Posts: 335
Joined: Fri Mar 26, 2004 7:31 pm
Location: Bristol, UK
Contact:

Re: Custom BBCodes localization

Post by ToonArmy » Tue Aug 18, 2009 12:26 pm

Helpline is already able to be localised.

Code: Select all

        // If the helpline is defined within the language file, we will use the localised version, else just use the database entry...
        if (isset($user->lang[strtoupper($row['bbcode_helpline'])]))
        {
            $row['bbcode_helpline'] = $user->lang[strtoupper($row['bbcode_helpline'])];
        } 
Chris SmithBlogXMOOhlohArea51WikiNo support via PM/IM
Image

User avatar
-=ET=-
Registered User
Posts: 211
Joined: Mon May 26, 2003 1:35 pm
Location: France

Re: Custom BBCodes localization

Post by -=ET=- » Tue Aug 18, 2009 12:57 pm

ToonArmy wrote:Helpline is already able to be localised.
Ooops, my fault, I didn't look at these lines above.
Thanks!

So I see how you've done.
Then, why not considering to add an extra field on the ACP BBCode form, called "Button label"?

In this case, same, people would have the possibility to set a language string as field value, and then localize their custom BBCode buttons :)
Eternal newbie

code reader
Registered User
Posts: 653
Joined: Wed Sep 21, 2005 3:01 pm

Re: Custom BBCodes localization

Post by code reader » Fri Sep 11, 2009 7:55 pm

-=ET=- wrote:Then, why not considering to add an extra field on the ACP BBCode form, called "Button label"?

In this case, same, people would have the possibility to set a language string as field value, and then localize their custom BBCode buttons :)
i absolutely agree that this makes sense. in reality, this is something suggested (by myself, among other people) back when custom bbcode was introduced.
this simple addition would actually enable making eliminating most of the "normal" bbcodes (the only reason why we can't use, say, "bold", italics or underlined as custom bbcodes is because currently we can't have the button be bold or italics - allowing a separate label in the DB, will enable you to use html tags as part of the label).

taking it a tiny step further, we should also allow for *image* buttons. again, by having the button label/image defined separately from the bbcode code will allow that.

localization is a bit tricky, though, because the text and help should not come from the XX/*.php files (where XX is the language), but rather from the DB, so with a multilingual site, when creating a new bbcode one would need to manually enter a label per language. sensible implementation will require a new table with 4 columns (bbcode code, language, description, helpline)

Post Reply