Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Google Translate Issues w/Javascript Navigation

Status
Not open for further replies.

LOW

Programmer
Sep 27, 2000
45
0
0
US
We're using Google Translate on our site. When we translate a page and hit a regular link to another page, it displays as translated (that's what we want), however when selecting one of our navigation links (which are javascript includes), the new page goes back to English. Does anyone have a workaround for this? Here's an example of a javascript include for navigation:

<div style="text-align:center; margin-top:20px;" class="localTxtNav">

<script type="text/javascript">
var loc;
loc == "home_index";
if (loc == null || loc.length == 0) {loc = "x";}

if (loc == "home_index") {document.write("| Police Department Home ");}
else {document.write("| <a href=\"/police/\">Police Department Home</a> ");}

if (loc == "help_index") {document.write("| Help Us Help You ");}
else {document.write("| <a href=\"/police/help/\">Help Us Help You</a> ");}
if (loc == "recruit_index") {document.write("| Join the SDPD |");}
else {document.write("| <a href=\"/police/recruiting/\">Join the SDPD</a> |");}

</script>
</div>

Any assistance would be most appreciated.
 
Hi

This is why is wrong to use JavaScript for the functional elements of the site : they break automated processing.

Personally I would worry about the search engines' indexer bots first.

So better write a decent HTML document first, then add some JavaScript things only after.

I would do it like this :
CSS:
[purple].no[/purple] [teal]{[/teal]
  [blue]color:[/blue] [green]black[/green];
  [blue]text-decoration:[/blue] [green]none[/green];
  [blue]cursor:[/blue] [green]text[/green];
[teal]}[/teal]
HTML:
[b]<div[/b] [maroon]class[/maroon][teal]=[/teal][green][i]"localTxtNav"[/i][/green] [maroon]id[/maroon][teal]=[/teal][green][i]"nav"[/i][/green][b]>[/b]
[b]<a[/b] [maroon]href[/maroon][teal]=[/teal][green][i]"/police/"[/i][/green][b]>[/b]Police Department Home[b]</a>[/b]
[b]<a[/b] [maroon]href[/maroon][teal]=[/teal][green][i]"/police/help/"[/i][/green][b]>[/b]Help Us Help You[b]</a>[/b]
[b]<a[/b] [maroon]href[/maroon][teal]=[/teal][green][i]"/police/recruiting/"[/i][/green][b]>[/b]Join the SDPD[b]</a>[/b]
[b]</div>[/b]
JavaScript:
[b]var[/b] loc[teal]=[/teal]document[teal].[/teal]location[teal].[/teal]pathname
[b]var[/b] nav[teal]=[/teal]document[teal].[/teal][COLOR=darkgoldenrod]getElementById[/color][teal]([/teal][green][i]'nav'[/i][/green][teal]).[/teal][COLOR=darkgoldenrod]getElementsByTagName[/color][teal]([/teal][green][i]'a'[/i][/green][teal])[/teal]
[b]var[/b] now[teal]=-[/teal][purple]1[/purple]
[b]for[/b] [teal]([/teal][b]var[/b] i[teal]=[/teal][purple]0[/purple][teal],[/teal]l[teal]=[/teal]nav[teal].[/teal]length[teal];[/teal]i[teal]<[/teal]l[teal];[/teal]i[teal]++)[/teal]
  [b]if[/b] [teal]([/teal]loc[teal].[/teal][COLOR=darkgoldenrod]indexOf[/color][teal]([/teal]nav[teal][[/teal]i[teal]].[/teal]href[teal].[/teal][COLOR=darkgoldenrod]replace[/color][teal]([/teal][fuchsia]/^.*?\/\/.*?\//[/fuchsia][teal],[/teal][green][i]'/'[/i][/green][teal]))==[/teal][purple]0[/purple] [teal]&&[/teal] [teal]([/teal]now[teal]==-[/teal][purple]1[/purple] [teal]||[/teal] nav[teal][[/teal]now[teal]].[/teal]href[teal].[/teal]length[teal]<[/teal]nav[teal][[/teal]i[teal]].[/teal]href[teal].[/teal]length[teal]))[/teal]
    now[teal]=[/teal]i
[b]if[/b] [teal]([/teal]now[teal]!=-[/teal][purple]1[/purple][teal])[/teal] nav[teal][[/teal]now[teal]].[/teal]className[teal]=[/teal][green][i]'no'[/i][/green]

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top