Am Di 10. Apr 2012, 19:13:55, SHAW schrieb:
Show quoted text> These lines of code are a performance killer:
>
> for (@sorted) {
> $list{$_} = $lcm->country2code( $_, 'LOCALE_CODE_ALPHA_2', $lang );
> }
Is suspected something like that but wasn´t aware that the performance
penalty was that severe.
At the time of writing I wasn´t absolutely sure if
Locale::Country::Multilingual would always return the same number of
codes or names in the exact same order for every call to
"all_country_codes" or "all_country_names($lang)" using any possible
language.
Otherwise I´d have written something like:
my %countries = ();
@countries{ $lcm->all_country_names($lang) } = $lcm->all_country_codes;
(By the way: I was really surprised to see that using "zip" is even
faster - if only marginally - than the hash slice assignment...)
Show quoted text
I´ve adopted most of that for
https://metacpan.org/release/HJANSEN/Mojolicious-Plugin-CountryDropDown-0.0502-TRIAL/
Show quoted text> If your going to allow the user to select what code format they
> should use (which probably isn't a bad idea)
Haven´t done that yet. Will look into it before releasing the next
non-DEV version.
Show quoted text> * Maybe you should consider stubbing out the language specific
> country names to a localization framework..?
Don´t really understand what you´re driving at, here.
Show quoted text> * A way to prioritize countries. For example in the USA you might
> want Canada, Mexico, and USA at the top or the list.
Added some support for that.
Show quoted text> * Select multiple options
Haven´t tried yet but shouldn´t that be just a matter of providing the
appropriate HTML attributes (and therefore already be possible)?
Show quoted text> * I'd also drop show_country_list. Not sure how useful it is to have
> an HTML fragment in the stash.
It´s gone.
Show quoted text> * (Nitpicking here) maybe even rename the country_drop_down to
> country_select_field to be in line with Mojo conventions/lingo.
Looks like it´d make sense. Done.
Show quoted text> I'm willing to help!
So I recognized ;-)
Heiko