3

I am looking for an example using Cobol either mf cobol or gnucobol. I would like an alternate of VB or C. Old time coboller since Cobol 61. I have looked at the Java and python examples but they are not clear to me.

Parameter sizes, contents, and order are what I am looking for as well as the translation routine or module name.

Vb or c example will do as I have worked with those languages as well.

A cobol example with results expected:

Id division.
Program-Id.  Somename.
Environment division.
Data division.
Working-storage section.

01 Some-existing-text pic x(32000) value
"The quick brown fox jumped over the silver moon".

01 input-text-type pic x(20) value "english".

01 resulting-text pic x(32000) value
"Der schnelle braune Fuchs sprang über den silbernen Mond ".

01 destination-text-type pic x(20) value "German".

Procedure division.
Start-here.
    Call "translation-routine" using Some-existing-text,
                                     input-text-type,
                                     Resulting-text,
                                     Destination-text-type.
Stop-here.
Stop run.
B--rian
  • 5,578
  • 10
  • 38
  • 89
  • 2
    Google Translate is used to translate between natural languages (English, Russian, ...). It is useless at translating COBOL to anything. Are you looking for a conversion tool or service to convert COBOL? – Ira Baxter Mar 31 '18 at 08:48
  • 2
    You might find my discussion of one translator of COBOL to Java interesting: https://www.quora.com/Which-are-the-best-available-open-source-tools-for-converting-COBOL-code-to-Java/answer/Ira-Baxter – Ira Baxter Mar 31 '18 at 08:50
  • It might be possible to use the GnuCOBOL Python Instrinsic. Which version of GnuCOBOL are you using? – Rick Smith Mar 31 '18 at 11:57
  • 1
    To clarify. I have a cobol system that I am happy with. What want to translate is the text in the files to appeal to more users. The text is in English and I would like my users to be comfortable reading the text in the language that They are are most comfortable with. Like "call using my-existing-text, "English", translated-text, "German".". Just call a routine data in and get data out. Kiss theory I would think. Thanks. Ron – Ronald Draper Apr 01 '18 at 01:10
  • Currently a mf user but if gnu is able to do the text translation, then I am open to some change. Ron – Ronald Draper Apr 01 '18 at 01:19
  • We're talking about English text embedded in the source of your COBOL program? You mean text strings that get printed to the console or printer, or do you mean comments? Who exactly will read this and be happier after your problem is solved, a user of the program or a programmer reading its text? If this is really about translating English text and not COBOL source, what is with the "I would like VB or C" red herring? "Java and Python examples"? I think you need to show us an example of "before" and "after" for what you want. This question is written pretty badly if you want answers. – Ira Baxter Apr 01 '18 at 04:00
  • 1
    As the others said you'll have to create a sample. In general you can use both the `CALL` interface or user defined functions to provide this, but you'd have first to think about how you want the text to be resolved. And keep in mind that even short sentences in English can get much longer in other languages - you'd have to provide enough "place" for the text (on printer/screen) and at least for `CALL` have to provide enough space for the returning text. ... And maybe think about your approach again as google-translate != "comfortable reading in any language"... – Simon Sobisch Apr 01 '18 at 11:55
  • This will get tricky. Google deprecated the public API quite a while ago; they had no choice given the level of abuse on the service. Even if you had a key, you are then faced with http/https from COBOL with a response in JSON form. I'd punt this to javascript or node.js and use piped command capture. – Brian Tiffin May 15 '18 at 02:56

1 Answers1

0

Take a look at this, i tried it in linux and its working absolutely fine.

First Install Translate Shell:- Translate Shell is available in the official repositories of popular Linux operating systems.

Use below command to install.

$ sudo apt-get install translate-shell

Now find the cobol code that takes user input and translates from your preferred language to English and vice versa.

ID DIVISION.
PROGRAM-ID.  SOMENAME.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.

01 SOME-SAMLPLE-TEXT PIC X(30) VALUE "नमस्ते". /*THIS WORD IS "HI" IN HINDI*/

PROCEDURE DIVISION.
START-HERE.
        STRING "TRANS"
               " "
               SOME-SAMLPLE-TEXT
        DELIMITED BY SPACES INTO LINUX-COMMAND.
       CALL "SYSTEM" USING LINUX-COMMAND
                  RETURNING CONVERTED-TEXT.
        DISPLAY CONVERTED-TEXT.
STOP RUN.

Output will be "HI"

Below program translates Hindi to Tamil, you can use an variable and make the language code dynamic. For more language codes goto:https:language codes

ID DIVISION.
PROGRAM-ID.  SOMENAME.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.

01 SOME-SAMPLE-TEXT PIC X(30) VALUE "नमस्ते". /*THIS WORD IS "HI" IN HINDI*/

PROCEDURE DIVISION.
START-HERE.
        STRING "TRANS"
               " "
               ":"
               "te" /*code to convert text to tamil*/
               " "
               SOME-SAMPLE-TEXT
        DELIMITED BY SPACES INTO LINUX-COMMAND.
       CALL "SYSTEM" USING LINUX-COMMAND
                  RETURNING CONVERTED-TEXT.
        DISPLAY CONVERTED-TEXT.
STOP RUN.

Output will be "வணக்கம்"

For information on installing google translate in linux please refer :this link Happy coding........