thanks for your reply and your advices, I will try to extend the sfi18n class.
On 3月20日, 上午3時35分, "rooster (Russ)" <russmon...@gmail.com> wrote: > The i18n helper is quite simple in what it does. If it does not find a > target translation it will simply return what was passed. > > You have a few of ways to get round this: > > 1. Write your own (override the) __() function So it checks if the > string returned is identical, if it is - then you can invoke the i18n > call again with the culture set to "en". So instead of loading helper > i18n, you load myI18n (or whatever) > 2. Extend the sfI18n class (change in factories.yml to yourI18n class > and extend sfI18n) - change the behaviour there > > Probably a few others - but the bottom line is that the symfony i18n > helper does not support what you are trying to do, as the "normal" > behaviour is to write your __("key") using the fallback language. This > has much less overhead than falling back to an entirely new catalogue > every time a string is not found. > > Russ. > > On Mar 19, 2:40 am, Andy Cheung <andychi...@gmail.com> wrote: > > > > > Hello, > > > I would like to ask if it is possible to return another language > > translation instead of the input when there is no translation for the > > user's current language. > > > For example: > > > in the template: > > <?php echo __('[HELLO]'); ?> > > > in a translation in 'en' > > <trans-unit id="1"> > > <source>[HELLO]</source> > > <target>Hello</target> > > </trans-unit> > > > OK, when the user reads the page in 'en', the > > [HELLO] message is translated without problem, > > but if the user changes to another language say 'fr', > > and I have not defined this translation for fr, then > > it will display [HELLO](the input value). > > > However, what I want is that to return > > the en translation as default. > > > I am doing the translation like this because > > the wording of the default language(en) may change frequently > > but not it other language, and it will be very annoying if > > I change the <source> for other language every time. > > > Hope someone gives me advice, thanks! -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en To unsubscribe from this group, send email to symfony-users+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.