PDA

View Full Version : Add And Use Custom Phrase Type.


deathemperor
30 May 2006, 17:12
How to add

Simple, just use these 2 lines in your install code, it will add a new phrase type with phrasegroup_name = tm_phrase, phrasegroup_title = trademanager and productid as trademanager.

require_once(DIR . '/includes/adminfunctions_language.php');
add_phrase_type('tm_phrase', 'Trade Manager', 'trademanager');

The function reads

/**
* Allows plugins etc. to add a phrasetype easily
*
* @param string Phrasetype name
* @param string Phrasetype title
* @param string Product ID
*
* @return mixed If insert succeeds, returns inserted phrasetypeid
*/
function add_phrase_type($phrasegroup_name, $phrasegroup_title, $productid = 'vbulletin')


How to use

In your script, after:

// ################### PRE-CACHE TEMPLATES AND DATA ######################

include this this line // get special phrase groups
$phrasegroups = array('tm_phrase');

tm_phrase is the phrasegroup_name that you added as above.

Now you can use the phrases from "Trade Manager" phrase group to your script.

How this helps ?
I can think of these for now:
- Prevent spamming the global phrases, make it getting bigger and bigger.
- Easier to manage. Because it's your own custom phrases ;)
- Make your product more like a product :P.

Notice
- These phrases can only use to replace global phrase. Meaning, instead of create all of them and put to Global phrase, you put it in your own group. So if you want to use them for Permissions, Error Messages, etc. you simply can't.

Correct me if I missed something.

Have fun.

wiritten by deathemperor @ www.holvn.org

lightwave
20 Jul 2006, 17:30
really great modification. i used it myself.

FractalizeR
14 Nov 2006, 11:21
I have some questions:

1. How to completely delete all phrases of my plugin on uninstallation? Is this done automatically?
2. So if you want to use them for Permissions, Error Messages, etc. you simply can't.
Could you please explain, what this means? What do you mean under "Permissions, Error messages"?

BTW, isn't add_phrase_type deprecated yet? As I can see, for example psiStats addon for VB does not use this function, but still uses custom phrases

deathemperor
14 Nov 2006, 19:19
1. Yes when: for example when you add a phrase, you choose a product it belongs to then when the product uninstalled the phrases belong to that product will be removed too.

2. I haven't found a way to add custom phrases for Permission, Error Messages, etc (which are some phrase types). So currently it's only possible to add global phrases. The psiStats may use queries in its product installation files (xml for example). add_phrase_type just do the same, it also runs queries but it's written by vbulletin development staves so what would you choose ?

FractalizeR
19 Nov 2006, 11:23
Thanks :) Now I understand.

steadicamop
26 Nov 2006, 00:51
include this this line // get special phrase groups
$phrasegroups = array('tm_phrase');

I'm not sure if I'm missing something really simple here - but this lot doesn't seem to work for me - where can you add the $phrasegroups to? I have tried the php file I have and inside the plugin - but just not working, none of my phrases show ... would love to be able to separate them out.

Thanks

Jason

deathemperor
26 Nov 2006, 23:45
actually I only tried it for new files. you can see it on vbulletin files, it's placed before everything (almost).

I think it will work on plugin if you use array_merge, I will try it myself.

testbot
24 Oct 2009, 19:32
is there away to add a translation? i want to append some txt to an existing phrase.