Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Symfony] 1.4 Zmiana języka strony
Micchaleq
post
Post #1





Grupa: Zarejestrowani
Postów: 186
Pomógł: 4
Dołączył: 13.10.2009

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


Witam serdecznie,


Mam pewien problem nie wiem jak to rozwiązać.

Otóż zrobiłem sobie tłumaczenie strony i chciałbym aby uzytkownik miał możliwość wyboru języka ( to normalne )

język ustawiam sobie za pomocą
$this->getUser()->setCulture('en');

aby go zmienić muszę oczywiście podmienić en na inny, ale po tym muszę wyczyścić pamięć.

Jak teraz zrobić tak by po kliknięciu użytkownik widział ten język który chce widzieć?

W sumie to problemem dla mnie jest czyszczenie sama akcja(kliknięcie ) i powrót są oczywiste.

Ten post edytował Micchaleq 14.02.2012, 10:39:19
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
chemik1982
post
Post #2





Grupa: Zarejestrowani
Postów: 91
Pomógł: 13
Dołączył: 20.03.2007
Skąd: Bydgoszcz

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


Ja to rozwiązałem w taki sposób. W app.yml mam zdefiniowane języki:
  1. all:
  2. cultures:
  3. pl:
  4. title: polski
  5. panel_title: polski
  6. image: pl.png
  7. default: true
  8. en:
  9. title: english
  10. panel_title: angielski
  11. image: gb.png
  12. default: false
  13. de:
  14. title: deutsch
  15. panel_title: niemiecki
  16. image: de.png
  17. default: false
  18. ru:
  19. title: русский язык
  20. panel_title: rosyjski
  21. image: ru.png
  22. default: false


Flagi na froncie pokazuję korzystając z komponentu:

  1. public function executeSwitchI18n() {
  2. $this->routing = sfContext::getInstance()->getRouting();
  3. $uri = $this->routing->getCurrentInternalUri();
  4. $pathinfo = $this->routing->parse($this->request->getPathInfo());
  5. unset($pathinfo['module']);
  6. unset($pathinfo['action']);
  7. unset($pathinfo['sf_culture']);
  8. unset($pathinfo['_sf_route']);
  9. $this->pathinfo = $pathinfo;
  10. $this->module = $this->getRequest()->getParameter('module');
  11. $this->action = $this->getRequest()->getParameter('action');
  12. $this->routingName = $this->routing->getCurrentRouteName();
  13. $this->cultures = sfConfig::get('app_cultures');
  14. }


Podam Ci jeszcze routing.yml

  1. homepage:
  2. url: /:sf_culture/
  3. param: { sf_culture: <?php $languages = sfContext::getInstance()->getRequest()->getLanguages(); echo substr(strip_tags($languages[0]),0,2); ?>, module: home, action: index }
  4. requirements: { sf_culture: (?(IMG:style_emoticons/default/tongue.gif) l|en|de|ru) }
  5. send:
  6. url: /wyslij.html
  7. param: { module: home, action: send }
  8. news:
  9. url: /:sf_culture/aktualnosci/:page
  10. param: { module: news, action: index, page: 1 }
  11. requirements: { sf_culture: (?(IMG:style_emoticons/default/tongue.gif) l|en|de|ru) }
  12. news_entity:
  13. url: /:sf_culture/aktualnosci/:page/:slug
  14. param: { module: news, action: item, page: 1 }
  15. requirements: { sf_culture: (?(IMG:style_emoticons/default/tongue.gif) l|en|de|ru) }
  16. download:
  17. url: /:sf_culture/pliki-do-pobrania.html
  18. param: { module: home, action: download }
  19. requirements: { sf_culture: (?(IMG:style_emoticons/default/tongue.gif) l|en|de|ru) }
  20. contact:
  21. url: /:sf_culture/kontakt
  22. param: { module: pages, action: contact }
  23. requirements: { sf_culture: (?(IMG:style_emoticons/default/tongue.gif) l|en|de|ru) }
  24. gallery:
  25. url: /:sf_culture/galeria-zdjec
  26. param: { module: gallery, action: index }
  27. requirements: { sf_culture: (?(IMG:style_emoticons/default/tongue.gif) l|en|de|ru) }
  28. pages:
  29. url: /:sf_culture/:slug
  30. param: { module: pages, action: index }
  31. requirements: { sf_culture: (?(IMG:style_emoticons/default/tongue.gif) l|en|de|ru) }
  32. default_index:
  33. url: /:module
  34. param: { action: index }
  35. default:
  36. url: /:module/:action/*


A widokiem się pobaw (IMG:style_emoticons/default/wink.gif) .
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 28.12.2025 - 00:40