Open Nukepayload2 opened 6 years ago
This is pretty intriguing since I've always found it interesting that almost all programming languages depend on some manner of understanding English. Since VB is so heavily dependent on "plain language" words, it's presumably fairly easy compared to other languages to translate.
I would assume a key goal for something like this would be for the community to develop standard *.vbld files for inclusion into VB, so that people who speak the same language could learn using the same keywords, and educational material could be built on them.
@Nukepayload2 It is interesting that your sample is in Chinese. Actually it doesn't fit if you "translate" VB code simply into Chinese.
There aren't spaces between Chinese words, but all programming languages do need spaces to parse and compile. There is an unsuccessful sample: 易语言.飞扬, which is almost a translation of C#.
To my opinion, it is the hardest part of learning a programming language to manage the basic grammer and keywords. If you keep the grammer and most keywords unchanged, I don't think it will make big changes to build a "language pack" of the class library.
There is another problem: speed of input. In most places, Chinese keywords or class names needs more keys than equivalent English ones(most people use Pinyin, while users of Wubi and Shuangpin are less and less):
English | Chinese Pinyin | Chinese Wubi | Chinese Shuangpin(double-key, 双拼, 自然码) |
---|---|---|---|
Dim(3) | bianliang(9) | yojf(4) | bmld(4) |
Console(7) | kongzhitai(10) | rprjckf (7+space) -or- rrc (3+space) | ksvitl(6) |
And I don't think Intellisense is intelligent enough to be an IME...
Although I love both Chinese and VB, I don't think this is a good idea. It may be more nesessary to translate English documents of .NET Core into Chinese.
Addition: I have designed a .NET programming language called "H#", which is partly based on grammer of Chinese, Visual Basic and C#. I wrote a compiler for it years ago(and was too young too simple at that time). Here is a sample of H# code(I didn't translate the namespace/class/method names but planned to):
导入 System
名域 测试
公共引类 类一
私有静态单小 小数字段
静态整数函数 主过程(文本[] 参数)
Console.WriteLine("在此向{0}致以{1}的{2}{3}{4}" , "世界" , "最崇高" , "敬意" , "!" , 123)
//Console.WriteLine("这是真注释。")
文本 字符串一个 = Console.ReadLine()//还是真注释
Console.WriteLine(字符串一个)
Console.WriteLine(字符串一个.GetType())
定义 整数一个 = 整数.Parse(Console.ReadLine())
Console.WriteLine(整数一个)
Console.WriteLine("{0:X000}" , 整数一个)
Console.WriteLine(整数一个.ToString())
Console.WriteLine(整数一个.GetType())
返回 0
函数结束
定义结束
定义结束
which is equivalent to(I translated the names to English):
Imports System
Namespace Test
Public Class Class1
Private Shared SingleField As Single
Shared Function Main(args As String()) As Integer
Console.WriteLine("Hello world!")
Dim str As String = Console.ReadLine()
Console.WriteLine(str)
Console.WriteLine(str.GetType())
Dim i = Integer.Parse(Console.ReadLine())
Console.WriteLine(i)
Console.WriteLine("{0:X000}", i)
Console.WriteLine(i.ToString())
Console.WriteLine(i.GetType())
Return 0
End Function
End Class
End Namespace
But I gave it up after some time. I knew that I couldn't complete it by myself. Also, I had to face the problems in my last comment, and didn't know how to solve them.
Actually, I don't think it is hard to recite some English words of a programming language. I first learned VB6 at the age of 9. I didn't even understand "Sub", "Dim", or "Double" in "DbClick". When I learned VB.Net at age 11, I didn't understand "Private" and "Public" at first. But I could recite them and write some small programs. What was hard for me was that there weren't (even aren't now!) enough Chinese tutorials of VB.Net besides MSDN, and even MSDN was translated by machine!
@Berrysoft
There is another problem: speed of input
If the users want to input faster, they can use regular VB code file instead. When they are learning VB, they can write programs with the help of .vblc
. As they gradually get used to the VB syntax, they can replace the aliases which they want to write faster with the original names by code fixes. Finally, they will no longer need .vblc
. They can switch to normal VB by right clicking on the .vblc
and select "Switch to .vb".
Problem
Many people do not speak English. If they want to learn VB, they will be asked to learn Computer English first. But some of them don't have enough time to recite so many English words. So, how about give them the chance of programming in their mother-languages?
Design
Introduce a localized VB code file type (
*.vblc
) and a project-level localization definition file type (EditorLocalizationConfig.vbld
).In
*.vblc
files, you can use aliases inEditorLocalizationConfig.vbld
files optionally. The IntelliSense will provide code fixes to toggle aliases.*.vblc
files will be transformed into regular*.vb
files at design-time. Once the user save*.vblc
or before build, the background code generator will generate new*.vb
files.In the
EditorLocalizationConfig.vbld
, you can specify alias for keywords, types and members by adding new xml nodes. For example, if you want to define an alias for the "Dim" keyword with the Chinese word "变量", and translate "Console.WriteLine(String)" into Chinese "控制台.输出行", you can change the content ofEditorLocalizationConfig.vbld
to:This change will affect all
*.vblc
files in the current project after you save theEditorLocalizationConfig.vbld
file. The following file:Program.vblc
Will be transformed into:
Program.vb