Home

Your premium source for custom modification services for phpBB
  logo

HomeForumsBlogMOD ManagerFAQSearchRegisterLogin

Comments September 18, 2006

MOD Writers: Where do you put your language strings?

Filed under: MOD Writing — Dave Rathbun @ 9:18 am CommentsComments (2) 

One of the decisions that a MOD writer has to make is whether to provide language strings as edits to an existing language file, or create their own. There are advantages and disadvantages (as I see it) either way.

Using Standard phpBB Language Files
Advantages
If you include your language strings within a standard language file (lang_main.php or lang_admin.php are likely candidates) then you don’t have to do anything to get your language values loaded. The standard application code already takes care of loading these files. This is probably the best approach for MODs with only a few language strings.

Disadvantages
As with any MOD, when you edit existing files you run the risk that those files could be overwritten during an upgrade. For larger MODs, this might be more of a risk. If you have a lot of language strings, and they’re only required for certain pages, then having them in a standard language file loads them even when they are not needed, using extra session memory.

Using Custom Language Files
Advantages
Your language files are only loaded when you need them. So if your MOD includes separate php files, and the language values are only needed when your code is executed, then you don’t take extra memory unless it’s actually needed. This is a direct counterpoint to the disadvantage listed previously, of course.

I think it would be easier to provide translations. If someone wanted to go to the trouble to translate your MOD, you could simply provide a translated file rather than new MOD instructions. I don’t have any direct experience with this, but it seems to make sense to me.

It also seems that it would be easier to provide an update to your MOD, as you can simply provide a file to copy rather than edits to an existing file. If you update your MOD, the update instructions become “copy” rather than “open” + “find” + “after, add” or whatever would be required.

Disadvantages
You either have to a) include extra MOD instructions to load the language files (since they’re not loaded as part of the standard process) or b) take care of loading the language files within your own code. If it’s a large enough MOD, and the language files are extensive enough, this is probably what you want to do anyway. So perhaps this isn’t that much of a disadvantage.

As an example, I have a MOD called Page Permissions that allows a board administrator to set permissions based on page names, rather than page content. So you can have specific permissions for the member listing, or for viewing profiles, just as examples. The MOD requires extremely minimal edits to existing files, other than the language entries. When I started, I simply added the required language entries to the lang_admin or lang_main files. There are only a few lines added to lang_main, so there’s probably not a big impact to how much session memory is used.

There are quite a few language strings added to lang_admin.php, but that file is only loaded when the admin enters the ACP (Admin Control Panel). So I’m not too concerned about memory utilization there either.

So the only real reasons to consider breaking all of the language strings out into their own file would be ease of updates and ease of translations. At the moment I’ve left the Page Permissions MOD with its language strings included in the standard file, but I expect I will change that if (when) I issue a future release.

2 Comments »

  1. Myself, I would use the standard phpBB language files if I know that the Mod I’m developing is small and won’t require anymore changes or updates. Otherwise I tend to stick with custom language files.

    Comment by alexi02 — September 19, 2006 @ 10:19 am

  2. I will be honest, I’ve never used a custom language file. I should have, with my “Page Permissions” MOD. Doing that would have made the MOD install incredibly simple, as the bulk of the actual edits are language entries.

    I expect to update that MOD and set it up to use its own language file. Thanks for the comment! Welcome to the Doctor Blog. 8-)

    Comment by dave.rathbun — September 20, 2006 @ 9:44 am

RSS feed for comments on this post.

Leave a comment

Tags allowed in comments:
<a href="" title=""> <acronym title=""> <blockquote cite=""> <code> <strong> <em> <u> <sup> <sub> <strike>

Confirm submission by clicking only the marked checkbox:

     **         

Powered by WordPress