testing for existence of language files?

Discussion forum for MOD Writers regarding MOD Development.
Locked
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

testing for existence of language files?

Post by asinshesq »

I got the following message in connection with denial of a new version of one of my mods:
This MOD doesn't test if the language file exist:
Image
Testing for the existence of a language file (presumably to cover the situation where the person who installed the mod forgot to copy the mod language files over to other languages the board uses) is a new idea for me, and looking at some other mods I don't see others doing that. Is that required, how do we test that generically (for whatever language happens to be live for a user) and what should the code do if the file doesn't exist?

I don't use other languages on my board and I have never studied the add_lang function, but I had assumed that when a mod includes this line:

Code: Select all

$user->add_lang('mods/foo');
phpbb3's core code would deal with that nicely if language/[user language]/mods/foo.php doesn't exist. What should mod author's be doing about this?
User avatar
tbackoff
Former Team Member
Posts: 7064
Joined: Thu Jun 04, 2009 1:41 am
Location: cheerleading practice
Name: Tabitha Backoff

Re: testing for existence of language files?

Post by tbackoff »

That's interesting - I thought MODs only had to work with the prosilver style and the en language set. Have you contacted the validator?
Flying is the second best thrill to cheerleaders; being caught is the first.
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Re: testing for existence of language files?

Post by asinshesq »

Thanks, tabitha (and how have you been?).

You are definitely right that mods only have to work with prosilver style and en, but I guess the validator believes that if it fails with another language it should do so gracefully (without throwing errors). In that regard, I note that if I switch my own account to es (spanish) on my test board everything still works for plain vanilla phpbb3 even though I do not have a language/es folder; since phpbb3 can't find the es language files it appears to default to english with no errors. I think that's what the validator thinks mods should do too. I haven't yet investigated how plain vanilla phbbb3 does that (never considered this issue before)...any chance you know off the top of your head? Otherwise, I will reverse engineer.

I did reply to the validation topic sticky but haven't yet heard back: https://www.phpbb.com/customise/db/mod/ ... 81#p361781
User avatar
tbackoff
Former Team Member
Posts: 7064
Joined: Thu Jun 04, 2009 1:41 am
Location: cheerleading practice
Name: Tabitha Backoff

Re: testing for existence of language files?

Post by tbackoff »

I'm good, thanks for asking!
asinshesq wrote:I note that if I switch my own account to es (spanish) on my test board everything still works for plain vanilla phpbb3 even though I do not have a language/es folder; since phpbb3 can't find the es language files it appears to default to english.
Are you running your board with DEBUG and DEBUG_EXTRA enabled?

I'm still wondering why validators are testing MODs with other languages. Hopefully someone from the MOD Team can chime in on this. Was this a change in policy? There's nothing on the MOD Validation Checklist.

Side note - only the MOD Team and MOD Author can see validation topics. ;)
Flying is the second best thrill to cheerleaders; being caught is the first.
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Re: testing for existence of language files?

Post by asinshesq »

This happens even without debug and debug extra. After experimenting a bit, I see the issue is a bit narrower. For regular language entries used by my mod, my test board gracefully defaults to en in the absence of the appropriate language folder. The narrower problem occurs when the mod sends out email using an email template added by the mod. In that case, it does NOT default to en email templates in the absence of the the appropriate language folder for a given recipient (though plain vanilla seems to do that). I'll see if I can figure out how plain vanilla phpbb3 does that.

Thanks again for your input.
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Re: testing for existence of language files?

Post by asinshesq »

Here's the update: I didn't get an answer as to why the rules technically require me to fix that issue, but the comment does not apply to add_lang() since that function already gracefully falls back to en if the folder for the lang in question doesn't exist. My mod happened to include a language file in a particular file in a way where add_lang() would not work (basically, it included a language file for the language of each recipient of an email in order to build the text of that email, because trying to do the multiple permutations of that text via separate email templates would have been unwieldy, and I don't think you use add_lang() more than once in a file). To fix that, I did the following:

Code: Select all

FIND
include($phpbb_root_path . 'language/' . $recipient_lang . '/mods/foo.' . $phpEx);

REPLACE WITH
file_exists($phpbb_root_path . 'language/' . $recipient_lang . '/mods/foo.' . $phpEx) ? include($phpbb_root_path . 'language/' . $recipient_lang . '/mods/foo.' . $phpEx) : include($phpbb_root_path . 'language/en/mods/foo.' . $phpEx);
Locked

Return to “[3.0.x] MOD Writers Discussion”