News:

Wondering if this will always be free?  See why free is better.

Main Menu

Making own file in languages...

Started by Burke ♞ Knight, November 14, 2008, 08:29:49 AM

Previous topic - Next topic

Burke ♞ Knight

Hello,

I'm working on a site, that has several pages, due to the site integration mod's help. :)

However, I'm really working on making a new menu for the site, and since it is very long list of text strings, I'd like to make a file in Themes/default/languages/  that would hold all the text strings for this menu, and have no idea how to have SMF call up that file.

The name of the file would be:
Realm.english.php

Any ideas on how to get it to call this file?

ccbtimewiz

Did you use the loadLanguage() function?

loadLanguage('Realm');

Burke ♞ Knight

Quote from: ccbtimewiz on November 14, 2008, 11:53:49 AM
Did you use the loadLanguage() function?

loadLanguage('Realm');

In what file do I add that?

ccbtimewiz


Burke ♞ Knight

Right now, I had the file, Realm.english.php in the Themes/default/languages directory.
So, what do I do?

Make a file Realm.php in sources and add this to it:


<?php
loadLanguage
('Realm');
?>

ccbtimewiz

Wait, you don't have Realm.template.php or Realm.php? o_O

Burke ♞ Knight

No. Just the language file. The rest is the menu, that goes into Subs.php in sources.

ccbtimewiz

Why don't you just add the strings to Modifications.{your_language}.php in that case? o.o;

Burke ♞ Knight

I ended up doing that, but still wanted to know where it would be added, to call up a new language file for text strings. :)

Rumbaar

You can just add it anywhere in that file, if I get what you mean.  As long as it's after the <?php and before the ?>
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

Marcus Forsberg

If it's only strings for the menu in it, add loadLanguage('Realm'); in Subs.php.
Doesn't matter where in the file you add it, but you might want to add it among theo ther loadLanguage() functions in that file.

Burke ♞ Knight

I'll give that a shot. :)
Thanks Nascar. :)

Rumbaar

Adding extra language file calls can increase load, where the Modifications.{language}.php file is already being called and meant to be a place where you can add extra $txt[] strings.
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

Burke ♞ Knight

Indeed, but too many strings in one file, can increase load, too.

Rumbaar

I don't think as much as calling a new file on each load though.  But I'm sure either way nothing of any notice on most forums.
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

Deprecated

The Modifications.{language}.php file is provided so that modification authors have a standardized place where they can put their modification's language strings. That is its intended purpose. In fact just today a mod author was asked to please move his added language strings to the Modifications.{language}.php files before his mod could be approved, although that was not the only reason he was squawked.

Furthermore, you are best off if you use this search string when installing your language strings:

<search position="end" />

I'm not saying that other ways won't work (because they do work) but it makes it easier for other people to understand your code if you do things the same way that everybody else does the same things.

So please tell us why you think you have too many strings. And please note (SMF 2.0 only) that once you have loaded your file it stays in the cache, so it would make no difference whether your strings are in Modifications.{language}.php or in a dedicated file.

How many strings are we talking about here? I don't see any problem adding a couple hundred strings if that's all it is.


Burke ♞ Knight

Well, this was mainly a mod for my own site of course. Not one to be used on any other site... (As if anyone would have a site like that one...LOL)

It also was more a way of learning, that I asked how to do so. Right now, they are in the modifications file, yet I was wanting to know how to call up my own, if I ever needed to, for another mod. Using the Realm site as a reference was just to make things easier, and that it would most likely have been my first try at doing my own language file for the text strings.

Rumbaar

#17
Yes I realised you were only make a custom modification to your own site and no other intention.  It seems some of us a little more zealous than others :)

When it's your own site you can do so as you will.
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

Deprecated

Burke, just do what I do. I just go looking around in SMF source and find some existing code that does the same thing. There really isn't anything new under the sun, but rather just things that already exist, and rearranged.

One nice thing you can look forward to, after you have built up several of your own mods you can start cutting 'n pasting your own code. Like the "adding a control panel" stuff. Once you have figured out how to do one SMF 1.1.7 and one SMF 2.0, you can reuse the same code over and over. That makes it a lot easier to come out with new mods.

Deprecated

Quote from: Rumbaar on November 24, 2008, 05:38:31 PM
Yes I realised you were only make a custom modification to your own site and no other intention.  It seems some of use a little more zealous than others :)

You may call it 'zealous' but I'm spending 2/3 to 3/4 of my mod package support labor fixing problems caused by the careless work of other mod authors, like inserting or removing a tab in a comment line (that happened to be MY target) or accidentally removing a line-feed and getting their code inserted on the same line as existing code.

It's pretty frustrating when most of your support amounts to fixing problems that could have been avoided if the other guy had been a bit more 'zealous.'

Rumbaar

Well he is only working on his site, with no intention of releasing to the public or uploading it to the Customization section.  If he wanted to hard code each and every text string that would be his own problem and prerogative.  Talking about how to package it as a mod or making it strict in line with SMF coding doesn't benefit his end goal.
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

Burke ♞ Knight

Hey, I have to learn somehow...LOL

And yes, when it comes to this one site in particular, even though it is an info site for an MMORPG I don't even have an account to play on anymore, I try to get it perfect. I owe it to my Realm Family to do so. After all, if not for the Realm, and my "Family", I never would have gotten as much into web work as I have. :)

Rumbaar

Oh I know that, I run and operate one of the more popular The Matrix Online MMORPG resource sites and I quit playing the game 1-2 years ago.  So I understand the passion and commitment to get it right :)
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

Advertisement: