Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [SF2][SF] Problem z tlumaczeniem interfejsu - culture nie dziala
swiezak
post
Post #1





Grupa: Zarejestrowani
Postów: 159
Pomógł: 0
Dołączył: 21.08.2011

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


Probuje wdrozyc w swoim projekcie obluge wielu jezykow. Jednak tlumaczenia z pliku messages.en.xlf w ogole nie sa zaczytywane. Byc moze problem tkwi w konfiguracji w ktoryms z plikow yml.

W pliku config.yml mam nastepujace zapisy:
  1. parameters:
  2. locale: pl
  3. framework:
  4. translator: { fallback: ["%locale%"] }
  5. default_locale: pl


Plik routing.yml:
  1. homepage:
  2. pattern: /{culture}
  3. defaults: { _controller: MlFrontendBundle:Default:index, culture: pl }
  4. requirements:
  5. culture: pl|en


Kontroler:
  1. /**
  2.   * @Route("/", name="homepage")
  3.   * @Template()
  4.   */
  5. public function indexAction()
  6. {
  7. return array();
  8. }


layout.twig.html
  1. <li><strong>JĘZYK</strong>
  2. {% if app.request.get('culture') == 'pl' %}
  3. <a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false"> PL <i class="fa fa-angle-down"></i></a>
  4. <ul class="dropdown-menu">
  5. <li><a href="{{ path('homepage', {'culture': 'en'}) }}">EN</a></li>
  6. </ul>
  7. {% endif %}
  8. {% if app.request.get('culture') == 'en' %}
  9. <a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false"> EN <i class="fa fa-angle-down"></i></a>
  10. <ul class="dropdown-menu">
  11. <li><a href="{{ path('homepage', {'culture': 'pl'}) }}">PL</a></li>
  12. </ul>
  13. {% endif %}
  14. </li>


Plik z tlumaczeniem interfejsu:
  1. <?xml version="1.0"?>
  2. <xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
  3. <file source-language="pl" datatype="plaintext" original="file.ext">
  4. <body>
  5. <trans-unit id="1">
  6. <source>JĘZYK</source>
  7. <target>LANGUAGE</target>
  8. </trans-unit>
  9. <trans-unit id="2">
  10. <source>Wyślij</source>
  11. <target>Send</target>
  12. </trans-unit>
  13. ...
  14. </body>
  15. </file>
  16. </xliff>


W templatce wywoluje tlumaczenie w ten sposob:
  1. {% trans %}Wyślij{% endtrans %}


Prosze o podpowiedz, gdzie popelnilem blad i jak go naprawic.

Ten post edytował swiezak 9.02.2016, 20:28:55
Go to the top of the page
+Quote Post
kpt_lucek
post
Post #2





Grupa: Zarejestrowani
Postów: 428
Pomógł: 77
Dołączył: 10.07.2011
Skąd: Warszawa

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


Adnotacja nadpisuje Ci config z yml.

Poczytaj o prefix'ach


--------------------


Cytat
There is a Bundle for that
Lukas Kahwe Smith - October 31th, 2014
Go to the top of the page
+Quote Post
swiezak
post
Post #3





Grupa: Zarejestrowani
Postów: 159
Pomógł: 0
Dołączył: 21.08.2011

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


Dzieki za poswiecony czas i podpowiedz. Rzeczywiscie adnotacja okazala sie problematyczna. Po drobnych modyfikacjach w kodzie wszystko dziala jak nalezy.

Pozdrawiam.
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 Aktualny czas: 20.08.2025 - 04:29