comp.lang.ada
 help / color / mirror / Atom feed
From: Michael Rohan <michael@zanyblue.com>
Subject: Re: Formatted IO - Fortran style or similar.
Date: Wed, 1 Aug 2012 12:14:00 -0700 (PDT)
Date: 2012-08-01T12:14:00-07:00	[thread overview]
Message-ID: <4eea8d29-3ef7-4053-afc3-140a866cc552@googlegroups.com> (raw)
In-Reply-To: <87boivrq3a.fsf@adaheads.sparre-andersen.dk>

On Wednesday, August 1, 2012 1:09:13 AM UTC-7, Jacob Sparre Andersen wrote:
> stefan-lucks@see-the.signature writes:
> 
> > On Tue, 31 Jul 2012, Jacob Sparre Andersen wrote:
> 
> 
> 
> >> How would you handle translatable user visible strings - such as
> 
> >> "Parsing '${file_name}' failed on line ${line_number}." (where
> 
> >> "${...}" identifies parameter substitutions) - in Ada?
> 
> >
> 
> > Why do you need to *substitute* the parameters in the string at all?
> 
> >
> 
> > Without substitution, the following seems to work fine:
> 
> >
> 
> >   Ada.Text_IO.Put_Line("Parsing "         & File_Name & 
> 
> >                        " failed on line " & To_String(Line_Number) & 
> 
> >                        ".");
> 
> 
> 
> Yes.  But how do you translate that text without having to recompile
> 
> the whole application?
> 
> 
> 
> My question was related to _translatable_ user visible strings.  If I
> 
> just want to make an all-American program, your proposed solution is
> 
> fine, but when I want to make it easy to translate the user visible
> 
> strings in an application you proposed solution is unacceptable.
> 
> 
> 
> Greetings,
> 
> 
> 
> Jacob
> 
> -- 
> 
> "Those who will not reason, are bigots,
> 
>  those who cannot, are fools, and
> 
>  those who dare not, are slaves."

Hi,

The standard way to do this is to externalize all localizable strings.  Since
message snippets are not generally localizable (there's no real context), the
messages must be defined as complete sentences with embedded references to the
application arguments that substituted at run-time.

Using my previous example, the message

Summary=Vector norm is {0,real,10.2f} with rank of {1,integer}

would be defined in a properties file, e.g., myapp.properties, with
localizations in locale specific files, e.g., if folks in GB want to see
the rank first

Summary=Vector rank is {1,integer} with norm of {0,real,10.2f}

in a myapp_en_GB.properties file.  The underlying source code remains
the same

    Print_Summary (+Norm, +Rank);

The ZB compiler, zbmcompile, would generate a package containing the
myapp.properties and myapp_en_GB.properties strings, and accessor routines
for all the message keys defined.  Depending on the run-time locale, the
value of the LANG variable on Unix, the correct localized message is
displayed.  (see http://zanyblue.sourceforge.net).

If you want a globalized application, you need to get the message strings
out of the application and you need to allow localization folks the freedom
to move message arguments around in the localized text.

Take care,
Michael.



      parent reply	other threads:[~2012-08-02 15:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-30  8:50 Formatted IO - Fortran style or similar Mark Murray
2012-07-30  9:59 ` Ian Clifton
2012-07-30 18:57   ` Michael Rohan
2012-07-30 22:12   ` Mark Murray
2012-07-31  7:17     ` Dmitry A. Kazakov
     [not found]     ` <npbe18d3o3gdc2ut41f1codvv6rhfgidr3@invalid.netcom.com>
2012-07-31 11:56       ` Jacob Sparre Andersen
2012-07-31 15:12         ` stefan-lucks
2012-07-31 17:34           ` Adam Beneschan
2012-08-01  6:56             ` stefan-lucks
     [not found]           ` <be5g18p0gnf2ocdf3hmgjslgnu0jogrh91@invalid.netcom.com>
2012-08-01  6:48             ` stefan-lucks
2012-08-01  8:09           ` Jacob Sparre Andersen
2012-08-01 10:28             ` Georg Bauhaus
2012-08-01 16:28             ` Simon Wright
2012-08-01 19:14             ` Michael Rohan [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox