Nao

  • Dadman with a boy
  • Posts: 16,079
How I miss the freedom of coding the easy way...
« on November 17th, 2016, 05:44 PM »
Quote from Nao on November 10th, 2016, 05:12 PM
Added a generically generic template for the generic purpose of showing generic text in the usual generic place.
Gosh, I should have done that years ago...
To hell with MVC! Anything that makes reading code is a plus of course, but if it makes WRITING code much more annoying, then it also kills spontaneity.

It's a bit like the language translation system... SMF does it with $txt['item_name'], when really they should do something like txt('Actual text'), and then call a function that checks if a translation is available for that particular string... Maybe a txt('Actual text', 'Context') allowing for multiple strings within different contexts, of course... Things like that. That would make it easier to just write plugins without having to bother about translations, and then anyone can translate any string that way (plus, they don't have to refer to a master file to get the original translation, and if the English version is modified, the translation will need to be updated otherwise the text will now show up in English -- in the current Wedge and SMF, a modified English string won't be updated at all in translated version).
Yes it's a bit slower at parsing time, but it's not a problem with Wedge, because all files are cached, and thus you can parse & run that function at cache time and not at runtime, and then save the cached file to something like 'Something.template.french.php', etc...

Of course, it's too late to do that now...

CerealGuy

  • Posts: 343
Re: How I miss the freedom of coding the easy way...
« Reply #1, on November 19th, 2016, 10:59 AM »Last edited on November 21st, 2016, 08:48 AM
It's never too late. Write a fancy script replacing all $txt['stuff'] with the proper translation and let's go. I think for wedge it would be always easy to change core stuff, just because there are not many plugins which relay on those thing. And even if so like in this case, it's just some handful plugins which shouldn't be too hard to update. I like the idea and i hate it to always have to load some language stuff. Plus, the translation system is shit if there's no translation available. Wedge (and i'm sure it's the same with smf) don't fall back to the default translation if there's a translation missing. Better approach would be to log an errror about a missing translation and show the default message.

I really like the possibility to do those in-same-file templates. Should be same with language and everything else. Best to hack something together and it's easier to learn for new plugin developers.

Nao

  • Dadman with a boy
  • Posts: 16,079
Re: How I miss the freedom of coding the easy way...
« Reply #2, on November 25th, 2016, 01:40 PM »
Actually, unlike SMF, Wedge *does* fall back to English if a specific string (or an entire file) is missing from the translation.
One of the things that bother me is that SMF never put a clear wall between the admin & public areas. That is, it's MUCH easier to translate JUST the text visible to regular users, and leave the rest in English. It makes the idea of starting a translation from scratch much less scary.
Because, let's face it, if you DON'T speak English at all, you're better off NOT trying to administrate a forum, or even a website in general... I'm not saying you shouldn't, I'm saying perhaps you should consider leaving it to someone else. ;)

I don't know, regarding this txt() thing, what do you guys think..?

It couldn't be magically done with a mass replace though, because of the whole 'context' thing. Although I suppose we could just write a quick tool to go through all strings in all files, and print out the duplicate ones, and apply a context to each of them.

Time goes by and I still regret that Wedge never took off. If there was a large community behind it, it would be so encouraging. Then again it would also make it harder to do breaking changes like these... ;)
Gosh it's been so long, I'm getting lost in my own code changes. For instance, I don't remember how to override a template function from within a Custom.template.php file... At least I remember I can do that, lol. I'll need to find where I documented that...

CerealGuy

  • Posts: 343
Re: How I miss the freedom of coding the easy way...
« Reply #3, on November 27th, 2016, 12:55 AM »
I like it, but $txt stuff should still work in the beginning.
How do you wan't to call the function?
Code: [Select]
we:txt('This is some example txt', 'test_example')

And how do you want to do the translation stuff?
Again some
Code: [Select]
$txt['test_example'] = 'Das ist ein beispiel txt';
?

Nao

  • Dadman with a boy
  • Posts: 16,079