Hi
Is there a parallel to Format/NumberFormat/DecimalFormat in ruby?
Thanks
Venkat
···
--
Posted via http://www.ruby-forum.com/.
Hi
Is there a parallel to Format/NumberFormat/DecimalFormat in ruby?
Thanks
Venkat
--
Posted via http://www.ruby-forum.com/.
printf, sprintf and % operator for String comes to mind.
Kind regards
robert
On 30.07.2009 00:32, Venkat Akkineni wrote:
Is there a parallel to Format/NumberFormat/DecimalFormat in ruby?
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
Robert Klemme wrote:
Is there a parallel to Format/NumberFormat/DecimalFormat in ruby?
printf, sprintf and % operator for String comes to mind.
Kind regards
robert
Thanks for the reply. But as you know java.text api provides the
facility to handle dates, text, numbers in a language independent
manner. In other words of sayin it will let you set date formats ,
number operators etc based on the locale you are dealing with. We have
resorted to writing an API after failing to find one.
Thanks again
Venkat
Did you look at stftime? Perhaps you could provide a concrete example of
what you're trying to do? Chances are that it's already been done.
James
On Thu, Jul 30, 2009 at 12:17 PM, Venkat Akkineni < venkatram.akkineni@gmail.com> wrote:
Robert Klemme wrote:
> On 30.07.2009 00:32, Venkat Akkineni wrote:
>> Is there a parallel to Format/NumberFormat/DecimalFormat in ruby?
>
> printf, sprintf and % operator for String comes to mind.
>
> Kind regards
>
> robertThanks for the reply. But as you know java.text api provides the
facility to handle dates, text, numbers in a language independent
manner. In other words of sayin it will let you set date formats ,
number operators etc based on the locale you are dealing with. We have
resorted to writing an API after failing to find one.Thanks again
Venkat
--
Posted via http://www.ruby-forum.com/\.
Robert Klemme wrote:
Is there a parallel to Format/NumberFormat/DecimalFormat in ruby?
printf, sprintf and % operator for String comes to mind.
Thanks for the reply. But as you know java.text api provides the facility to handle dates, text, numbers in a language independent manner.
Well, that's what you get with incomplete specifications. You did not mention that you need the locale awareness of those.
In other words of sayin it will let you set date formats , number operators etc based on the locale you are dealing with. We have resorted to writing an API after failing to find one.
AFAIK there is no locale aware version of the *printf family of methods. Maybe there's a gem though or a pointer in RAA.
Kind regards
robert
On 30.07.2009 18:17, Venkat Akkineni wrote:
On 30.07.2009 00:32, Venkat Akkineni wrote:
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
James Herdman wrote:
Did you look at stftime? Perhaps you could provide a concrete example of
what you're trying to do? Chances are that it's already been done.James
On Thu, Jul 30, 2009 at 12:17 PM, Venkat Akkineni <
I am trying to translate an application from java to ruby. The actual
application uses decimal formats to provide localization facilities. I
have the code that I am trying to translate which I will attach with the
post.
char decimal = '.';
char grouping = ',';
String formatOutput = null;
String formatInternal = null;
DecimalFormatSymbols dfs = new DecimalFormatSymbols();
dfs.setDecimalSeparator(decimal);
dfs.setGroupingSeparator(grouping);
DecimalFormatSymbols dfsEsp = new DecimalFormatSymbols();
dfsEsp.setDecimalSeparator('.');
dfsEsp.setGroupingSeparator(',');
FormatCouple fc;
fc = new FormatCouple(new DecimalFormat(formatOutput, dfs), new
DecimalFormat(formatInternal,
dfsEsp));
hasFormats.put(formatName, fc);
Any help is appreciated.
Thanks
Venkat
--
Posted via http://www.ruby-forum.com/\.
Well, that's what you get with incomplete specifications. You did not
mention that you need the locale awareness of those.
Lesson Learned: Better the specification better the answer. In my
defense, I think my mind was wandering around the strippers I have seen
last night. cheers.
AFAIK there is no locale aware version of the *printf family of methods.
Maybe there's a gem though or a pointer in RAA.Kind regards
robert
Thanks For the answer
Okay. So sample input and output? Normally I'd parse through the Java,
but I'm feeling a little lazy.
Subtle but poignant. Well I don't have a testcase for the class which is
hindering me from posting an output.
The above code actually replaces the conventional numeric symbols used
in English speaking nations with any available local (i.e local to a
nation where it is being used) symbols. Thats about it.
As a solution we are just translating the java.text api into ruby as it
saves time in drafting our own api and it would mean adoption of a
stable draft developed by fully dedicated team. Comments, criticisms and
thoughts are welcome. If things go well we intend to offer the api as a
gem.
Thanks
Venkat
--
Posted via http://www.ruby-forum.com/\.
Okay. So sample input and output? Normally I'd parse through the Java, but
I'm feeling a little lazy.
James
On Thu, Jul 30, 2009 at 1:21 PM, Venkat Akkineni < venkatram.akkineni@gmail.com> wrote:
James Herdman wrote:
> Did you look at stftime? Perhaps you could provide a concrete example of
> what you're trying to do? Chances are that it's already been done.
>
> James
>
> On Thu, Jul 30, 2009 at 12:17 PM, Venkat Akkineni <I am trying to translate an application from java to ruby. The actual
application uses decimal formats to provide localization facilities. I
have the code that I am trying to translate which I will attach with the
post.char decimal = '.';
char grouping = ',';
String formatOutput = null;
String formatInternal = null;DecimalFormatSymbols dfs = new DecimalFormatSymbols();
dfs.setDecimalSeparator(decimal);
dfs.setGroupingSeparator(grouping);
DecimalFormatSymbols dfsEsp = new DecimalFormatSymbols();
dfsEsp.setDecimalSeparator('.');
dfsEsp.setGroupingSeparator(',');
FormatCouple fc;
fc = new FormatCouple(new DecimalFormat(formatOutput, dfs), new
DecimalFormat(formatInternal,
dfsEsp));
hasFormats.put(formatName, fc);Any help is appreciated.
Thanks
Venkat
--
Posted via http://www.ruby-forum.com/\.
Have a look at mutoh's gettext package[1], a rubyish implementation of
GNU's gettext.
It is a mature message translation system of all purpose. You may
think it is good
to implement i18n'ed formatter of date/time/number etc atop of it.
2009/7/31 Venkat Akkineni <venkatram.akkineni@gmail.com>:
As a solution we are just translating the java.text api into ruby as it
saves time in drafting our own api and it would mean adoption of a
stable draft developed by fully dedicated team. Comments, criticisms and
thoughts are welcome. If things go well we intend to offer the api as a
gem.
--
OZAWA Sakuro
Well, that's what you get with incomplete specifications. You did not
mention that you need the locale awareness of those.Lesson Learned: Better the specification better the answer. In my defense, I think my mind was wandering around the strippers I have seen last night. cheers.
No problem at all - it happens all the time.
The above code actually replaces the conventional numeric symbols used in English speaking nations with any available local (i.e local to a nation where it is being used) symbols. Thats about it.
As a solution we are just translating the java.text api into ruby as it saves time in drafting our own api and it would mean adoption of a stable draft developed by fully dedicated team. Comments, criticisms and thoughts are welcome. If things go well we intend to offer the api as a gem.
You could do something like this (untested):
LOCALE_SYMBOLS_US = {
'%.' => '.',
'%,' => ',',
}
def lprintf(pattern, *args)
# emulate locale aware lookup
syms = LOCALE_SYMBOLS_US
pat = pattern.gsub(Regexp.new(Regexp.union(syms.keys))) do |m|
syms[m] || ''
end
printf(pat, *args)
end
The symbols then should really come from a resource file selected via the current locale.
Kind regards
robert
On 31.07.2009 13:30, Venkat Akkineni wrote:
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
OZAWA Sakuro wrote:
2009/7/31 Venkat Akkineni <venkatram.akkineni@gmail.com>:
As a solution we are just translating the java.text api into ruby as it
saves time in drafting our own api and it would mean adoption of a
stable draft developed by fully dedicated team. Comments, criticisms and
thoughts are welcome. If things go well we intend to offer the api as a
gem.Have a look at mutoh's gettext package[1], a rubyish implementation of
GNU's gettext.
It is a mature message translation system of all purpose. You may
think it is good
to implement i18n'ed formatter of date/time/number etc atop of it.
Thanks for the information Ozawa. I have noticed that you are
one of the developers. Could you point me to specific comprehensive
resources that will help me research and understand the workings of the
library. I found some documents on Yotabanana.
Thankyou once again.
Venkat
--
Posted via http://www.ruby-forum.com/\.
I realize that the gettext gem is a simili to java's resourcebundle
hence will help me load key value resources from .po files(.properties
files in java). Definately saved me considerable amoount of work.
Thanks
Venkat
--
Posted via http://www.ruby-forum.com/.
I don't have much, but firstly I recommend you to visit GNU's gettext page
(gettext - GNU Project - Free Software Foundation ) and learn its design and philosophy.
2009/8/1 Venkat Akkineni <venkatram.akkineni@gmail.com>:
Could you point me to specific comprehensive
resources that will help me research and understand the workings of the
library. I found some documents on Yotabanana.
--
OZAWA Sakuro