comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Re: gettext for Ada
Date: Mon, 20 Nov 2017 07:40:21 -0800 (PST)
Date: 2017-11-20T07:40:21-08:00	[thread overview]
Message-ID: <2c5d0dff-bc12-4b37-b8e1-ac176c3e675f@googlegroups.com> (raw)
In-Reply-To: <ousq8j$17fb$1@gioia.aioe.org>

On Sunday, November 19, 2017 at 1:40:55 PM UTC-7, Victor Porton wrote:
> Where can I get a gettext bindings for Ada?

I would actually advise against gettext usage, in general -- one of the big problems is that it's all string-based operations, meaning that there's going to be either a lot of text processing/parsing and/or somewhat ad hoc database (ie PO files) -- for a real translation solution which is lightweight and won't introduce foreign dependencies you can use Ada packages for exactly that purpose.

Ideally messages would be constructed w/ appropriate structure and rendered in the user/display language as needed... this is, however, a more complex solution than many are willing to accept as I've never actually seen it in usage. (Though, to be fair, I've only professionally worked on ONE project which had multilingual needs.)

> 
> Is there are less heavyweight solution?

-- Message Spec: project-messages.ads
Package Project.Messages is
  Type Disk is (Read_Error, Write_Error, Access_Error);
  
  Function Disk_Error( File_Name : String; Error : Disk ) return String;
End Project.Messages;


-- Package Body: project-messages.adb
-- Location: ./English/
Package Body Project.Messages is
  
  Function Disk_Error( File_Name : String; Error : Disk ) return String is
  Begin
    case Error is
      when Access_Error => Return "The disk Drive could not be accessed.";
      when Read_Error | Write_Error => Return "There was an Error " &
            (if Error = Read_Error then "reading from" else "writing to") &
             " the file """ & File_Name & """.";
    end case;
  End Disk Error;
End Project.Messages;

-- Package Body: project-messages.adb
-- Location: ./Japanese/
Package Body Project.Messages is
  
  Function Disk_Error( File_Name : String; Error : Disk ) return String is
  Begin
    case Error is
      when Access_Error => Return "ディスクドライブにアクセスできませんでした。";
      when Read_Error | Write_Error => Return "ファイル " & File_Name & ' ' &
            (if Error = Read_Error then "からの読み取り" else "への書き込み") &
             "中にエラーが発生しました。";
    end case;
  End Disk Error;
End Project.Messages;

And then at compile-time select the proper language to build the application via GPR-projects, makefiles, or whatever paramaterizable build-system you wish to use.

  reply	other threads:[~2017-11-20 15:40 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-19 20:40 gettext for Ada Victor Porton
2017-11-20 15:40 ` Shark8 [this message]
2017-11-20 19:28   ` Jacob Sparre Andersen
2017-11-20 19:59     ` Shark8
2017-11-20 20:33       ` Dmitry A. Kazakov
2017-11-21 19:15         ` Jacob Sparre Andersen
2017-11-21 20:54           ` Dmitry A. Kazakov
2017-11-23  9:15             ` Jacob Sparre Andersen
2017-11-23  9:47               ` Dmitry A. Kazakov
2017-11-23 10:03                 ` Jacob Sparre Andersen
2017-11-23 10:37                   ` Dmitry A. Kazakov
2017-11-23 12:14                     ` Jacob Sparre Andersen
2017-11-23 13:23                       ` Dmitry A. Kazakov
2017-11-21 19:22       ` Jacob Sparre Andersen
2017-11-20 22:43   ` Randy Brukardt
2017-11-21  0:28     ` Shark8
2017-11-21  8:29       ` G. B.
2017-11-21 13:48         ` J-P. Rosen
2017-11-22  1:10       ` Randy Brukardt
2017-11-22 15:38         ` Shark8
2017-11-23  0:30           ` Randy Brukardt
2017-11-23  3:08             ` Shark8
2017-11-28  0:48               ` Randy Brukardt
2017-11-28 16:47                 ` Simon Wright
2017-11-28 17:03                 ` Dmitry A. Kazakov
2017-11-28 22:41                   ` Randy Brukardt
2017-11-29  9:09                     ` Dmitry A. Kazakov
2017-11-23  8:25           ` G. B.
2017-11-23 16:02             ` Shark8
2017-11-23 18:55               ` G. B.
2017-11-23 20:24                 ` Shark8
2017-11-28  0:55                   ` Randy Brukardt
2017-11-22 21:36 ` Blady
replies disabled

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