Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Zmiana języka kodu strony, Dosc trudna/dziwna sprawa
Watt
post 1.04.2010, 19:22:44
Post #1





Grupa: Zarejestrowani
Postów: 372
Pomógł: 1
Dołączył: 13.06.2008

Ostrzeżenie: (0%)
-----


Witam,

Wie ktoś może jak zmienić jezyk strony - mam kod który ma się pokazać i przed jego pokazaniem przeżucić do translatora, aby zmienił język? Jest coś takiego możliwe?

Ten post edytował Watt 1.04.2010, 19:53:00
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 8)
Pawel_W
post 1.04.2010, 19:33:03
Post #2





Grupa: Zarejestrowani
Postów: 1 675
Pomógł: 286
Dołączył: 15.06.2009
Skąd: Wieliczka

Ostrzeżenie: (0%)
-----


tak, jest to możliwe, musisz połączyć się z translatorem, przesłać mu dane i przechwycić wynik, następnie go wyświetlić smile.gif
Go to the top of the page
+Quote Post
Watt
post 1.04.2010, 19:35:46
Post #3





Grupa: Zarejestrowani
Postów: 372
Pomógł: 1
Dołączył: 13.06.2008

Ostrzeżenie: (0%)
-----


  1. $link = 'http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=' .
  2. urlencode($kodstrony) .
  3. '&langpair=' . $langstrony . '%7C' .
  4. $langwyjsciowy;


Napisałem coś takiego, ale zwraca pusty wynik - może urlencode() coś zawala?
Go to the top of the page
+Quote Post
Pawel_W
post 1.04.2010, 19:40:35
Post #4





Grupa: Zarejestrowani
Postów: 1 675
Pomógł: 286
Dołączył: 15.06.2009
Skąd: Wieliczka

Ostrzeżenie: (0%)
-----


no dobra, ale co to ma robić? bo z tego nic nie wynika, poza przypisaniem do $link ciągu znaków smile.gif
Go to the top of the page
+Quote Post
Watt
post 1.04.2010, 19:43:29
Post #5





Grupa: Zarejestrowani
Postów: 372
Pomógł: 1
Dołączył: 13.06.2008

Ostrzeżenie: (0%)
-----


Aj, źle skopiowałem
  1. $link = 'http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=' .
  2. urlencode($kodstrony) .
  3. '&langpair=' . $langstrony . '%7C' .
  4. $langwyjsciowy;
  5.  
  6.  
  7. $kodstrony = file_get_contents($link);
  8.  


Z tym, że $kodstrony jest pusty - nie zwraca wyniku, a np.

http://ajax.googleapis.com/ajax/services/l...;langpair=pl|en

To działa jak ręcznie wpiszę.
Go to the top of the page
+Quote Post
Pawel_W
post 1.04.2010, 19:52:57
Post #6





Grupa: Zarejestrowani
Postów: 1 675
Pomógł: 286
Dołączył: 15.06.2009
Skąd: Wieliczka

Ostrzeżenie: (0%)
-----


na pewno wszystko masz?

bo u mnie to:
  1. <?php
  2. $kodstrony = "Lubie placki";
  3. $langstrony = "pl";
  4. $langwyjsciowy = "en";
  5. $link = 'http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q='.urlencode($kodstrony).'&langpair=' . $langstrony.'%7C'.$langwyjsciowy;
  6. $kodstrony = file_get_contents($link);
  7. echo $kodstrony;
  8. ?>

działa smile.gif
Go to the top of the page
+Quote Post
Watt
post 1.04.2010, 20:08:04
Post #7





Grupa: Zarejestrowani
Postów: 372
Pomógł: 1
Dołączył: 13.06.2008

Ostrzeżenie: (0%)
-----


Kod strony to nie lubie placki, dla mnie przykładowo kod tej strony to:
Kod
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-2" />
<link rel="shortcut icon" href="favicon.ico" />
<title>[PHP]Zmiana języka kodu strony - Forum PHP.pl</title>
<meta name="Keywords" content="php, mysql, pomoc, programowanie, oop, php5, interfejs, abstrakcja, xml, ajax" />
<meta name="description" content="Raczkujesz w tematyce WWW (PHP, SQL, (X)HTML, CSS, JS, XML, AJAX)? ... Jeśli masz problem ze skryptem php tutaj jest odpowiednie miejsce, aby znaleźć odpowiedź; na Twoje pytania." />
<link rel="alternate" type="application/rss+xml" title="Forum PHP.pl - tematy" href="http://forum.php.pl/index.php?act=rssout&id=1" />
<link rel="alternate" type="application/rss+xml" title="Forum PHP.pl - posty" href="http://forum.php.pl/index.php?act=rssout&id=2" />
<link rel="alternate" type="application/rss+xml" title="Przedszkole - tematy" href="http://forum.php.pl/index.php?act=rssout&id=3" />
<link rel="alternate" type="application/rss+xml" title="PHP - tematy" href="http://forum.php.pl/index.php?act=rssout&id=4" />
<link rel="alternate" type="application/rss+xml" title="Po stronie przeglądarki - tematy" href="http://forum.php.pl/index.php?act=rssout&id=5" />
<link rel="alternate" type="application/rss+xml" title="Giełda ofert" href="http://forum.php.pl/index.php?act=rssout&id=6" />
<link rel="alternate" type="application/rss+xml" title="Praca oferowana (Job offers)" href="http://forum.php.pl/index.php?act=rssout&id=7" />
<link rel="alternate" type="application/rss+xml" title="Newsy" href="http://forum.php.pl/index.php?act=rssout&id=8" />


<style type="text/css" media="all">

@import url(http://forum.php.pl/style_images/css_10.css);

</style>
<style type="text/css" media="all">

@import url(style_images/top.css);
@import url(style_images/geshi.css);
</style>


<!--[if IE 6]>
<style type="text/css" media="all">
@import url(style_images/ie6-fix.css);
</style>
<![endif]-->

<!--[if IE 7]>
<style type="text/css" media="all">
@import url(style_images/ie7-fix.css);
</style>
<![endif]-->

<!-- Extra Style -->
<link id="topstyle" rel="stylesheet" type="text/css" href="./" />

<script type="text/javascript" src="./addons/jQuery/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="./addons/jQuery/jquery.cookie.js"></script>
<script type="text/javascript" src="./addons/jQuery/superfish/superfish.js"></script>

<script type="text/javascript" src="./addons/jQuery/hwao-adds.js"></script>
<script type="text/javascript" src="./jscripts/easter-eggs.js"></script>



<style type='text/css'>
@import url( "http://forum.php.pl/style_images/upgrade_ip/folder_editor_images/css_rte.css" );
</style>
<link rel="search" type="application/opensearchdescription+xml" title="Szukaj na forum.php.pl" href="search.xml" />
</head>
<body>

<div id="hwao-topbar">
   <div id="background-color-switch">

      <ul></ul>
   </div>

  
      
<div id="hwao-topbar-left">

<strong>Witaj <a href="____Watt_m35165.html">    Watt</a>!</strong> (<a href="http://forum.php.pl/wylogowanie.html&k=72d290ba9cc2f9891feefef9b598d2a2">Wyloguj</a>)

      
   </div>




   <div id="hwao-topbar-right">


...
...
...
...
...


</body>
</html>


Problem jest w tym, że tego nie chce zmienić.

Ten post edytował Watt 1.04.2010, 20:08:53
Go to the top of the page
+Quote Post
Pawel_W
post 1.04.2010, 20:18:40
Post #8





Grupa: Zarejestrowani
Postów: 1 675
Pomógł: 286
Dołączył: 15.06.2009
Skąd: Wieliczka

Ostrzeżenie: (0%)
-----


o ile wiem to przez $_GET można przesłać określoną ilość znaków, dlatego to może nie działać

EDIT:
a dlaczego nie skorzystasz z gotowego translatora google?
http://translate.google.com/translate_tool...sl=de&tl=pl

Ten post edytował Pawel_W 1.04.2010, 20:20:01
Go to the top of the page
+Quote Post
Watt
post 1.04.2010, 21:59:51
Post #9





Grupa: Zarejestrowani
Postów: 372
Pomógł: 1
Dołączył: 13.06.2008

Ostrzeżenie: (0%)
-----


Może masz jakiś pomysł, żeby rozwiązać mój problem?

Dlaczego nie?
1. JS, nie każdy ma odpalone
2. Np title tym nie zmienie
3. Chciałbym móc to przerobic w php

Wklejenie kodu tu: http://translate.google.pl/# działa.

  1. $t = new GoogleTranslate;
  2.  
  3. //set input and output language:
  4.  
  5. $t->inLang = 'en';
  6. $t->outLang = 'de';
  7.  
  8. //translate
  9. $piece = explode("\n", $contents);
  10. $contents = "";
  11. $u = 30;
  12. for($z; $z < ceil(count($piece)/30); $z++)
  13. {
  14. for($i = 0; $i <= $u; $i++)
  15. {
  16. $pieces = $piece[$i]."\n".$pieces;
  17. $u++;
  18. }
  19. $result = $t->translate($pieces);
  20. $results = $result."\n".$results;
  21. $pieces = "";
  22. }
  23.  
  24.  
  25. $contents = $results;
  26.  
  27.  
  28.  
  29. return $contents;


Myślałem nad czymś takim, ale:

Fatal error: Maximum execution time of 30 seconds exceeded

Może jakieś pomysły?

Ten post edytował Watt 2.04.2010, 07:16:14
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 08:17