From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.107.20.87 with SMTP id 84mr7471079iou.31.1511192421733; Mon, 20 Nov 2017 07:40:21 -0800 (PST) X-Received: by 10.157.95.5 with SMTP id f5mr562940oti.9.1511192421649; Mon, 20 Nov 2017 07:40:21 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.kjsl.com!usenet.stanford.edu!i6no1899788itb.0!news-out.google.com!193ni3857iti.0!nntp.google.com!d140no1877610itd.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 20 Nov 2017 07:40:21 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=155.148.6.150; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 155.148.6.150 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <2c5d0dff-bc12-4b37-b8e1-ac176c3e675f@googlegroups.com> Subject: Re: gettext for Ada From: Shark8 Injection-Date: Mon, 20 Nov 2017 15:40:21 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: feeder.eternal-september.org comp.lang.ada:49014 Date: 2017-11-20T07:40:21-08:00 List-Id: 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 go= ing to be either a lot of text processing/parsing and/or somewhat ad hoc da= tabase (ie PO files) -- for a real translation solution which is lightweigh= t and won't introduce foreign dependencies you can use Ada packages for exa= ctly 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.) >=20 > Is there are less heavyweight solution? -- Message Spec: project-messages.ads Package Project.Messages is Type Disk is (Read_Error, Write_Error, Access_Error); =20 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 =20 Function Disk_Error( File_Name : String; Error : Disk ) return String is Begin case Error is when Access_Error =3D> Return "The disk Drive could not be accessed."= ; when Read_Error | Write_Error =3D> Return "There was an Error " & (if Error =3D 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 =20 Function Disk_Error( File_Name : String; Error : Disk ) return String is Begin case Error is when Access_Error =3D> Return "=E3=83=87=E3=82=A3=E3=82=B9=E3=82=AF= =E3=83=89=E3=83=A9=E3=82=A4=E3=83=96=E3=81=AB=E3=82=A2=E3=82=AF=E3=82=BB=E3= =82=B9=E3=81=A7=E3=81=8D=E3=81=BE=E3=81=9B=E3=82=93=E3=81=A7=E3=81=97=E3=81= =9F=E3=80=82"; when Read_Error | Write_Error =3D> Return "=E3=83=95=E3=82=A1=E3=82= =A4=E3=83=AB " & File_Name & ' ' & (if Error =3D Read_Error then "=E3=81=8B=E3=82=89=E3=81=AE=E8= =AA=AD=E3=81=BF=E5=8F=96=E3=82=8A" else "=E3=81=B8=E3=81=AE=E6=9B=B8=E3=81= =8D=E8=BE=BC=E3=81=BF") & "=E4=B8=AD=E3=81=AB=E3=82=A8=E3=83=A9=E3=83=BC=E3=81=8C=E7=99= =BA=E7=94=9F=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F=E3=80=82"; end case; End Disk Error; End Project.Messages; And then at compile-time select the proper language to build the applicatio= n via GPR-projects, makefiles, or whatever paramaterizable build-system you= wish to use.