News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Hook interesting?

Started by ^HeRaCLeS^, January 08, 2013, 09:43:05 AM

Previous topic - Next topic

^HeRaCLeS^

I think it would be good to have a hook for languages..


add_integration_function('integrate_txt','txt_example');


function txt_example(&$languages) {

$languages = array(
'english' = array(
$txt['text1'] => 'text 1',
$txt['text2'] => 'text 2',
$txt['text3'] => 'text 3',
),
'spanish_es' = array(
$txt['text1'] => 'texto 1',
$txt['text2'] => 'texto 2',
$txt['text3'] => 'texto 3',
),
'spanish_latin' = array(
$txt['text1'] => 'texto 1',
$txt['text2'] => 'texto 2',
$txt['text3'] => 'texto 3',
),
);

}


..or something like that O:)
^HeRaCLeS^
*¤×• Ni te molestes en enviarme un Mp porque el soporte lo doy solo por el foro •×¤*


SMFPersonal

NanoSector

That would make the array way too big, causing performance issues.

If you want to use languages without modifying files, use loadLanguage('language') in your mod which uses hooks.
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

^HeRaCLeS^

Yes. That's what I do.

But... in 10 languages ​​are 10 files thereby increasing the size of the modification.

This was just an example, could arise otherwise.
^HeRaCLeS^
*¤×• Ni te molestes en enviarme un Mp porque el soporte lo doy solo por el foro •×¤*


SMFPersonal

NanoSector

Quote from: ^HeRaCLeS^ on January 08, 2013, 11:32:44 AM
Yes. That's what I do.

But... in 10 languages ​​are 10 files thereby increasing the size of the modification.

This was just an example, could arise otherwise.
It doesn't make much of a difference; you have to store the data somewhere :P (may save you 500 bytes at best, not much of a dealbreaker)
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

^HeRaCLeS^

At the moment of uploading files all bytes are taken into account! and more if they are free servers.
^HeRaCLeS^
*¤×• Ni te molestes en enviarme un Mp porque el soporte lo doy solo por el foro •×¤*


SMFPersonal

Arantor

Given that file size usage gets rounded up by hosts, this really makes little difference for storage purposes.

Also, this is only any use in UTF-8, other than UTF-8 you can't safely mix the encodings in a single file otherwise.

What would be better is, instead, if a hook could perform loadLanguage when called and load the right file directly. This would also actually perform faster because less code would have to be parsed and executed.

Antes

Actually, it would be better if package manager/mods offers language edits like "other themes" part, optional and detectable.

Arantor

The entire goal was to avoid making file edits which is a GOOD thing.

Antes

Quote from: Arantor on May 22, 2014, 09:46:51 AM
The entire goal was to avoid making file edits which is a GOOD thing.

If I'm not mistaken SMF doesn't even recognizing the files (source/template/language etc...) so when you install a mod if contains language files which your forum doesn't have it still copies the files either you have to delete manually or leave them. I'm saying it would be better if package manager offers to skip those files and/or edits.

Arantor

That depends how smart you are as a mod author, actually. It is entirely possible to force a mod to put its files only in the default theme's languages folder, rather than copying it into every theme's languages folder and has been for years.

But what you're talking about is completely unrelated to the original suggestion anyway.

Advertisement: