My First Addon

Posts from previous Beta sessions

My First Addon

Postby nightfighter » Thu Aug 23, 2007 11:05 pm

I have started working on building my first addon. I am looking at the code for this and wondering how I go about making the installation text that goes on the addon install page multi-lingual. When I try to use a $lang entry, I get:

Parse error: syntax error, unexpected T_GLOBAL, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/worldofw/public_html/roster200/addons/guildstats/inc/install.def.php on line 30

If I put in a line that says:

global $lang;

With it not there, I get:

Parse error: syntax error, unexpected T_VARIABLE in /home/worldofw/public_html/roster200/addons/guildstats/inc/install.def.php on line 39

which says:

var $fullname = $lang['guildstats_fullname']; // 'Guild Statistics';


Is it not doable? Is there a different way I need to do it? Thanks for any help in this.
User avatar
nightfighter
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 169
Joined: Wed Jul 05, 2006 11:25 pm
Location: Boise, Idaho, USA

My First Addon

Postby zanix » Fri Aug 24, 2007 12:45 am

These values are entered into the db and are meant to be static
You cannot use a variable to set a declared class variable

However, you can set this in the class constructor
Code: Select all
$this->fullname = $roster->locale->act['guildstats_fullname'];

But this is entered in the db and will be set to whatever locale Roster is in when the addon is installed


We could probably enable you to use locale keys there, like we do with the button names
So you could use
Code: Select all
$this->fullname = 'guildstats_fullname';

Which would try to use this locale key
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

My First Addon

Postby nightfighter » Fri Aug 24, 2007 5:25 am

I think most of us would like to be able to use the locale keys for this information so that the screen will change based on the current local. It is possible the person running the system does not know English and would have trouble setting up the addon because of it. I would not even mind if you put something in the string that identifies it as a locale key.
User avatar
nightfighter
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 169
Joined: Wed Jul 05, 2006 11:25 pm
Location: Boise, Idaho, USA

My First Addon

Postby ds » Fri Aug 24, 2007 5:34 am

If you use the $roster->locale->act['localized_string'] object method it will return the localized string for the currently selected language.

I think of "act" as "Active Language".
Image
ds
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 297
Joined: Sat Jul 08, 2006 9:58 am

My First Addon

Postby nightfighter » Sun Aug 26, 2007 8:08 am

Well, I tried out your suggestion and it seems the locale files for the addon are not accessed when displaying the list of addon's available. It does not load them if they are on or off.

I tested this by putting an echo into the files showing the area of the code I am working in. The one from the constructor is showing, but not the one from the locale file.
User avatar
nightfighter
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 169
Joined: Wed Jul 05, 2006 11:25 pm
Location: Boise, Idaho, USA

My First Addon

Postby zanix » Sun Aug 26, 2007 9:17 am

I have made a change in the svn so you can use locale keys for the fullname and description variables

Code: Select all
var $fullname = 'guildstats_fullname';

Will be converted to
Code: Select all
$roster->locale->act['guildstats_fullname']


If the locale key isn't found, then it outputs it directly
Code: Select all
var $fullname = 'Guild Stats';

Will display 'Guild Stats'

All the addons in roster are already converted to use this.
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

My First Addon

Postby nightfighter » Sun Aug 26, 2007 9:46 am

Cool, thanks for the help.
User avatar
nightfighter
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 169
Joined: Wed Jul 05, 2006 11:25 pm
Location: Boise, Idaho, USA

My First Addon

Postby zanix » Sun Aug 26, 2007 10:13 am

No, thank you
I didn't even think of enabling this to be localized
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

My First Addon

Postby ds » Sun Aug 26, 2007 1:34 pm

beta testing 4tw :)
Image
ds
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 297
Joined: Sat Jul 08, 2006 9:58 am


Return to Archived

Who is online

Users browsing this forum: No registered users and 0 guests

cron