[RFC|Rejected] Language in the database

These RFCs were either rejected or have been replaced by an alternative proposal. They will not be included in phpBB.
Post Reply
User avatar
imkingdavid
Registered User
Posts: 1050
Joined: Thu Jul 30, 2009 12:06 pm

[RFC|Rejected] Language in the database

Post by imkingdavid »

Well, I noticed the topic about loading all of the default language files just to be sure no keys get lost in translation (hehe :lol:), and I got to thinking, why are we relying on files anyway? Why not put the language stuff in the database? I doubt it would be a major resource hog, and we could of course cache it so that we don't have to run queries on every page load. This would make it easier to do what naderman suggested for having a fall back, but instead of including an entire language file to look for one key, we just add an if statement to say that if the language key does not exist in the selected language, check the default language as well. This way you're only loading the keys you need, not each one available.

The way I envision in would not require dramatic changes (or any, really) to the way we use the language array (or, better yet, the $user->lang() method), it would just be a different way of storing it and selecting it.

As for language packs, we could even keep the lang file as it is and have an "installer" that processes the $lang array in the files and adds them to the database directly, so we wouldn't need to get rid of the current language files. And because of that, we could allow the admin to select whether to serve language from the files or the database (although then we still need to decide whether to load the default language pack files for a fallback).

So what would need to happen is to add a new table like so (may need some changes, just a rough idea of what we would need):

Code: Select all

CREATE TABLE phpbb_lang_items (
    lang_item_id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    lang_iso_id VARCHAR(6) NOT NULL DEFAULT 'en', // this would reference the phpbb_lang table
    lang_item_key VARCHAR(255) NOT NULL DEFAULT '',
    lang_item_value TEXT NOT NULL, // this is TEXT because varchar is too short in some cases
);
Anyway, this just kind of suddenly occurred to me and I really haven't thought through any of the potential cons, but I wanted to get this up for thoughts. So... thoughts?
I do custom MODs. PM for a quote!
View My: MODs | Portfolio
Please do NOT contact for support via PM or email.
Remember, the enemy's gate is down.
User avatar
imkingdavid
Registered User
Posts: 1050
Joined: Thu Jul 30, 2009 12:06 pm

Re: [RFC] Language in the database

Post by imkingdavid »

Here's an irc log from just now:

Code: Select all

[17:29:54] <imkingdavid> anyone wanna take a look at this and tell me why it's a bad idea before I think too much abuot it? http://area51.phpbb.com/phpBB/viewtopic.php?f=108&t=42939
[17:29:59] <imkingdavid> :DDDD
[17:31:23] <nx-> because you have to load the entries on each request?
[17:32:35] <nx-> we are relying on files because parsing php code is i'm assuming faster than issuing an sql query and then parsing the results
[17:32:36] <nx-> when you use cache you still parse everything
[17:33:30] --> t_backoff (~t_backoff@phpbb/moderator/tbackoff) has joined #phpBB-dev
[17:33:30] *** Mode #phpBB-dev +o t_backoff by ChanServ
[17:33:40] <nx-> but now instead of just loading a file you first load everything into the database, then you read it back from the database, then you store it into cache and read it out of the cache
[17:33:40] <nx-> still parsing everything
[17:33:40] <nx-> if you want fallbacks you can do them in filesystem just as well
[17:33:40] <nx-> well, in a normal app you could
[17:33:41] <nx-> in phpbb i guess not
[17:34:37] <nx-> i would be really careful with changes like this and especially making them on a whim
[17:34:51] <nx-> the only reason i'm seeing is "This would make it easier to do what naderman suggested for having a fall back"
[17:35:12] <nx-> not anywhere enough of a reason to put this much data into the database for me
I do custom MODs. PM for a quote!
View My: MODs | Portfolio
Please do NOT contact for support via PM or email.
Remember, the enemy's gate is down.
Danielx64
Registered User
Posts: 304
Joined: Mon Feb 08, 2010 3:42 am

Re: [RFC] Language in the database

Post by Danielx64 »

I suppose the only thing is, how much bigger will the database get? Wouldn't be that much right?
User avatar
DavidIQ
Customisations Team Leader
Customisations Team Leader
Posts: 1875
Joined: Thu Mar 02, 2006 4:29 pm
Location: Earth
Contact:

Re: [RFC] Language in the database

Post by DavidIQ »

Would probably be, at most, a few hundred rows and, in some rare/unique instances (tons of extensions installed), a bit over a thousand.
Image
User avatar
naderman
Consultant
Posts: 1727
Joined: Sun Jan 11, 2004 2:11 am
Location: Berlin, Germany
Contact:

Re: [RFC] Language in the database

Post by naderman »

This is going to make updates very complicated, so I'd rather just stick to files.
MartinTruckenbrodt
Posts: 171
Joined: Sun Jan 29, 2006 1:00 pm
Location: Germany
Contact:

Re: [RFC] Language in the database

Post by MartinTruckenbrodt »

Hello,
I can remember that the APboard (or tForum? ) have been doing it this way (about 9 years ago - in 2003 I moved to phpBB).
Database or files?
Files!

Cache?
Are you sure that language files are cached the way you told here (in Olympus).
When I'm programming and testing my MODs and I'm uploading a changed language file then always the content is updated without purging the board cache. So I think that the language files are loaded always again.

Bye Martin
Advanced Block MOD 1.1.1 has been released! - Prevent spam on your phpBB3 board with Stop Forum Spam, BotScout, Akismet, Project Honey Pot and several IP-RBL and Domain-RBL DNS blacklists! - My MODs
User avatar
imkingdavid
Registered User
Posts: 1050
Joined: Thu Jul 30, 2009 12:06 pm

Re: [RFC] Language in the database

Post by imkingdavid »

MartinTruckenbrodt wrote:Hello,
I can remember that the APboard (or tForum? ) have been doing it this way (about 9 years ago - in 2003 I moved to phpBB).
Database or files?
Files!

Cache?
Are you sure that language files are cached the way you told here (in Olympus).
When I'm programming and testing my MODs and I'm uploading a changed language file then always the content is updated without purging the board cache. So I think that the language files are loaded always again.

Bye Martin
I never said that Olympus cached language entries. Instead, I was suggesting that if they are moved into the database, we cache them so that we don't have to perform queries each time we want to get a language string.

Anyway, I am marking this topic as rejected, since I have already been told that this is not a realistic or beneficial change to look into at this time.
I do custom MODs. PM for a quote!
View My: MODs | Portfolio
Please do NOT contact for support via PM or email.
Remember, the enemy's gate is down.
MartinTruckenbrodt
Posts: 171
Joined: Sun Jan 29, 2006 1:00 pm
Location: Germany
Contact:

Re: [RFC|Rejected] Language in the database

Post by MartinTruckenbrodt »

Hello imkingdavid,
thanks for the clarification!
BTW: It has not been a persoanl attack. Now I know that file content is not cached in Olympus.
Bye Martin
Advanced Block MOD 1.1.1 has been released! - Prevent spam on your phpBB3 board with Stop Forum Spam, BotScout, Akismet, Project Honey Pot and several IP-RBL and Domain-RBL DNS blacklists! - My MODs
Post Reply