Gossamer Forum
Home : Products : DBMan : Customization :

One Databse, Multiple html.plīs best way?

Quote Reply
One Databse, Multiple html.plīs best way?
Is there an easy way to do this..

My site will be in 4 languages, the default being English, then German, Dutch & Russian.. Dbman will need to query only one database and will have only one Admin.. Should I create 4 html.plīs for each language and would I use one default.cfg and what would the paths to directories look like from my cgi-bin ..

Help Appreciated.. Justin

Quote Reply
Re: One Databse, Multiple html.plīs best way? In reply to
It might be easier to create additional html.pl file. Of course, you could use one html.pl file and then use conditional statements, like the following:

Code:

if ($in{'language'} eq "German") {
print qq|HTML CODES|;
}
if ($in{'language'} eq "Dutch") {
print qq|SOME OTHER HTML CODES|;
}
if ($in{'language'} eq "Russian") {
print qq|YET OTHER HTML CODES|;
}
else {
print qq|ENGLISH HTML CODES|;
}


Throughout your subs in the main html.pl file.

Then to call the different languages in the REQUEST_URI string, add the following parameter:

Code:

&language=German


Example:

Outside of DBMAN:
Code:

<a href="/cgi-bin/dbman/db.cgi?db=default&uid=default&language=Dutch">Dutch Database</a>
<a href="/cgi-bin/dbman/db.cgi?db=default&uid=default">English Database</a>
<a href="/cgi-bin/dbman/db.cgi?db=default&uid=default&language=German">German Database</a>
<a href="/cgi-bin/dbman/db.cgi?db=default&uid=default&language=Russian">Russian Database</a>


Within DBMAN:
Code:

<a href="$db_script_url?db=default&uid=default&language=Dutch">Dutch Database</a>
<a href="$db_script_url?db=default&uid=default">English Database</a>
<a href="$db_script_url?db=default&uid=default&language=German">German Database</a>
<a href="$db_script_url?db=default&uid=default&language=Russian">Russian Database</a>


Now if you want to use separate html.pl files, then simply change the following codes in the default.cfg file:

Code:

require $db_script_path . "/html.pl";


to the following codes:

Code:

if ($in{'language'} eq "Dutch") {
require $db_script_path . "/dutch_html.pl";
}
if ($in{'language'} eq "German") {
require $db_script_path . "/german_html.pl";
}
if ($in{'language'} eq "Russian") {
require $db_script_path . "/russian_html.pl";
}
else {
require $db_script_path . "/english_html.pl";
}


Some of the above codes may need tweaking, but the logic is there.

Regards,

Eliot Lee
Quote Reply
Re: One Databse, Multiple html.plīs best way? In reply to
Thank Elliot.. The second options seems my best bet.. Justin

Quote Reply
Re: One Databse, Multiple html.plīs best way? In reply to
You're welcome...remember that I have not tested any of the above options...just logic that may work.

Regards,

Eliot Lee
Quote Reply
Re: One Databse, Multiple html.plīs best way? In reply to
Iīm receiving an "Error: Unknown Action" message..

I have to go with the second method.. any other thoughts to the reason why I canīt get this to work..

Here is a demo link along with my default.cfg...

http://www.visaverde.com/test.html

Thanks. Justin..

Quote Reply
Re: One Databse, Multiple html.plīs best way? In reply to
Hi!

Found the thread Eliot!!

One question - will the &language= be kept throughout the user session? Or will they suddenly be faced with an english page when they log-out or add a record, etc.

Mine is for co-branding, so I cannot really have seperate links on the homepage, it needs to be discreet and follow the user without their intervention

... ? Wink



Cheers!
Ben
------------
http://www.travel-experiences.com
Quote Reply
Re: One Databse, Multiple html.plīs best way? In reply to
Come on ... you know you want to! ;)

Cheers!
Ben
------------
http://www.travel-experiences.com
Quote Reply
Re: One Databse, Multiple html.plīs best way? In reply to
Is this a "can't be done"?

Ifa nyone has any ideas, please let me know. I have helped out in this forum, just like others. Please give me a hand!! Wink



Cheers!
Ben
------------
http://www.travel-experiences.com
Quote Reply
Re: One Databse, Multiple html.plīs best way? In reply to
As long as you keep passing in a "language" field in your links and forms, you will always have the $in{'language'} variable available to you.

So you will have to go through each link and add &language=$in{'language'} to them, and similar inputs to your forms.


Another idea you may concider would be assigning a language to each user in default.pass so users don't have to keep picking a language every time they log in.

This may be one way:

Use a variation of the "add permission" mod to add a "language" field to the default.pass field.
eg: usename:password:1:0:0:0:0:english

Then, as people log on to the database, they will be assigned a new variable called $language (for example. you will set this up as you install the mod)

Then you can add &language=$language to each of your links.


Hope this gives you some ideas.

- Mark

Astro-Boy!!
http://www.zip.com.au/~astroboy/
Quote Reply
Re: One Databse, Multiple html.plīs best way? In reply to
Cheers Mr Astro!!

I'll give it a go....



Cheers!
Ben
------------
http://www.travel-experiences.com
Quote Reply
Re: One Databse, Multiple html.plīs best way? In reply to
Here is what I did... I need multiple views from the same database. On one page for "consumers" we return only a name & phone #. On a page for "members" we return all database info. I did this by using the very first example above by modifying the html.pl file like so:

#Stick this under the sub html_record with the HTML CODES being the form/table fields you want or have modified

if ($in{'language'} eq "Consumer") {
print qq|CERTAIN HTML CODES|;
}
else {
print qq|ALL HTML CODES|;
}

Use this as an example link to get the people to view the proper set of fields based upon where they are in your site:

http://www.yourdomain.com/cgibin/dbman/db.cgi?db=default&language=Consumer&uid=&view_records=1&ID=*

This worked for me, but I've yet to really tweak it or try to break it. I had to play around with where to place the "language" part in order to get it to work.

Quote Reply
Re: One Databse, Multiple html.plīs best way? In reply to
Hi

AstroBoy.....

Ive just been installing the New Permission mod. When I get to updating the admin screen, how should I approach this:

Code:
if (!$perm) {
$perm = qq|
View <input type=checkbox name="per_view" value="1" |; ($auth_default_perm[0] and $perm .= "CHECKED"); $perm .= qq|>
Add <input type=checkbox name="per_add" value="1" |; ($auth_default_perm[1] and $perm .= "CHECKED"); $perm .= qq|>
Delete <input type=checkbox name="per_del" value="1" |; ($auth_default_perm[2] and $perm .= "CHECKED"); $perm .= qq|>
Modify <input type=checkbox name="per_mod" value="1" |; ($auth_default_perm[3] and $perm .= "CHECKED"); $perm .= qq|>
Member <input type=checkbox name="per_mem" value="1" |; ($auth_default_perm[4] and $perm .= "CHECKED"); $perm .= qq|>
Admin <input type=checkbox name="per_admin" value="1" |; ($auth_default_perm[5] and $perm .= "CHECKED"); $perm .= qq|>|;
}


As I want a text value rather than a checkbox. I have changed it to type=text but what about the value=1 (is this the default language?) and $perm.="CHECKED" ??

Hope you can help!!!

Cheers!
Ben
------------
http://www.travel-experiences.com
Quote Reply
Re: One Databse, Multiple html.plīs best way? In reply to
Heeelllppp!?

Cheers!
Ben
------------
http://www.travel-experiences.com
Quote Reply
Re: One Databse, Multiple html.plīs best way? In reply to
Hi people

I am really close to doing this, but could reaaly use a bit of help?! Please? Wink

Cheers!
Ben
------------
http://www.travel-experiences.com
Quote Reply
Re: One Databse, Multiple html.plīs best way? In reply to
Hi Benseb,

Rather than adding a checkbox, you can just add a new INPUT box to the html_admin_display sub-routine of html.pl

Eg:
<tr><td align=right><$font>New Username:</font></td>
<td><input type="text" name="new_username" size="14"></td></tr>
<tr><td align=right><$font>Language:</font></td>
<td><input type="text" name="language" size="14" value="$language"></td></tr>

<tr><td align=right><$font>Change Password:</font></td>
<td><input type="text" name="password" size="14" value="$password"></td></tr>


- Mark


Astro-Boy!!
http://www.zip.com.au/~astroboy/
Quote Reply
Re: One Databse, Multiple html.plīs best way? In reply to
Cheers for that! I'll have fun over christmas trying to piece it all together!

;)


Cheers!
Ben
------------
http://www.travel-experiences.com
Quote Reply
Re: [benseb] One Databse, Multiple html.plīs best way? In reply to
Im also thinking of making my dbman multi-languaged like the above, with one slight difference:

I want to have one separete file for all text content, ie the html.pl hosts all code, design etc and then I have another file that keeps the different translations. So that I from the html.pl call different subs within the "languages.pl" file. How can I do this?, in html.pl calling subs from another file? Should I use some kind of "require" solution?

Anyone understood what I mean? :)

Thanks!
Quote Reply
Re: [eric74] One Databse, Multiple html.plīs best way? In reply to
A question I would have is how are you going to handle all the page titles and form buttons in the various languages?

Even if you put the add form and displays within a separate file that would not deal with all the translations needed within many of the other subs. I should think you would need a separate html.pl file for each translation.




Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] One Databse, Multiple html.plīs best way? In reply to
I should say it all depends on how the database is used.

If *all* database routines are potentially accessed by users with different languages, then you might end up with different html.pls. If only some routines are accessed by users with different languages - e.g. if only users in English can add, modify and delete records, but viewing is in many languages -, then you'd only have to add language variation to html_view_success, html_record and html_view_failure.

One approach that, at least for forms, might be easier than doing things in html.pl is to code language variation in the cfg-file directly. For the forms, if you have autogeneration enabled, you could add another value to the %db_def-array - a descriptive field name - and then simply make its value for each field dependent on the language you use - you can then use this descriptive field name for your form generation instead of the "real" fieldname.


kellner