View Full Version : multilangual emty.php
jeronimo
23rd of April 2007 (Mon), 08:43
Hello all
I am try to make some pages with info about some general stuff based on emty.php. No problem so far.
But now I want those pages to be multilangual. Off course I can do this by changing the language files.
However, it would be more nice if I could type all the text in one file, and then if the user changes language, it gets the same info, in the other language.
How can this be done directly in emty.php?
Thanks
jeronimo
5th of May 2007 (Sat), 10:25
Well this is acually VERY VERY simpel
Make a file containing the text with the layout you want
<table width="100%" border="0" cellspacing="20" cellpadding="0"><tr><td>
<h2 class="ee_css_header_large">Login op de site</h2>
<p class="ee_css_paragraph">blablabla<br /> and so on<br /><br /> more to say</p>
<div class="login ee_css_paragraph">
</div>
</td>
</tr></table>
Safe this as 1.php containing ONLY this code (other name is also good, as long as you remind it)
Retype all the text to other languages you want and safe them to the dir they belong
Then open the empty.php
Some where half way the page you see
//content here
Right underneath this us paste the folowing code
<?php
@include ("./languages/" . $ee_lang . "/1.php");
?>
Safe the emty.php to an other name. Upload all the files and your done.
Simple and very handy for larger text files
jeronimo
11th of May 2007 (Fri), 18:32
The only thing I am trying now is to make an title appear in the tittle bar of the browser. How should we do this for empty.php based files? (for index.php and so on it is defiened in the template files)
------------------ puzzeling around helps ------------------------
So how did I manage
I added
ob_start();
$titletext = $s_indexpage_title . " -> " . ee_translate_A($translated["Contact_form"]);
print trim($titletext);
$browser_title_html = ob_get_contents();
ob_end_clean();
just above the place where you put your content.
Then in the title bar of your browser the title wil appear.
Note that you have to setup the ee_translate_A($translated["Contact_form"] in the global.php of the language files
jeronimo
12th of May 2007 (Sat), 09:46
The only problem I find now is the folowing;
Inlcuding things work fine but then...
The form that is included is nicely displayed multilangual, but then when the form is processed, my page is refreshed with losing the language. (so it is plain mail.php in stead of mail.php?ee_lang=eng )
How can this be solved?
Pekka
12th of May 2007 (Sat), 12:14
Make sure that you send variable $ee_lang out with the form.
jeronimo
13th of May 2007 (Sun), 18:10
So the form reads the variable $ee_lang form the url
Then the form takes this to the next step in the proces
But should the form also write it out to the url again? (mail.php?ee_lang=NLA)
wkitty42
23rd of May 2007 (Wed), 14:26
jeronimo,
i'm sure you've puzzled this out by now... it has been a week since your last post and my writting of this...
what pekka is saying is that you'd pass $ee_lang just as you did for the 1.php files but you'd also list it in the url you are creating and POSTing to otherwise, yes, it will be lost... you have to send it along by some method...
if you do have this solved, would you post what else you've done to facilitate it? i'm sure that others are also interested in this... i would likely be moreso if i were multilingual but sadly i'm not any more and haven't been since the age of 5 or 6 :(
jeronimo
23rd of May 2007 (Wed), 16:20
Sorry but I didn't have time to look at it. Maybe this (long) weekend i will find some time.
Before I just tried to make the mailform in the NLA and the ENG directory. However this didn't work. I think because the files where called by;
<?php
@include ("./languages/" . $ee_lang . "/1.php");
?>
And the .$ee_lang i think is the bottle neck in this. Maybe it work with a file that is included as above, but this file is including again strait from the directory
so mail.php includes LANG/mail.php
mail.php includes the form from the LANG dir. This should work. Will come back on this later for shure
jeronimo
28th of May 2007 (Mon), 10:09
Nope, also the last option did not work.
I cann't manage to write out $ee_lang with the form. The form doesn't handle the variable.
So maybe something to put on the wishlist for ee
An mail form (with captcha) that is completely multilangual.
I wil make an mail_nl.php and an mail_en.php now. Not the most elegant whay of doing it, but this will work for now. (only when people switch language while on the mailpage, the language wil not change there)
wkitty42
29th of May 2007 (Tue), 13:17
doing this from memory...
in your form definition, you specify certain variables to carry the form data... so you should be able to create another variable named ee_lang and then assign $ee_lang to it... i'd have to go dig up a form and lay it out in php to be able to post an example to try to make it clearer...
ok, let's see if i can do it (roughly) with a form from this page's source ;)
<form action="foo.php?ee_lang=<?php print "\"".$ee_lang."\"" ?> method="post">
<input type="hidden" name="ee_lang" value=<?php print "\"".$ee_lang."\"" ?> />
<input type="text" name="query" size="25" />
<input type="submit" class="button" value="Go" />
</form>
ok, i think this is it... i've stripped out a major amount of stuff from the section i cut out of the source on this page... i'm not sure about the 'type="hidden"' portion but the above should give you more of an idea of what i believe needs to be done... the only other thing i could possibly do would be to find some time and go actually code one up and see what happens ;)
[edit] updated form action line to include ee_lang... not sure if it needs be passes both ways or just one of them... if only one, i'd suspect it be the form action line instead of the hidden variable...
wkitty42
1st of June 2007 (Fri), 15:41
ok, i have gone and actually done this however, i've only one language installed and so can't test it much beyond that... what i've got appears to be the minimum necessary to work...
i followed your instructions above to the letter... i saved a new copy of empty.php as emptytest.php and did all my work in there... here is all the code... the only real mod i've done to the original file is to fix toroot and actually use it in the code (ie: replace "./ with $toroot.")
this is emptytest.php
<?php
error_reporting(0);
$toroot = "./";
$currentpage = "custom_a";
$this_is_index = "1";
ob_start ("ob_gzhandler");
@include ($toroot."basecode/SCRIPT_slashwork.php");
@include ($toroot."basecode/SECURITY_datacleaner.php");
@include ($toroot."basecode/SETUP_settings.php");
@include ($toroot."basecode/SCRIPT_connect.php");
@include ($toroot."basecode/SCRIPT_uncookied.php");
$uncookied_base_id = "";
if (isset($_POST['u'])) {
$u = ee_datacleaner($_POST['u']);
ee_uncookied_update_log ($u);
if ($u=="") $u = 1;
ee_uncookied_extract ($u); // now we have all post variables back
}
if (isset($_GET['u'])) {
$u = ee_datacleaner($_GET['u']);
ee_uncookied_update_log ($u);
$u = str_replace($uncookied_foochar,"",$u);
$vartalo = explode($uncookied_splitter,$u);
$u = $vartalo[0];
if ($u=="") $u = 1;
if (isset($vartalo[1])) {
$offset = $vartalo[1];
}
if (ee_uncookied_get_id ($u)) {
ee_uncookied_extract ($u); // now we have all get variables back
} else {
$offset_finder = "1";
}
}
@include ($toroot."basecode/SCRIPT_language.php");
unset($exhibition);
if (isset ($_GET['exhibition'])) {
$exhibition = ee_datacleaner($_GET['exhibition']);
}
@include ($toroot."languages/" . $ee_lang . "/global.php");
@include ($toroot."languages/" . $ee_lang . "/custom.php");
@require ($toroot."basecode/SECURITY_check_user_authorization.php");
@require ($toroot."basecode/SECURITY_check_exhibition_validity.php");
@include ($toroot."basecode/SCRIPT_common_functions.php");
@include ($toroot."basecode/SCRIPT_fetchsettings.php");
@include ($toroot."basecode/SCRIPT_get_styledata.php");
@include ($toroot."basecode/SCRIPT_indexfunctions.php");
@include ($toroot."basecode/SCRIPT_get_structure.php");
$uncookied = array(
"sortby_off" => @$sortby_off,
"sort_row" => @$sort_row,
"order" => @$order,
"search_row" => @$search_row,
"keyword" => @$keyword,
"category" => @$category,
"select_output" => @$select_output,
"size" => @$size,
"exhibition" => @$exhibition,
"perpage" => @$perpage,
"revealforms" => @$revealforms,
"viewall" => @$viewall,
"hidedetail" => @$hidedetail,
"ee_lang" => @$ee_lang
);
$temp = $uncookied;
$uncookied_base_id = ee_uncookied_make ($temp);
@include ($toroot."basecode/SCRIPT_common_items.php");
ob_start();
// content here
?>
<?php
ob_start();
$titletext = $s_indexpage_title . " -> " . ee_translate_A($translated["Contact_form"]);
print trim($titletext);
$browser_title_html = ob_get_contents();
ob_end_clean();
@include ($toroot."languages/" . $ee_lang . "/emptytest1.php");
?>
<table width="100%" border="0" cellspacing="20" cellpadding="0"><tr><td>
<h2 class="ee_css_header_large ee_css_capitalize">hello world</h2>
<?php
print "<p class=\"ee_css_paragraph\">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla tristique mollis magna. Ut vel ipsum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec et nibh. Suspendisse non neque. Cras vel sem. Quisque pellentesque, ligula quis faucibus gravida, odio augue porttitor justo, at suscipit nulla mauris sit amet arcu. Sed at arcu. Nullam arcu nulla, feugiat sed, convallis ac, bibendum id, ante. Quisque libero lacus, imperdiet ac, blandit in, tempus ac, urna. Sed tristique malesuada pede. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In fringilla, quam at tempor sodales, nibh felis iaculis neque, eget porta pede pede at tellus. Duis nec elit ac neque placerat malesuada. Duis lacinia malesuada neque. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Vestibulum felis.</p>";
?>
</td></tr></table>
<?php
// content ends
$custom_content_html = ob_get_contents();
ob_end_clean();
ob_start();
@include ("./" . $custom_a_content);
$ee_all_html = ob_get_contents();
ob_end_clean();
print $ee_all_html;
mysql_close ();
ob_end_flush();
?>
this is emptytest1.php
<?php
error_reporting(0);
$toroot = "../../";
@include ($toroot."basecode/SECURITY_datacleaner.php");
if (isset($_POST['myquery'])) {
$myquery = ee_datacleaner($_POST['myquery']);
}
?>
<table width="100%" border="0" cellspacing="20" cellpadding="0">
<tr>
<td>
<h2 class="ee_css_header_large">Login op de site</h2>
<p class="ee_css_paragraph">
blablabla<br />
and so on<br />
<br />
more to say
<br />
<br />
ee_lang: |<?php print $ee_lang ?>|<br />
myquery: |<?php print $myquery ?>|<br />
</p>
<div class="login ee_css_paragraph">
<?php print "<form action=\"emptytest.php?ee_lang=".$ee_lang."\" method=\"post\">\n" ?>
<input type="text" name="myquery" size="25" />
<input type="submit" class="button" value="Go" />
</form>
</div>
</td>
</tr>
</table>
<?php
// content ends
?>
the only "problem" i'm having is getting the title to come up as the translated contact form entry that i placed in languages/eng/global.php...
i tried numerous ways of writting the "form" line but the only way i was able to get it to work properly was by letting php do the entire line...
i tested by going to /emptytest.php and then filling in the field and hitting the button... the language is already defined when you first go to the page and when you click the button, the url in the address bar will change to include the "?ee_lang=whatever" portion... i think the form line in php is really all you need...
give it a try and see how it goes ;)
jeronimo
1st of June 2007 (Fri), 16:50
Thanks a lot.
I am thinking about completely rewrite the script I have
This will certanly help me.
Hope I can find some time in the near future to work on it. I will adapt it to EE needs.
wkitty42
1st of June 2007 (Fri), 19:24
one of the things you may notice in emptytest1.php is that i had to specifically look for the data variable from the form i was posting... i don't have anything about a contact form and, at this time, don't have an idea on how i'd work with that but i think the concept would be the same... specifically grab the var and then work with it to trigger an email post or some such... should be easy enough and you don't have to have the destination of the email in the post vars as it can be coded directly in the post processing section...
jeronimo
22nd of November 2007 (Thu), 11:00
In the end I mannaged to get an working multilangual mail form.
I will make an separate topic to explain everything
www.landmarks.nl/mail.php
vBulletin® v3.6.12, Copyright ©2000-2012, Jelsoft Enterprises Ltd.