It is not really a custom fallback. Reading user's preferred languages
is in my opinion very common in web applications.

We could decrease the overhead and disk usage using symfony's caching
and with separation of logic. I think the way of Zend_Translate is
good. It provides a separate method to get the preferred languages,
which is not part of the core logic. Instead of setting a culture
string, we would have an array. The main logic would handle a culture
string and array. Only developers who wish to use this would set the
culture with an array. The available translations would be read only
once (when caching is enabled, performance is improved even more) and
then there's only php logic without disk use (but memory, that's
true).

Another complication is if I have set the languages "de_CH",
"de_AT" ..., if "de_CH" is not found, it would search for "de". But we
need to check if the next language is starting with "de" too as
"de_AT" could be available.

On 9 Okt., 09:34, Lukas Kahwe Smith <[email protected]> wrote:
> On 08.10.2010, at 22:03, halk <[email protected]> wrote:
>
>
>
>
>
> > Hello all,
>
> > Fabien told us in his keynote on symfony day 2010 in Cologne today,
> > that Symfony2's new Translation component has a fallback for the
> > culture/locale built-in. Fabien gave this example: "fr_FR", "fr",
> > "en". If there is no translation "fr_FR", Symfony2 looks for "fr", if
> > not then "en" (as set in configuration). After Fabien's keynote
> > someone asked him whether the user can define the fallback order.
> > Fabien answered that it is not implemented yet.
>
> > Does Symfony2 read the user's preferred languages from browser? In
> > Zend Framework I can tell ZF to read the browser preference:
>
> > $translate = new Zend_Translate(
> >    'gettext',
> >    APPLICATION_PATH . '/langs',
> >    $locale->getLanguage(),
> >    array(
> >        'scan'           => Zend_Translate::LOCALE_FILENAME,
> >        'disableNotices' => true
> >    )
> > );
>
> > $locale->getLanguage() parses the $_SERVER['HTTP_ACCEPT_LANGUAGE']
> > variable and returns an array of preferred languages. I believe that
> > if the customer/project asks for it and the developer tells Symfony2
> > to do (f.e. as a parameter),  Symfony2 should read this setting and
> > use it for selecting the translation and for fallback.
>
> > F.e. if "de_DE", "tr_TR" and "en_GB" are the preferred languages set
> > in the user's browser, Symfony2 should first look for the translations
> > "de_DE", then "de". If still no match, it should try to find a
> > translation catalogue for the next preferred language, in this case
> > "tr_TR" and if not "tr" etc. If non of the preferred languages
> > matches, Symfony2 will take the culture defined in configuration.
>
> > What do you think? I could write a patch if the idea sounds good for
> > you.
>
> if i understood Fabien properly, the issue is that i order to make the  
> fallback have no overhead the entire logic is applied when the  
> datastructure is generated.
>
> now if you have custom fallbacks this obviously doesnt work anymore.  
> however doing the fallback logic at runtime comes with an overhead.
>
> now depending on the number of languages you have and maybe a sensible  
> estimation of which fallback orders make sense you could boil things  
> down to a smaller number of permutations allowing you again to apply  
> the fallback logic at generation time at the expense of increase disk  
> (and memory) use.
>
> regards
> Lukas

-- 
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 developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en

Reply via email to