Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [Symfony] wielojęzyczność
blackroger
post
Post #1





Grupa: Zarejestrowani
Postów: 176
Pomógł: 0
Dołączył: 8.11.2008

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


Oto routing:

  1. homepage:
  2. url: /:sf_culture/
  3. param: { module: main, action: index }
  4. requirements:
  5. sf_culture: (?(IMG:style_emoticons/default/tongue.gif) l|en)
  6.  



Chcę otrzymać takie coś:
wpisuję domena.pl/ - domyślnie polska wersja
wpisując domena.pl/en/ - angielska wersja


Czy istnieje możliwość aby po prostu nie ustalać domeny polskiej poprzez /pl/ bo to jest niepotrzebne i tylko w przypadku innego niż polski języka dawać. Nie wiem czy to się nie kłóci z zasadami routingu. Proszę o odpowiedź.

Teraz aby to osiągnąć robię :


  1.  
  2. homepage2:
  3. url: /
  4. param: { module: main, action: index }
  5.  
  6.  
  7.  
  8. homepage:
  9. url: /:sf_culture/
  10. param: { module: main, action: index }
  11. requirements:
  12. sf_culture: (?(IMG:style_emoticons/default/tongue.gif) l|en)
  13.  
  14.  



ale musiałbym wszędzie dublować adresy.... a tak nie chce

hmm...dodatkowo mam pytanie....co właściwie oznacza

sf_culture: (? (IMG:style_emoticons/default/tongue.gif) l|en) (IMG:style_emoticons/default/questionmark.gif) ?

Głównie chodzi mi o ten znak zapytania...

Ten post edytował blackroger 1.05.2011, 17:12:55
Go to the top of the page
+Quote Post
jaro87
post
Post #2





Grupa: Zarejestrowani
Postów: 53
Pomógł: 7
Dołączył: 10.03.2011
Skąd: Wrocław

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


Spróbuj czegoś takiego:

  1. homepage:
  2. url: /:sf_culture
  3. param: { module: main, action: index, sf_culture: pl } #domyślnie pl
  4. requirements:
  5. sf_culture: (?(IMG:style_emoticons/default/tongue.gif) l|en)
  6.  


?(IMG:style_emoticons/default/tongue.gif) l|en to wyrażenie regularne. Znak zapytania to część składni.
http://www.roscripts.com/PHP_regular_expre...amples-136.html

Ten post edytował jaro87 4.05.2011, 12:06:06
Go to the top of the page
+Quote Post
blackroger
post
Post #3





Grupa: Zarejestrowani
Postów: 176
Pomógł: 0
Dołączył: 8.11.2008

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


Niestety nie działa (IMG:style_emoticons/default/sad.gif) zapętla się...


Przedstawię jeszcze raz sytuację, może krócej i prościej....
Aktualnie mam:

firstHomepage:
url: /
param: { module: main, action: index }

homepage:
url: /:sf_culture/
param: { module: main, action: index }
requirements:
sf_culture: (?(IMG:style_emoticons/default/tongue.gif) l|en)



tak wygląda strona startowa:

  1. //culture section
  2. $request = $this->getRequest();
  3. $lang = $this->getUser()->getCulture();
  4.  
  5. if(!$request->getParameter('sf_culture'))
  6. {
  7. if($this->getUser()->isFirstRequest())
  8. {
  9. $lang = $request->getPreferredCulture(array('pl', 'en'));
  10. $this->getUser()->setCulture($lang);
  11. $this->getUser()->isFirstRequest(false);
  12. }
  13.  
  14. $this->getController()->redirect('@homepage');
  15. }


Za każdym razem jak daje domena.pl/ to mnie przekierowuja na domena.pl/pl/ lub en/ w zależności.

Nie chcę żeby w adresie był znak /pl/ chcę aby te prefixy były dodawane tylko dla języków innych niż pl. Próbowałem już nawet w pathInfoArray w sfWebRequest wstawić formułkę usuwającą z adresu pl ale niestety te wartości są dodawane później i nie wiem dokłądnie jak to ugryźć.....

Proszę o pomoc...

Znalazłem podobny wątek na innym forum: http://groups.google.com/group/symfony-use...c63a3bb026f4dd9

Ale tam zalecają tworzyć dwa routingi do każdej akcji. Wydaje mi się to dziwne i jakies takie niezdarne....

To pomoże mi ktos? (IMG:style_emoticons/default/smile.gif)

Ten post edytował blackroger 4.05.2011, 18:24:13
Go to the top of the page
+Quote Post
jaro87
post
Post #4





Grupa: Zarejestrowani
Postów: 53
Pomógł: 7
Dołączył: 10.03.2011
Skąd: Wrocław

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


Jak stworzysz osobną akcję na zmianę języka nie będziesz miał żadnego zapętlenia.
Go to the top of the page
+Quote Post
arecki
post
Post #5





Grupa: Zarejestrowani
Postów: 222
Pomógł: 35
Dołączył: 6.02.2005

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


Ja używam czegoś takiego:
  1. homepage:
  2. url: /
  3. param: { module: pages, action: index, culture: pl }
  4.  
  5. default_lang:
  6. url: /:culture
  7. requirements: { culture: (?(IMG:style_emoticons/default/tongue.gif) l|en|de) }
  8. param: { module: pages, action: index }
  9.  
  10. default_index:
  11. url: /:culture/:module
  12. requirements: { culture: (?(IMG:style_emoticons/default/tongue.gif) l|en|de) }
  13. param: { action: index }
  14.  
  15. default:
  16. url: /:culture/:module/:action/*
  17. requirements: { culture: (?(IMG:style_emoticons/default/tongue.gif) l|en|de) }
  18.  

Go to the top of the page
+Quote Post

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: 27.09.2025 - 16:58