Browse Source

feat: 修改翻译

SongZihuan 3 years ago
parent
commit
ee0eee5b5c
5 changed files with 51 additions and 54 deletions
  1. 1 1
      lang/tr/base.py
  2. 26 28
      lang/tr/zh_cn.py
  3. 12 13
      src/main.c
  4. 3 3
      src/main_build.c
  5. 9 9
      src/runtime/aFunlang.c

+ 1 - 1
lang/tr/base.py

@@ -1,4 +1,4 @@
-HELP_INFO = r'''[option]
+help_info = r'''[option]
    help
    help
        -v Show    version info
        -v Show    version info
        -h Show    help page
        -h Show    help page

+ 26 - 28
lang/tr/zh_cn.py

@@ -1,4 +1,4 @@
-HELP_INFO = r'''[参数]
+help_info = r'''[参数]
    help
    help
        -v 显示版本信息
        -v 显示版本信息
        -h 显示帮助信息
        -h 显示帮助信息
@@ -15,34 +15,32 @@ HELP_INFO = r'''[参数]
        -- 前的自由参数被解析为-f参数
        -- 前的自由参数被解析为-f参数
        -- 后的自由参数被解析为命令行参数
        -- 后的自由参数被解析为命令行参数
    build
    build
-       -o 文件输出位置(完整目录, 仅支持单个文件编译)
-       -p 文件输出位置(文件夹, 支持多个文件编译)
-       -f 强制编译
+       -o/--out 文件输出位置(完整目录, 仅支持单个文件编译)
+       -p/--path 文件输出位置(文件夹, 支持多个文件编译)
+       -f/--fource 强制编译
 
 
 [Github page]
 [Github page]
    <https://github.com/aFun-org/aFunlang>'''
    <https://github.com/aFun-org/aFunlang>'''
    
    
-VERSION_N = '版本'
-CL_N = '命令行'
-CL_TIPS = '在顶层活动空间运行输入的代码'
-USAGE_N = '帮助'
-CL_ERROR = '命令行参数错误'
-NOT_FILE = '没有代码需要被运行'
-RUN_Exit_N = '退出'
-RUN_Exitcode_N = '退出代码'
-ARG_CONFLICT = '参数冲突'
-NOT_BUILD_SRC = '没有源码被编译'
-MANY_BUILD_SRC = '太多源码被编译'
-NOT_BUILD_FILE_EXISITS = '需要编译的文件不存在'
-ALREADY_BUILD = '已经编译'
-BUILD_AGAIN = '使用 --fource 强制编译'
-BUILD_FILE = '文件将被编译'
-RUN_SAVE_ERROR = '字节码编译失败'
-RUN_NOT_AUN = '运行的文件不是.aun文件'
-RUN_NOT_AUB = '运行的文件不是.aub文件'
-LOAD_BT_ERROR = '字节码加载失败'
-RUN_NOT_AUN_AUB = '运行的文件不是.aun或.aub文件'
-NOT_RUN_FILE_EXISITS = '需要运行的文件不存在'
-BUILD_IN_AUN = '被编译的文件不是.aun文件'
-BUILD_OUT_AUB = '编译输出的文件不是.aun文件'
-BUILD_ERROR_N = '编译失败'
+command_line_n = '命令行'
+command_line_tips = '在顶层活动空间运行输入的代码'
+usage_n = '帮助'
+cl_arg_error_e = '命令行参数错误'
+cl_not_file_e = '没有代码需要被运行'
+exit_code_n = '退出代码'
+arg_conflict_n = '参数冲突'
+build_not_src_e = '没有源码被编译'
+build_many_src_e = '太多源码被编译 (不要使用 --out 参数)'
+build_src_not_exists_e = '需要编译的文件不存在'
+build_src_already = '已经编译'
+build_use_f = '使用 --fource 强制编译'
+build_file = '文件将被编译'
+run_save_e = '字节码编译失败'
+run_source_not_aub_e = '运行的文件不是.aun文件'
+run_bt_not_aub_e = '运行的文件不是.aub文件'
+run_load_bt_e = '字节码加载失败'
+run_file_aun_aub_e = '运行的文件不是.aun或.aub文件'
+run_file_not_exists_e = '需要运行的文件不存在'
+build_in_aun_e = '被编译的文件不是.aun文件'
+build_out_aub_e = '编译输出的文件不是.aun文件'
+build_error_e = '编译失败'

+ 12 - 13
src/main.c

@@ -1,7 +1,6 @@
 #include <stdio.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include "aFun.h"
 #include "aFun.h"
-#include "main.h"
 #include "main_run.h"
 #include "main_run.h"
 #include "main_build.h"
 #include "main_build.h"
 
 
@@ -107,14 +106,14 @@ static void printVersion(void) {
 }
 }
 
 
 static void printWelcomeInfo(void) {
 static void printWelcomeInfo(void) {
-    printf_stdout(0, "aFunlang " aFunVersion " %s (" __DATE__ ", " __TIME__ ")\n", HT_getText(CL_N, "CommandLine"));
+    printf_stdout(0, "aFunlang " aFunVersion " %s (" __DATE__ ", " __TIME__ ")\n", HT_getText(command_line_n, "CommandLine"));
     fputs_stdout("["compilerID"] on "systemName"\n");
     fputs_stdout("["compilerID"] on "systemName"\n");
-    printf_stdout(0, "(%s)\n", HT_getText(CL_TIPS, "Enter the aFun code to run in the top activity"));
+    printf_stdout(0, "(%s)\n", HT_getText(command_line_tips, "Enter the aFun code to run in the top activity"));
 }
 }
 
 
 static void printHelp(void) {
 static void printHelp(void) {
-    printf_stdout(0, "aFunlang %s:\n", HT_getText(USAGE_N, "Usage"));
-    printf_stdout(0, "%s\n", HT_getText(HELP_INFO, ""));
+    printf_stdout(0, "aFunlang %s:\n", HT_getText(usage_n, "Usage"));
+    printf_stdout(0, "%s\n", HT_getText(help_info, ""));
 }
 }
 
 
 /*
 /*
@@ -123,7 +122,7 @@ static void printHelp(void) {
  */
  */
 static void printError(ff_FFlags *ff) {
 static void printError(ff_FFlags *ff) {
     writeErrorLog(aFunlangLogger, "%s argument error", ff_getChild(ff));
     writeErrorLog(aFunlangLogger, "%s argument error", ff_getChild(ff));
-    printf_stdout(0, "%s (%s)\n", HT_getText(CL_ERROR, "Command line argument error"), ff_getChild(ff));
+    printf_stdout(0, "%s (%s)\n", HT_getText(cl_arg_error_e, "Command line argument error"), ff_getChild(ff));
     printHelp();
     printHelp();
 }
 }
 
 
@@ -183,7 +182,7 @@ static int mainRun(ff_FFlags *ff) {
         writeErrorLog(aFunlangLogger, "aFun exit code: %d", exit_code);
         writeErrorLog(aFunlangLogger, "aFun exit code: %d", exit_code);
     else
     else
         writeInfoLog(aFunlangLogger, "aFun exit code: %d", exit_code);
         writeInfoLog(aFunlangLogger, "aFun exit code: %d", exit_code);
-    printf_stderr(0, "aFun %s: %d\n", HT_getText(RUN_Exitcode_N, "exit code"), exit_code);
+    printf_stderr(0, "aFun %s: %d\n", HT_getText(exit_code_n, "exit code"), exit_code);
 
 
     return exit_code;
     return exit_code;
 }
 }
@@ -249,7 +248,7 @@ static int mainCL(ff_FFlags *ff) {
 
 
     if (rl == NULL && !command_line) {
     if (rl == NULL && !command_line) {
         writeErrorLog(aFunlangLogger, "CL not file to run");
         writeErrorLog(aFunlangLogger, "CL not file to run");
-        printf_stderr(0, "%s\n", HT_getText(NOT_FILE, "There are not file run"));
+        printf_stderr(0, "%s\n", HT_getText(cl_not_file_e, "There are not file run"));
         return EXIT_FAILURE;
         return EXIT_FAILURE;
     }
     }
 
 
@@ -277,7 +276,7 @@ static int mainCL(ff_FFlags *ff) {
         writeErrorLog(aFunlangLogger, "aFun exit code: %d", exit_code);
         writeErrorLog(aFunlangLogger, "aFun exit code: %d", exit_code);
     else
     else
         writeInfoLog(aFunlangLogger, "aFun exit code: %d", exit_code);
         writeInfoLog(aFunlangLogger, "aFun exit code: %d", exit_code);
-    printf_stderr(0, "aFun %s: %d\n", HT_getText(RUN_Exitcode_N, "exit code"), exit_code);
+    printf_stderr(0, "aFun %s: %d\n", HT_getText(exit_code_n, "exit code"), exit_code);
 
 
     destructAFunEnvironment(env);
     destructAFunEnvironment(env);
     freeAllRunList(rl);
     freeAllRunList(rl);
@@ -298,7 +297,7 @@ static int mainBuild(ff_FFlags *ff) {
             case 'o':
             case 'o':
                 if (path != NULL) {
                 if (path != NULL) {
                     writeErrorLog(aFunlangLogger, "Build argument conflict");
                     writeErrorLog(aFunlangLogger, "Build argument conflict");
-                    printf_stderr(0, "%s\n", HT_getText(ARG_CONFLICT, "Argument conflict (out, path)"));
+                    printf_stderr(0, "%s (--out, --path)\n", HT_getText(arg_conflict_n, "Argument conflict"));
                     goto error;
                     goto error;
                 }
                 }
                 out_put = text;
                 out_put = text;
@@ -306,7 +305,7 @@ static int mainBuild(ff_FFlags *ff) {
             case 'p':
             case 'p':
                 if (out_put != NULL) {
                 if (out_put != NULL) {
                     writeErrorLog(aFunlangLogger, "Build argument conflict");
                     writeErrorLog(aFunlangLogger, "Build argument conflict");
-                    printf_stderr(0, "%s\n", HT_getText(ARG_CONFLICT, ""));
+                    printf_stderr(0, "%s (--out, --path)\n", HT_getText(arg_conflict_n, ""));
                     goto error;
                     goto error;
                 }
                 }
                 path = text;
                 path = text;
@@ -328,7 +327,7 @@ out:
         /* 如果没有参数 */
         /* 如果没有参数 */
         if (!ff_getopt_wild(&text, ff)) {
         if (!ff_getopt_wild(&text, ff)) {
             writeErrorLog(aFunlangLogger, "Build not source file");
             writeErrorLog(aFunlangLogger, "Build not source file");
-            printf_stderr(0, "%s\n", HT_getText(NOT_BUILD_SRC, "There are not source file to build"));
+            printf_stderr(0, "%s\n", HT_getText(build_not_src_e, "There are not source file to build"));
             goto error;
             goto error;
         } else
         } else
             in = text;
             in = text;
@@ -336,7 +335,7 @@ out:
         /* 如果还有第二个参数 */
         /* 如果还有第二个参数 */
         if (ff_getopt_wild(&text, ff)) {
         if (ff_getopt_wild(&text, ff)) {
             writeErrorLog(aFunlangLogger, "Build too many source file");
             writeErrorLog(aFunlangLogger, "Build too many source file");
-            printf_stderr(0, "%s\n", HT_getText(MANY_BUILD_SRC, "There are too many source file to build. (Do not use --out option)"));
+            printf_stderr(0, "%s\n", HT_getText(build_many_src_e, "There are too many source file to build (Do not use --out option)"));
             goto error;
             goto error;
         }
         }
 
 

+ 3 - 3
src/main_build.c

@@ -8,19 +8,19 @@ int buildFileOutput(FilePath out, FilePath in, bool force) {
 
 
         if (time_1 == 0 && time_2 == 0) {
         if (time_1 == 0 && time_2 == 0) {
             writeErrorLog(aFunlangLogger, "Source not exists: %s", in);
             writeErrorLog(aFunlangLogger, "Source not exists: %s", in);
-            printf_stderr(0, "%s [%s]\n", HT_getText(NOT_BUILD_FILE_EXISITS, "Source not exists"), in);
+            printf_stderr(0, "%s [%s]\n", HT_getText(build_src_not_exists_e, "Source not exists"), in);
             return -1;
             return -1;
         }
         }
 
 
         if (time_2 >= time_1) {
         if (time_2 >= time_1) {
             writeWarningLog(aFunlangLogger, "Source already build %s", in);
             writeWarningLog(aFunlangLogger, "Source already build %s", in);
-            printf_stderr("%s (%s), %s\n", HT_getText(ALREADY_BUILD, "Source already build"), in, HT_getText(BUILD_AGAIN, "use --force to build again"));
+            printf_stderr("%s (%s), %s\n", HT_getText(build_src_already, "Source already build"), in, HT_getText(build_use_f, "use --force to build again"));
             return 0;
             return 0;
         }
         }
     }
     }
 
 
     writeInfoLog(aFunlangLogger, "Build %s, %s",  in, out);
     writeInfoLog(aFunlangLogger, "Build %s, %s",  in, out);
-    printf_stdout("Source will be build (%s -> %s)\n", in, out);
+    printf_stdout("Source will be build (%s -> %s)\n", HT_getText(build_file, "Source will be build"), in, out);
     return buildFile(out, in);
     return buildFile(out, in);
 }
 }
 
 

+ 9 - 9
src/runtime/aFunlang.c

@@ -78,7 +78,7 @@ static int runCode_(FilePath name, af_Parser *parser, int mode, FilePath save_pa
         int res = writeByteCode(bt_code, save_path);
         int res = writeByteCode(bt_code, save_path);
         if (res != 1) {
         if (res != 1) {
             writeErrorLog(aFunCoreLogger, "Save %s bytecode error: %s", save_path, writeByteCodeError[res]);
             writeErrorLog(aFunCoreLogger, "Save %s bytecode error: %s", save_path, writeByteCodeError[res]);
-            printf_stderr(0, "%s: %s\n", HT_getText(RUN_SAVE_ERROR, "Save aFun Bytecode file error"), save_path);
+            printf_stderr(0, "%s: %s\n", HT_getText(run_save_e, "Save aFun Bytecode file error"), save_path);
         }
         }
     }
     }
 
 
@@ -116,7 +116,7 @@ int runCodeFromFileSource(FilePath file, bool save_afb, FilePath save_path, int
     char *sufix = getFileSurfix(file);
     char *sufix = getFileSurfix(file);
     if (sufix == NULL || !EQ_STR(".aun", sufix)) {
     if (sufix == NULL || !EQ_STR(".aun", sufix)) {
         writeErrorLog(aFunCoreLogger, "Source is not .aun file: %s", (sufix == NULL ? "" : sufix));
         writeErrorLog(aFunCoreLogger, "Source is not .aun file: %s", (sufix == NULL ? "" : sufix));
-        printf_stderr(0, "%s: %s\n", HT_getText(RUN_NOT_AUN, "Source is not .aun file"), (sufix == NULL ? "" : sufix));
+        printf_stderr(0, "%s: %s\n", HT_getText(run_source_not_aub_e, "Source is not .aun file"), (sufix == NULL ? "" : sufix));
         return -2;
         return -2;
     }
     }
 
 
@@ -176,7 +176,7 @@ int runCodeFromFileByte(FilePath file, int mode, af_Environment *env){
     char *sufix = getFileSurfix(file);
     char *sufix = getFileSurfix(file);
     if (sufix == NULL || !EQ_STR(".aub", sufix)) {
     if (sufix == NULL || !EQ_STR(".aub", sufix)) {
         writeErrorLog(aFunCoreLogger, "Bytecode not .aub file: %s", (sufix == NULL ? "" : sufix));
         writeErrorLog(aFunCoreLogger, "Bytecode not .aub file: %s", (sufix == NULL ? "" : sufix));
-        printf_stderr(0, "%s: %s\n", HT_getText(RUN_NOT_AUB, "Bytecode not .aub file"), (sufix == NULL ? "" : sufix));
+        printf_stderr(0, "%s: %s\n", HT_getText(run_bt_not_aub_e, "Bytecode not .aub file"), (sufix == NULL ? "" : sufix));
         return -2;
         return -2;
     }
     }
 
 
@@ -184,7 +184,7 @@ int runCodeFromFileByte(FilePath file, int mode, af_Environment *env){
     int res = readByteCode(&code, file);
     int res = readByteCode(&code, file);
     if(res != 1) {
     if(res != 1) {
         writeErrorLog(aFunCoreLogger, "Load %s bytecode file error: %s", file, readByteCodeError[res]);
         writeErrorLog(aFunCoreLogger, "Load %s bytecode file error: %s", file, readByteCodeError[res]);
-        printf_stderr(0, "%s: %s\n", HT_getText(LOAD_BT_ERROR, "Load bytecode file error"), file);
+        printf_stderr(0, "%s: %s\n", HT_getText(run_load_bt_e, "Load bytecode file error"), file);
         return -2;
         return -2;
     }
     }
 
 
@@ -204,7 +204,7 @@ int runCodeFromFile(FilePath file, bool save_afb, int mode, af_Environment *env)
     char *sufix = getFileSurfix(file);
     char *sufix = getFileSurfix(file);
     if (sufix != NULL && !EQ_STR(".aun", sufix) && !EQ_STR(".aub", sufix)) {  // 不是源文件, 字节码文件或无后缀文件
     if (sufix != NULL && !EQ_STR(".aun", sufix) && !EQ_STR(".aub", sufix)) {  // 不是源文件, 字节码文件或无后缀文件
         writeErrorLog(aFunCoreLogger, "Run file not .aun/.aub file: %s", sufix);
         writeErrorLog(aFunCoreLogger, "Run file not .aun/.aub file: %s", sufix);
-        printf_stderr(0, "%s: %s\n", HT_getText(NOT_RUN_FILE_EXISITS, "Run file not .aun/.aub file"), file);
+        printf_stderr(0, "%s: %s\n", HT_getText(run_file_aun_aub_e, "Run file not .aun/.aub file"), file);
         return -2;
         return -2;
     }
     }
 
 
@@ -217,7 +217,7 @@ int runCodeFromFile(FilePath file, bool save_afb, int mode, af_Environment *env)
 
 
     if (time_1 == 0 && time_2 == 0) {
     if (time_1 == 0 && time_2 == 0) {
         writeErrorLog(aFunCoreLogger, "Run file not exists: %s", file);
         writeErrorLog(aFunCoreLogger, "Run file not exists: %s", file);
-        printf_stderr(0, "%s: %s\n", HT_getText(NOT_RUN_FILE_EXISITS, "Run file not exists"), file);
+        printf_stderr(0, "%s: %s\n", HT_getText(run_file_not_exists_e, "Run file not exists"), file);
         free(path_1);
         free(path_1);
         free(path_2);
         free(path_2);
         return -3;
         return -3;
@@ -250,13 +250,13 @@ int buildFile(FilePath out, FilePath in){
     char *suffix_out = getFileSurfix(out);
     char *suffix_out = getFileSurfix(out);
     if (suffix_in == NULL || !EQ_STR(".aun", suffix_in)) {  // 不是源文件
     if (suffix_in == NULL || !EQ_STR(".aun", suffix_in)) {  // 不是源文件
         writeErrorLog(aFunCoreLogger, "Input not .aun %s", (suffix_in == NULL ? "" : suffix_in));
         writeErrorLog(aFunCoreLogger, "Input not .aun %s", (suffix_in == NULL ? "" : suffix_in));
-        printf_stderr("%s: %s\n", HT_getText(BUILD_IN_AUN, "Input file is not .aun file"), (suffix_in == NULL ? "" : suffix_in));
+        printf_stderr("%s: %s\n", HT_getText(build_in_aun_e, "Input file is not .aun file"), (suffix_in == NULL ? "" : suffix_in));
         return -2;
         return -2;
     }
     }
 
 
     if (suffix_out == NULL || !EQ_STR(".aub", suffix_out)) {  // 不是字节码文件
     if (suffix_out == NULL || !EQ_STR(".aub", suffix_out)) {  // 不是字节码文件
         writeErrorLog(aFunCoreLogger, "Output not .aub %s", (suffix_out == NULL ? "" : suffix_out));
         writeErrorLog(aFunCoreLogger, "Output not .aub %s", (suffix_out == NULL ? "" : suffix_out));
-        printf_stderr("%s: %s\n", HT_getText(BUILD_OUT_AUB, "Output file is not .aub file"), (suffix_out == NULL ? "" : suffix_out));
+        printf_stderr("%s: %s\n", HT_getText(build_out_aub_e, "Output file is not .aub file"), (suffix_out == NULL ? "" : suffix_out));
         return -2;
         return -2;
     }
     }
 
 
@@ -271,7 +271,7 @@ int buildFile(FilePath out, FilePath in){
 
 
     if (res != 1) {
     if (res != 1) {
         writeErrorLog(aFunCoreLogger, "Build %s error: %s", in, writeByteCodeError[res]);
         writeErrorLog(aFunCoreLogger, "Build %s error: %s", in, writeByteCodeError[res]);
-        printf_stderr(0, "%s: %s\n", HT_getText(BUILD_ERROR_N, "Build error"), in);
+        printf_stderr(0, "%s: %s\n", HT_getText(build_error_e, "Build error"), in);
         return -3;
         return -3;
     }
     }