Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: The Wizard - maaliskuu 02, 2014, 10:35:23 AP

Otsikko: fatal_lang_error question
Kirjoitti: The Wizard - maaliskuu 02, 2014, 10:35:23 AP
Hello:

Is there any way to use the "fatal_lang_error" but direct it to read text from my "ToyShop.english.php" file instead of the "Modifications.english.php" file?
The reason I ask is that if someone wanted to translate my work into another language it would be easier, and quicker to just have to translate the ToyShop.english.php file.

If so could you show me a example of how this can be done?

Thanks

Wiz
Otsikko: Re: fatal_lang_error question
Kirjoitti: emanuele - maaliskuu 02, 2014, 11:26:04 AP
loadLanguage('ToyShop');
fatal_lang_error('whatever_string_you_want_to_use');
Otsikko: Re: fatal_lang_error question
Kirjoitti: The Wizard - maaliskuu 02, 2014, 12:10:06 IP
Hi emanuele:

I tried that, and it does not work. As I understand it the "fatal_lang_error" has it's own template it uses, and uses the "Modifications.english.php" file to call the language. I was just hoping there was a way to use my own language file, but I don't think so. I Would like to hear what some of the guys working on the code functions of smf have to say about this?

Wiz
Otsikko: Re: fatal_lang_error question
Kirjoitti: margarett - maaliskuu 02, 2014, 12:41:19 IP
It should use primarily Errors.english.php, actually.
But, as long as the language is loaded, the string should be recognized from whatever file it comes as emanuele says. It should, I will test it when I get to the PC.
Otsikko: Re: fatal_lang_error question
Kirjoitti: emanuele - maaliskuu 02, 2014, 03:27:07 IP
fatal_lang_error uses the argument you pass as index of $txt:
https://github.com/SimpleMachines/SMF2.1/blob/master/Sources/Errors.php#L167

So, you can place your string any where you want, provided you load the language file before calling fatal_lang_error and is stored into the usual $txt variable.

Lainaus käyttäjältä: The Wizard - maaliskuu 02, 2014, 12:10:06 IP
I Would like to hear what some of the guys working on the code functions of smf have to say about this?
I may not have a shiny badge, but I think I know something of how SMF works. ;)
Otsikko: Re: fatal_lang_error question
Kirjoitti: margarett - maaliskuu 02, 2014, 03:58:54 IP
Actually you do. It's not shiny (dark brown isn't) but there's one there ;)
And by all means yes, you know how stuff works!