Babylscript now on GitHub

59 views
Skip to first unread message

Ming

unread,
Apr 6, 2012, 11:39:45 AM4/6/12
to babyl...@googlegroups.com
Babylscript is based on the Mozilla Rhino JavaScript engine. The source code for Rhino moved from CVS to Git sometime during the last year or so, so I've now also moved Babylscript onto GitHub. This should make it easier to track changes and to later update Babylscript to use newer versions of Rhino. As part of the move, I also rearchitected and rewrote Babylscript to extend Rhino more cleanly. Previously, Babylscript modified lots of the internals of Rhino. Currently, Babylscript now modifies fewer files and feels more like an extension.

Ming

unread,
Jul 19, 2012, 8:37:47 PM7/19/12
to babyl...@googlegroups.com
> Are the translations also ion GitHub? I could not find them by browsing https://github.com/my2iu/babylscript
> Example of corrections to be done to the French version http://www.babylscript.com/mappings/french.html :

Yes, they are on github, but the translations are buried in a subdirectory though:


Any help you can give on the French translation would be much appreciated because my own French is pretty weak. If you want to send your translation suggestions to me directly or to this google group, that also works.


* "return" → should be "retourner" and not "renvoi" as it needs an infinitive form to be coherent with other similar keywords.

Yeah, I was thinking of renvoyer, but I guess retourner is probably more commonly used, so I should probably go with that.
 
* "continue" → should be "continuer" for the same reason (consistency with the very similar "break")

* "finally" → "finalement"

* "int" → "entier"


I was thinking that since int is short for integer, that ent would work well as a short form for entier, but I admit that it might be too short to the point where no one knows what it's referring to. What do you think?
 
* "throw" → "lever" (this is the normal expression: "lever une exception")


Well, it's also "raise and exception" in English as well, but the JavaScript keywords are still throw and catch. I was originally going to use lancer and capturer like the language LSE2000, but it felt like they used the wrong translation for "throw" and "catch". When you throw an exception, you aren't throwing it to someone, you're throwing it out or tossing it into the air, hoping that someone else can handle it. And catch should be translated more like "catch a ball." But I wasn't sure because the Java books I read also used lancer and capturer as well.
 
* "yield" → "fournir"


Yield is a tricky one because "yield" has many different meanings in English, and they all have different translations. Does the yield keyword mean "stop" as in stop your thread of execution? Does yield mean "give up" as in temporarily give up your execution so that something else can run? Or does yield mean "produce" as in produce some output by a generator. The yield keyword does all of these things, so it's hard to say. I guess fournir is a reasonable choice though.
 
* "final" → "final"

* "throws" → "lève" (or possibly "levant"?)

* "package" → "paquetage"

* etc.

Thanks! I'll try to integrate these changes in the next couple of days.

-Ming

Alexandre Alapetite

unread,
Jul 22, 2012, 8:10:31 AM7/22/12
to babyl...@googlegroups.com
Hello,

2012/7/20 Ming <ming...@gmail.com>:
>> Are the translations also ion GitHub? I could not find them by browsing
>> https://github.com/my2iu/babylscript
>> Example of corrections to be done to the French version
>> http://www.babylscript.com/mappings/french.html :
>
> Yes, they are on github, but the translations are buried in a subdirectory
> though:
>
> https://github.com/my2iu/babylscript/tree/Babylscript1_7R2_BRANCH/src/org/mozilla/javascript/babylscript/resources
>
> Any help you can give on the French translation would be much appreciated
> because my own French is pretty weak. If you want to send your translation
> suggestions to me directly or to this google group, that also works.

Ok, I have now made the same suggestions as below on GitHub.

Can't you use UTF-8 instead of escaping like "\u00e9"?

>> * "int" → "entier"
>>
>
> I was thinking that since int is short for integer, that ent would work well
> as a short form for entier, but I admit that it might be too short to the
> point where no one knows what it's referring to. What do you think?

Yes indeed; I do not think "ent" would be easily understood.

>>
>> * "throw" → "lever" (this is the normal expression: "lever une exception")
>>
>
> Well, it's also "raise and exception" in English as well, but the JavaScript
> keywords are still throw and catch. I was originally going to use lancer and
> capturer like the language LSE2000, but it felt like they used the wrong
> translation for "throw" and "catch". When you throw an exception, you aren't
> throwing it to someone, you're throwing it out or tossing it into the air,
> hoping that someone else can handle it. And catch should be translated more
> like "catch a ball." But I wasn't sure because the Java books I read also
> used lancer and capturer as well.

I did not know LSE2000. Interesting. In any case, the chosen
infinitive verb should also work well for "throws" (e.g. "lève").

>>
>> * "yield" → "fournir"
>>
>
> Yield is a tricky one because "yield" has many different meanings in
> English, and they all have different translations. Does the yield keyword
> mean "stop" as in stop your thread of execution? Does yield mean "give up"
> as in temporarily give up your execution so that something else can run? Or
> does yield mean "produce" as in produce some output by a generator. The
> yield keyword does all of these things, so it's hard to say. I guess fournir
> is a reasonable choice though.

Yes indeed, yield is very versatile and therefore difficult to
translate in one single word.
If I understood correctly, in your project, the focus is on JavaScript
usage, which limits a bit the diversity.
Another possibility would be to have some alias, i.e. a few words all
translated to yield.

>
> Thanks! I'll try to integrate these changes in the next couple of days.
>
> -Ming

Best regards,
Alexandre
http://alexandre.alapetite.fr

Ming

unread,
Jul 22, 2012, 2:09:29 PM7/22/12
to babyl...@googlegroups.com
Ok, I have now made the same suggestions as below on GitHub.

Can't you use UTF-8 instead of escaping like "\u00e9"?


When Sun was creating the internationalization framework for Java, I think it was before the invention of UTF-8 and there were hardly any UCS-2 text editors, so they required that .properties files be in ASCII format only with all non-ascii characters encoded with unicode escape codes. 

It's a bit of a pain. For the most recent translations, I've been working with spreadsheets (I've made a new one for French below) and then use a script to generate the .properties files:



Python generation script for tab-separated spreadsheet files (.tsv):
=============
import codecs, string, sys

def main(argv):
   global keywordList, objectList

   if len(argv) < 2:
      print """tsvToPo.py inputFilePrefix
         """
      return

   prefix = argv[1]

   f = codecs.open(prefix + '.tsv', encoding='utf_8')
   scanFile(f, 0)
   f.close()

   # Finished scanning files, so print out results
   f = open('Keywords_' + prefix + '.properties', 'w')
   outputAsJavaPropertyFile(f, keywordList)
   f.close()
   f = open('Objects_' + prefix + '.properties', 'w')
   outputAsJavaPropertyFile(f, objectList)
   f.close()

def scanFile(f, isScanForDefaults):
   mode = 0

   while 1:
      line = f.readline()
      if not line: break
      splits = line.split('\t')

      # Check for switches to different sections of the spreadsheet
      firstCell = splits[0].strip()
      if firstCell == 'Keywords':
         mode = 1
         continue
      elif firstCell == 'Reserved words':
         mode = 2
         continue
      elif firstCell == 'Objects':
         mode = 3
         continue
      elif firstCell == 'Error Messages':
         mode = 4
         continue

      # Pass control to the appropriate handler
      if isScanForDefaults:
         if len(firstCell) == 0: continue
         english = firstCell.replace(' ', '_')
         translated = english
      else:
         if len(firstCell) == 0: continue
         if len(splits) < 2: continue
         english = firstCell.replace(' ', '_')
         translated = splits[1].strip()
         if len(translated) == 0: continue

      if mode == 0:
         continue
      elif mode == 1:
         handleKeyword(english, translated)
      elif mode == 2:
         handleReservedWords(english, translated)
      elif mode == 3:
         handleObjects(english, translated)



def outputAsJavaPropertyFile(out, dict):
   for (key, value) in dict.items():
      out.write(escapeJavaPropertyString(key))
      out.write(' = ')
      out.write(escapeJavaPropertyString(value))
      out.write('\n')

def escapeJavaPropertyString(str):
   ascii = ''
   for c in str:
      code = ord(c)
      if (code < 127):
         ascii = ascii + c
      else:
         ascii = ascii + ('\u%04x'  % code)
   return ascii

def handleKeyword(english, translated):
   global keywordList
   if english in keywordList and len(keywordList[english]) > len(translated): return
   keywordList[english] = translated

def handleReservedWords(english, translated):
   global keywordList
   if english in keywordList and len(keywordList[english]) > len(translated): return
   keywordList[english] = translated

def handleObjects(english, translated):
   global objectList
   if english in objectList and len(objectList[english]) > len(translated): return
   objectList[english] = translated


keywordList = {}
objectList = {}

main(sys.argv)
=============

I've put in your changes. I'll ask around to some of my former French colleagues to see if they have alternate suggestions for how to handle throw/catch, and then I'll fix up the "lève" thing for throws.

-Ming
 

Alexandre Alapetite

unread,
Jul 22, 2012, 2:17:47 PM7/22/12
to babyl...@googlegroups.com
Ok :-)

2012/7/22 Ming <ming...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages