+ Reply to Thread
Results 1 to 8 of 8

Thread: Extapolate text from software?

  1. #1

    Extapolate text from software?

    Good morning Rebolers,
    I need an help to get a simple way to translate to english the text of software.
    I'm italian, and obviously my software is first written with italian language (buttons, texts, and so on ...) then I rewrite it with in English.
    Is there a way to extrapolate text form rebol file?
    Usually all the texts are between " " (examle: "hello world!"), is there a way with parse or find or something else?
    Any idea is welcome

  2. #2
    Administrator
    Join Date
    Jan 2004
    Posts
    388

    Well, Rebol code has values such as string!, date!, function! etc.

    So, all you need to do is load your program and examine those values. If you find string! values, they are a good candidate for translation ...

    Have a look at Carl's color-code script on rebol.org which examines the value of each word in a script and assigns a color based on its datatype!
    Dr Graham Chiu
    Wiki: http://www.compkarori.co.nz:8090
    ph: 1-818-570-2839

  3. #3

    MaxV, here's a quickie that may be useful:

    Code:
    rebol []
    code: {
        view layout [
            btn "some text"
            btn "some more text"
        ] 
    }
    strings: copy []
    parse code [any [thru {"} copy a-string to {"} (append strings a-string)] to end]
    foreach str strings [
        if true = request rejoin [{Change "} str {"?}] [
            replace/all code str request-text/title rejoin [{Change "} str {" to:}]
        ]
    ]
    editor code
    This will obviously work better if you use opening and closing curly braces instead of quotes to represent strings in your code.
    Last edited by notchent; August 1st, 2010 at 12:31 AM.

  4. #4

    Very good, I added a check for corrected ", so I obtain only the real strings:

    Code:
    code: { 
        view layout [
            btn "some text"
            btn "some more text"
        ] 
    }
    strings: copy []
    test: 1
    parse code [
       any [
          thru {"} (test: test + 1)   copy a-string
          to {"}  (if ((remainder test  2 ) = 0) [append strings a-string]) 
          ] 
        to end]
    parse code [any [thru "{"  copy a-string to "}" (append strings a-string) ] to end]
    probe strings
    alert "Done!"
    Now may next step is: how to use google translator with these strings?
    I can read the page of the translation simply with my browser, example: I want tor translate "Ciao mondo"
    Code:
    http://translate.google.com/?hl=it#auto|en|Ciao mondo
    but I can't read anywhere "Hello world" in source code of HTML, any suggestion?
    Thank you and best regards
    Max

  5. #5
    Administrator
    Join Date
    Jan 2004
    Posts
    388

    Must be being generated in Javascript so that's why you can't see it.
    Dr Graham Chiu
    Wiki: http://www.compkarori.co.nz:8090
    ph: 1-818-570-2839

  6. #6

    I found that to substitute the strings, it's fundamental use mold.
    Without mold, "Hello" could be:
    • "Hello"
    • {Hello}

    with mold i obtain: {"Hello"} or {{Hello}}

    so the correct script is:

    Code:
    theurl: to-file request-file
    code: read/string  theurl
    strings: copy []
    test: 1
    parse code [
       any [
          thru {"} (test: test + 1)   copy a-string
          to {"}  (if ((remainder test  2 ) = 0) [append strings mold a-string]) 
          ] 
        to end]
    parse code [any [thru "{"  copy a-string to "}" (append strings mold a-string) ] to end]
    append  theurl  ".txt"
    sort strings
    strings: unique/case strings
    write theurl ""  ; clean file
    foreach temp strings [
    	write/append theurl {[ }	
    	write/append theurl (mold temp)
    	write/append theurl { ]}
    	write/append theurl "^/"
    	]
    alert "Done!"

  7. #7
    Junior Member
    Join Date
    Feb 2010
    Posts
    13

    I once wrote a small program where I tried out the idea of putting ALL text (that is, button values, messages, EVERYTHING) into one file. I still have the code if you would like to examine it, but it is too big to paste into this message. The idea behind this was that if I wanted to translate the program to another language, I would have to translate just that one file. I never thought of using something like google to do the translating.

    Because all the text strings were identified by words, it would be possible to write a program to get each text string, although what one would DO with each text string, I have no idea.

  8. #8
    Administrator
    Join Date
    Jan 2004
    Posts
    388

    If you build your application with RebGUI, you get language localization built in.
    Dr Graham Chiu
    Wiki: http://www.compkarori.co.nz:8090
    ph: 1-818-570-2839

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts