[development] [VERY LONG] localization of currency, float, dates accordingly to language chosen

Ivan Sergio Borgonovo mail at webthatworks.it
Thu Oct 11 16:04:47 UTC 2007


On Thu, 11 Oct 2007 16:34:52 +0200
"Gábor Hojtsy" <gabor at hojtsy.hu> wrote:

> On 10/11/07, Ivan Sergio Borgonovo <mail at webthatworks.it> wrote:
> > My general feeling is that translations and taxonomies are too
> > highly coupled... I won't comment further without some more
> > knowledge on my part of the current status, but I think you got
> > an idea about what I mean from my previous email.
> 
> Hint: we did not do any taxonomy translation in Drupal 6, so they
> are neither coupled or not.

uh reading your thesis I thought you had implemented a sort of t()
for taxonomy.

> > I ask you just a bit of patience more for my rudeness but at this
> > time my module is agnostic of the drupal version and non Italian
> > content still have to be thought... but I need a smooth path to
> > have localised strings (dates, float, currency...). Any help on
> > this?

> From what you explained, your module might solve all Drupal i18n
> problems, so it is probably too complex for me to look at. Although
> I have not seen any from that, so it is quite hard to give any
> suggestions.

That's another module... doing something absolutely different from
localisation but I need a bit of localisation right now (dates, float
etc...) It would be nice if I could switch to drupal 6 smoothly.
I could go straight to some hack functions in this module doing
something completely different from i18n and just write 2 functions
that take some variable defined in admin/settings and the user
selected language for interface and format string accordingly.
If these functions could be integrated in the future of drupal 6
framework it would be better.

Ths is my rough idea:
You provide a couple of cfg more in admin/settings/locale
date format: "Y-m-d" float:... on each language line
Then you could add in each user profile
user/1/edit
Interface language:
language:
X
Y
Z
follow content
string localisation:
X
Y
Z
follow content
follow interface

and use functions like

function drupal_number_format($number,$locale=null) {
  if(!$locale) {
  if(isset($user->string_locale)) {
    $locale=$user->string_locale;
  } else {
	$locale=locale_criteria($user->language,$node->language);
  }
  return
number_format($number,$locale->number_format($locale));
}

where $locale->number_format[1] should return the string set into the
admin/settings/locale for the proper locale.

for my need I'd just set the locale the same as the language of the
user.

so I'd write mockup that have reasonable default param and some empty
function to return always the same stuff so I could keep the
outermost function interface constant.

[1] I saw that these values get stored into {locales_meta}, but I
didn't have the time to see in which object they are stored or what
is the halal way to get them through drupal api.


> > I read in your thesis:
> > "Local functionality By implementing a custom install profile, I
> > distributed the Hungar- ian interface translation with local
> > functionality for Hungarian date format support and features for
> > common hosts, beginning with Drupal 5.1 [38]."
> >
> > Just dates? what about float? is this stuff already ready and
> > hidden somewhere in the source of 5.2?

> I needed Hungarian date support + I did not need to modify how
> floating point stuff is presented + Nobody else contributed that =
> It is not there.

OK... you've read my rough proposal... any idea about how to make it
Drupal 6 friendly/portable?

-- 
Ivan Sergio Borgonovo
http://www.webthatworks.it



More information about the development mailing list