Addon Locale Parsing

Download, Present, and receive support for third party WoWRoster AddOns and modifications
WoWRoster AddOns and Mods are supported by the author only
Please understand that some AddOns and Mods may require advanced skills to employ

Addon Locale Parsing

Postby mdeshane » Fri Feb 15, 2008 9:06 pm

Ok, in working on the Accounts addon after the addition of the menu login, I noticed that when I'm not in an accounts page on the roster, my locale strings are not parsed, causing the User Name wording to disappear and a undefined index notice to appear. Do we have a roster function to get a specific addon's locale strings that I haven't seen? If not can we add one? Or will I have to include my locale files in the getMenuLoginForm function?
Image
Accounts Addon - Roster v2 User Account Addon

PKC Dev Site - http://dev.pkcomp.net
My Roster Dev Site - http://myroster.dontexist.net
User avatar
mdeshane
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 203
Joined: Sun Dec 10, 2006 4:54 am
Location: Grand Rapids, MI USA
Realm: Khadgar (PvE) - US

Re: Addon Locale Parsing

Postby Gaxme » Fri Feb 15, 2008 11:17 pm

Hmm, I'd guess you can probably still pull it out of the $roster->locale->wordings['locale'] strings, but I'm not certain about that...
Gaxme
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 74
Joined: Mon Jul 10, 2006 3:54 am

Addon Locale Parsing

Postby zanix » Sat Feb 16, 2008 3:46 am

No, there is no way currently to get a certain string from an addon when the addon is not active in Roster
We could probably include this ability

$roster->locale->getString('key','basename');

How does that sound other devs?
Last edited by zanix on Sat Feb 16, 2008 3:46 am, edited 1 time in total.
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: 5543
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

Addon Locale Parsing

Postby mdeshane » Sun Feb 17, 2008 6:00 am

That function would work perfectly. I hope the other devs think it would be a good addition. I could think of other uses for this, like grabbing the locale strings from the memberslist addon.
Image
Accounts Addon - Roster v2 User Account Addon

PKC Dev Site - http://dev.pkcomp.net
My Roster Dev Site - http://myroster.dontexist.net
User avatar
mdeshane
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 203
Joined: Sun Dec 10, 2006 4:54 am
Location: Grand Rapids, MI USA
Realm: Khadgar (PvE) - US

Addon Locale Parsing

Postby Anaxent » Sun Feb 17, 2008 8:00 am

Sounds like a good idea to me
User avatar
Anaxent
WoWRoster.net Dev Team
WoWRoster.net Dev Team
 
Posts: 642
Joined: Tue Jul 04, 2006 6:27 am
Location: Phoenix, Az

Addon Locale Parsing

Postby zanix » Sun Feb 17, 2008 9:48 am

To be added in the next svn commit

Code: Select all
    /**
     * Method to get a locale string using the passed key/addonname/locale
     * Pass a key to return the desired locale string
     * If addonname is not passed, it will return $roster->locale->wordings[$locale][$key]
     * If locale is not passed, it will default to the current locale setting
     *
     * @param string $key | Locale string to return
     * @param string $addon | Addon to search key
     * @param string $locale | Locale to search key
     * @return string
     */
    
function get_string$key $addon='' $locale='' )
    {
        if( 
$locale == '' )
        {
            
$locale $this->curlocale;
        }

        
$lang '';
        if( 
$addon != '' )
        {
            
$localefile ROSTER_ADDONS $addon DIR_SEP 'locale' DIR_SEP $locale '.php';

            if( 
file_exists($localefile) )
            {
                include(
$localefile);
            }
            else
            {
                
$enUSfile str_replace($locale '.php','enUS.php',$localefile);
                if( 
file_exists($enUSfile) )
                {
                    include(
$enUSfile);
                }
            }
        }

        if( isset(
$lang[$key]) )
        {
            return 
$lang[$key];
        }
        elseif( isset(
$this->wordings[$locale][$key]) )
        {
            return 
$this->wordings[$locale][$key];
        }
        elseif( isset(
$this->act[$key]) )
        {
            return 
$this->act[$key];
        }
        else
        {
            return 
'';
        }
    } 
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: 5543
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

Addon Locale Parsing

Postby PleegWat » Sun Feb 17, 2008 4:42 pm

suggested: $lang = array(); instead of $lang = '', to prevent a notice error when loading roster strings.

Return $key rather than '' if the string isn't found at all (This is default behaviour in memberslist).
I <3 /bin/bash
User avatar
PleegWat
WoWRoster.net Dev Team
WoWRoster.net Dev Team
 
Posts: 1636
Joined: Tue Jul 04, 2006 1:43 pm

Addon Locale Parsing

Postby zanix » Mon Feb 18, 2008 12:51 am

Good idea
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: 5543
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

Addon Locale Parsing

Postby mdeshane » Mon Feb 18, 2008 3:29 am

The new function works beautifully! Thanks guys! I hope the rest of the developer community here finds this useful too.
Image
Accounts Addon - Roster v2 User Account Addon

PKC Dev Site - http://dev.pkcomp.net
My Roster Dev Site - http://myroster.dontexist.net
User avatar
mdeshane
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 203
Joined: Sun Dec 10, 2006 4:54 am
Location: Grand Rapids, MI USA
Realm: Khadgar (PvE) - US


Return to AddOns and Mods

Who is online

Users browsing this forum: No registered users and 0 guests

cron