Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Dynamic Includes
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Dynamic Includes

 Post Reply Post Reply Page  12>
Author
theSCIENTIST View Drop Down
Senior Member
Senior Member


Joined: 31 July 2003
Location: United Kingdom
Status: Offline
Points: 440
Post Options Post Options   Thanks (0) Thanks(0)   Quote theSCIENTIST Quote  Post ReplyReply Direct Link To This Post Topic: Dynamic Includes
    Posted: 12 October 2004 at 5:06pm
What I need is to make a language changer for a project I'm working on, all language files have the following directory structure:

+languages
| en
|- files
| pt
|- files
and so on...

ASP pages will then call the correct file according to the value on the cookie (en/pt...), but I'm using SSI to include the language file and it does not allow dynamic values.

Now, for what I could gather SSI does not allow dynamic includes, you know the (<!-- #include file="page<%= rnd %>.asp" -->) this would be great, but because SSI's are included before the ASP parser, the <%= value %> would not be known, and it doen't work.

Then I tried the Server.Execute, also failed because it loads the file, processes it and unloads it, so it will no longer be available to pass language constants along.

I've been banging my head on the wall with this one, still no solution, has anyone done something similar, or know how can I do this? Remember I would like to use the directory stucture as above.

Thanks.
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 12 October 2004 at 5:37pm
You could do it another way, just have 1 static include file "languagefunctions.asp" and include a function like GetLanguage(Key) the GetLanguage function will open the appropriate file (or query the db) for the language and will return a value based on the key that was passed through.
Back to Top
theSCIENTIST View Drop Down
Senior Member
Senior Member


Joined: 31 July 2003
Location: United Kingdom
Status: Offline
Points: 440
Post Options Post Options   Thanks (0) Thanks(0)   Quote theSCIENTIST Quote  Post ReplyReply Direct Link To This Post Posted: 12 October 2004 at 7:05pm
Hi, I was actually exploring that possibility, since I have done exactly that for the skin changer, however, the language files are several files, each page requests the lang file it needs, (ie. gallery script requests only the gallery lang file, not a big global lang file) how do I go about doing that?

Each file has an Include on top that includes the language file it needs, and my other setup is like this: I have a language changer form that submits it's selection to a language processor page, this page then sets the cookie, and after that I'm kinda stuck.

I guess I could do a (Select Case) like this on the requesting page:

<%

Select Case Request.Cookies("Kahombo")("Language")
Case "en"
%>
<!--#include file="path/en.asp"--%>
<% Case "pt" %>
<!--#include file="path/pt.asp"--%>
<% End Select %>


The problem with this approach is that all files are included regardless, but only one is processed, also as the languages list gets bigger, it will get slower as all files must be included.

There must be another way.
Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post Posted: 13 October 2004 at 12:11am

Don't know the logic flow involved here, particularly avter the language files execute, but depending upon how the flow is structured, you might want to look at doing Server.Transfer.

Doesn't open up a new memory space like Server.Execute and as a result - IIRC - any stuff in a request/response onbject available to the original script is available to the transferred script. But you don't return to the original script. You'd have to have the subsequent statements from the original script incorporated within an include in each transferred script.


Lead me not into temptation... I know the short cut, follow me.
Back to Top
theSCIENTIST View Drop Down
Senior Member
Senior Member


Joined: 31 July 2003
Location: United Kingdom
Status: Offline
Points: 440
Post Options Post Options   Thanks (0) Thanks(0)   Quote theSCIENTIST Quote  Post ReplyReply Direct Link To This Post Posted: 13 October 2004 at 8:52am
What I'm trying to do is say for example you want to add multi-language capabilities to this forums, you'll have a drop-down list with the languages, users will then select a lang, and submit the form.

How would you do it after that?

dpyers: Did you mean using Server.Transfer with the PreserveForm option? How so? How do you plan to dynamically include the correct lang file? Thx.

All forum files contain variables that are the same in all language files, the difference is the value of those variables.

I've been looking around for this, and it seams to be a real pain in the back side to do in ASP, I've read a large discussion last night about it, it took me till 5am and the final word was that there's no easy way without some kind of compromise.

I may also look into do it in ASP.NET and combite it with ASP somehow, Mart, michael or any other .NET wiz, please comment.

Lots of people out there have this issue, I plan to crack it, with your help off-course ;) I will not do anything else until this is resolved as it is really important for my project, this morning I was even dreaming about language files :) damn this is getting bad. Thx.
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 13 October 2004 at 11:26am
I can help  you do it in .NET and access it through ASP if you have physical access to the server register a .NET component in the GAC
Back to Top
theSCIENTIST View Drop Down
Senior Member
Senior Member


Joined: 31 July 2003
Location: United Kingdom
Status: Offline
Points: 440
Post Options Post Options   Thanks (0) Thanks(0)   Quote theSCIENTIST Quote  Post ReplyReply Direct Link To This Post Posted: 13 October 2004 at 11:43am
COM? I rather not use COM as the project will later be hosted on many different hosts and some will not have this ability, so I would like to stay away from COM.

Anyway, if you can tell me the process involved.

Is there any other way to do this in ASP? Also, with no COM how to in ASP.NET?

Thx.
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 13 October 2004 at 12:12pm
No not COM, the only way you could do it with .NET is to make a new component and register it in the server GAC, you can then access it LIKE a Com component but it is really a .net component. All you basically have to be able to do is be able to run a batch file
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.