Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [Symfony] Internationalization i18 form
lukasz10
post
Post #1





Grupa: Zarejestrowani
Postów: 33
Pomógł: 1
Dołączył: 8.05.2010

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


witam wszystkich
Natrafiłem na pewien problem z tłumaczeniem formularz ich labeli oraz zawartości np selecta, chodzi oczywiscie o klase formularza:
sfLoader::loadHelpers(array('I18N'));
$sub = array('Wszedzie'=>__('Wszedzie'));
$this->setWidgets(array(
'sel' => new sfWidgetFormSelect(array('choices'=> $sub),array('class'=>'sel','id'=>'sell')),
))

$this->widgetSchema->setLabels(array(
'username'=>__('Login')

));
Podwójny podkreślnik działa w widoku, a jak mam poradzić sobie w formularzu
zgóry dzięki za podpowiedz
Go to the top of the page
+Quote Post
Wave
post
Post #2





Grupa: Zarejestrowani
Postów: 332
Pomógł: 6
Dołączył: 13.01.2005

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


Cytat
Calling the Translation Helper Outside a Template

Not all the text that is displayed in a page comes from templates. That's why you often need to call the __() helper in other parts of your application: actions, filters, model classes, and so on. Listing 13-19 shows how to call the helper in an action by retrieving the current instance of the I18N object through the context singleton.

Listing 13-19 - Calling __() in an Action

  1. $this->getContext()->getI18N()->__($text, $args, 'messages');
Go to the top of the page
+Quote Post
lukasz10
post
Post #3





Grupa: Zarejestrowani
Postów: 33
Pomógł: 1
Dołączył: 8.05.2010

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


Nie wiem w jaki sposób twoja podpowiedz ma mi pomoc , np w labelach formularza lub zawartosci selecta w pliku klasy formularza, w kwestii przetlumaczenia tego na inny jezyk, bo task: php symfony i18n:extract frontend en --auto-save mi tego nie gwarantuje, prosiłbym o przykład zastosowania o ile mozna


zgodnie z tym co jest na tej stronie: http://www.symfony-project.org/forms/1_4/e...nd-Localisation
wystarczy do pliku z tlumaczeniem message.xml

$this->setWidgets(array(
'name' => new sfWidgetFormInputText(), // the default label is "Name"
'email' => new sfWidgetFormInputText(), // the default label is "Email"
'body' => new sfWidgetFormTextarea(), // the default label is "Body"
));
<?xml version="1.0" ?>
<xliff version="1.0">
<file original="global" source-language="en" datatype="plaintext">
<body>
<trans-unit>
<source>Name</source>
<target>Nom</target>
</trans-unit>
<trans-unit>
<source>Email address</source>
<target>Adresse email</target>
</trans-unit>
<trans-unit>
<source>Body</source>
<target>Message</target>
</trans-unit>
</body>
</file>
</xliff>

a mi to nie dziala. czemu??
Go to the top of the page
+Quote Post
destroyerr
post
Post #4





Grupa: Zarejestrowani
Postów: 879
Pomógł: 189
Dołączył: 14.06.2006
Skąd: Bytom

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


Może dlatego, że nie włączyłeś w ogóle i18n, może dlatego, że nie wyczyściłeś cache'a, może nie ten katalog tłumaczeń.

@Wave miło, że wstawiłeś kawałek dokumentacji, ale czy o niego chodziło? Przecież formularze nie mają bezpośredniego dostępu do kontekstu. Metody sfContext::getInstance() należy unikać zawsze kiedy tylko można, a w tym przypadku można
Go to the top of the page
+Quote Post
lukasz10
post
Post #5





Grupa: Zarejestrowani
Postów: 33
Pomógł: 1
Dołączył: 8.05.2010

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


wszystko mam właczone bo mi tłumaczy z widoku, przy wykorzystaniu helpera __('') , a formularzu niestety nie

Ten post edytował lukasz10 24.06.2010, 15:08:16
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: 24.08.2025 - 22:07