Iāl try to explain better what i got. I have a file "java_php_test.php in this file i have the code:
<?php include_once 'common.php';?> and i also have a code for a Responsive menu. And i'm using a software to make the webpage. To this software there's an add on software called the Extension builder. U can use this to make Extensions/Add ons to the main software. So the values for the Menu Links/Items is coming from an XSL file this file is called menu_php.xsl, it's a little difficult to explain exactly how this works but the code in this file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match='/'>
<ul>
<xsl:for-each select="DATASET/ITEM">
<li id="{SELECTEDMENU}"><a href="{URL}" id="{LINKNUM}"><xsl:value-of select="MENUNAME"/></a></li>
</xsl:for-each>
</ul>
</xsl:template>
</xsl:stylesheet>
But i cant put in the <?echo $lang['MENU_HOME']; ?> code to the XSL file, so this i wy i need a java script to change the text.
//Responsive Menu Code Looks Like This:
<link rel="stylesheet" href="rmm-css/responsivemobilemenu.css"/>
<script src="rmm-js/responsivemobilemenu.js"></script>
<div class='rmm' data-menu-title = "Navigation" data-menu-style = "custom">
<ul><li id="current_yes"><a href="#" id="one">HEM</a></li><li id="current_no"><a href="#" id="two">KONTAKTA OSS</a></li></ul>
</div>
Then i have this code to change the HEM and KONTAKTA to HOME and CONTACT US:
<script>
var word = 'HEM';
var sent = $('#one').html().replace(word, '<?echo $lang['MENU_HOME']; ?>');
$('#one').html(sent);
</script>
<script>
var word = 'KONTAKTA OSS';
var sent = $('#two').html().replace(word, '<?echo $lang['MENU_CONTACT_US']; ?>');
$('#two').html(sent);
</script>
And the code in the common.php file look like this:
<?php
session_start();
header('Cache-control: private'); // IE 6 FIX
if(isSet($_GET['lang']))
{
$lang = $_GET['lang'];
// register the session and set the cookie
$_SESSION['lang'] = $lang;
setcookie("lang", $lang, time() + (3600 * 24 * 30));
}
else if(isSet($_SESSION['lang']))
{
$lang = $_SESSION['lang'];
}
else if(isSet($_COOKIE['lang']))
{
$lang = $_COOKIE['lang'];
}
else
{
$lang = 'en';
}
switch ($lang) {
case 'en':
$lang_file = 'lang.en.php';
break;
case 'de':
$lang_file = 'lang.de.php';
break;
case 'es':
$lang_file = 'lang.es.php';
break;
case 'se':
$lang_file = 'lang.se.php';
break;
default:
$lang_file = 'lang.en.php';
}
include_once 'languages/'.$lang_file;
?>
i then have 3 files that are named: lang.se.php, lang.en.php and lang.de.php the code in these files looks like this:
<?php
/*
------------------
Language: English
------------------
*/
$lang = array();
$lang['PAGE_TITLE'] = 'My website page title';
$lang['HEADER_TITLE'] = 'My website header title';
$lang['SITE_NAME'] = 'My Website';
$lang['SLOGAN'] = 'My slogan here';
$lang['HEADING'] = 'Heading';
// Menu
$lang['MENU_HOME'] = 'HOME';
$lang['MENU_ABOUT_US'] = 'About Us';
$lang['MENU_OUR_PRODUCTS'] = 'Our products';
$lang['MENU_CONTACT_US'] = 'CONTACT US';
$lang['MENU_ADVERTISE'] = 'Advertise';
$lang['MENU_SITE_MAP'] = 'Site Map';
// MAIN TEXT 1
$lang['MAINTEXTONE'] = 'This is a test for the main text 1';
?>
this is the lang.en.php file the others are just translated.
Then i have links to these files like this: http://test3.fcab.se/menu_lang_test/java_php_test.php?lang=se
http://test3.fcab.se/menu_lang_test/java_php_test.php?lang=en
http://test3.fcab.se/menu_lang_test/java_php_test.php?lang=de
I dont know if this helps or only complicates things but i can promise that it works.
Thank you all for your help.
Demo page here