Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.misc > #2039

Re: Issuing a message in the language of the user

From "James Harris" <james.harris.1@gmail.com>
Newsgroups comp.lang.misc
Subject Re: Issuing a message in the language of the user
Date 2014-04-28 18:15 +0100
Organization A noiseless patient Spider
Message-ID <ljm2c8$5tn$1@dont-email.me> (permalink)
References <ljjlr6$4ok$1@dont-email.me> <op.xe0nt7y86zenlw@localhost>

Show all headers | View raw


"Rod Pemberton" <dont_use_email@xnothavet.cqm> wrote in message 
news:op.xe0nt7y86zenlw@localhost...
> On Sun, 27 Apr 2014 15:29:42 -0400, James Harris 
> <james.harris.1@gmail.com> wrote:
>
>> [snip]
>>
>> The idea is that a program wants to issue a message to a user
>> (using a function which for the sake of giving it a name in this
>> post I will call IssueMsg) but doesn't want to have to know what
>> language the user speaks or what other locale settings are in
>> effect. The message should appear in English to an English speaker,
>> French to a French speaker etc. The IssueMsg routine is to look up
>> the message in a library of the appropriate language for the user
>> and then fill-in the parameter values supplied by the program.
>>
>> This is akin to gettext() but, of course, much better. ;-)
>>
>> Regarding the need for the order of values in a message to vary,
>> a two-parameter message in English might have parm 1 first then
>> parm 2 but the same message in French might be more naturally
>> expressed by having parm 2 come before parm 1. Rather than
>> forcing the same order on all languages the message needs to
>> pick the parameter for each location. This means that the message
>> text cannot just use them in order but needs to have numbered or
>> named parameters. Numbered is more efficient and was chosen for
>> the suggestion below.
>>
>> [snip]
>
> Is there a reason each message needs to have values?
>
> I.e., my inclination would be to have static strings for each
> language selectable by index and pointer.  The pointer would
> be set for the chosen language to select the appropriate array
> of strings.  I would avoid emitting values, or I'd emit them on
> a line without other text and without language specific formatting.

Some messages might not have values. They could be issued as normal but with 
no parameters. But some messages would need parameters. For example.

  your account balance is 10.62 CR
  you last logged in from IP address 10.1.1.4 on 5/5/2014
  syntax error on line 20 near column 8 expected one of ",", ";", "(".

James

Back to comp.lang.misc | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Issuing a message in the language of the user "James Harris" <james.harris.1@gmail.com> - 2014-04-27 20:29 +0100
  Re: Issuing a message in the language of the user "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2014-04-28 09:24 +0200
  Re: Issuing a message in the language of the user "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-04-28 03:45 -0400
    Re: Issuing a message in the language of the user "James Harris" <james.harris.1@gmail.com> - 2014-04-28 18:15 +0100
      Re: Issuing a message in the language of the user "BartC" <bc@freeuk.com> - 2014-04-28 19:09 +0100
      Re: Issuing a message in the language of the user "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-04-28 20:33 -0400
  Re: Issuing a message in the language of the user "BartC" <bc@freeuk.com> - 2014-04-28 09:52 +0100
    Re: Issuing a message in the language of the user "James Harris" <james.harris.1@gmail.com> - 2014-04-28 19:17 +0100
      Re: Issuing a message in the language of the user "BartC" <bc@freeuk.com> - 2014-04-29 22:17 +0100
        Re: Issuing a message in the language of the user "James Harris" <james.harris.1@gmail.com> - 2014-04-29 23:21 +0100
  Re: Issuing a message in the language of the user George Neuner <gneuner2@comcast.net> - 2014-04-28 12:27 -0400

csiph-web