Преглед изворни кода

Expose QCoreApplication::translate() to host environment

Neal Wilson пре 8 година
родитељ
комит
3cf4444fce
1 измењених фајлова са 12 додато и 0 уклоњено
  1. 12
    0
      src/typica.w

+ 12
- 0
src/typica.w Прегледај датотеку

@@ -4149,6 +4149,7 @@ QScriptValue annotationFromRecord(QScriptContext *context,
4149 4149
                                   QScriptEngine *engine);
4150 4150
 QScriptValue setTabOrder(QScriptContext *context, QScriptEngine *engine);
4151 4151
 QScriptValue saveFileFromDatabase(QScriptContext *context, QScriptEngine *engine);
4152
+QScriptValue scriptTr(QScriptContext *context, QScriptEngine *engine);
4152 4153
 
4153 4154
 @ These functions are passed to the scripting engine.
4154 4155
 
@@ -4164,6 +4165,7 @@ engine->globalObject().setProperty("setTabOrder",
4164 4165
                                    engine->newFunction(setTabOrder));
4165 4166
 engine->globalObject().setProperty("saveFileFromDatabase",
4166 4167
                                    engine->newFunction(saveFileFromDatabase));
4168
+engine->globalObject().setProperty("TTR", engine->newFunction(scriptTr));
4167 4169
 
4168 4170
 @ These functions are not part of an object. They expect a string specifying
4169 4171
 the path to a file and return a string with either the name of the file without
@@ -4290,6 +4292,16 @@ QScriptValue setTabOrder(QScriptContext *context, QScriptEngine *)
4290 4292
     return QScriptValue();
4291 4293
 }
4292 4294
 
4295
+@ This function is used to allow text that must be placed in scripts to be
4296
+translated into other languages.
4297
+
4298
+@<Functions for scripting@>=
4299
+QScriptValue scriptTr(QScriptContext *context, QScriptEngine *)
4300
+{
4301
+    return QScriptValue(QCoreApplication::translate(
4302
+        argument<QString>(0, context).toAscii().data(),
4303
+        argument<QString>(1, context).toUtf8().data()));
4304
+}
4293 4305
 
4294 4306
 @** Application Configuration.
4295 4307
 

Loading…
Откажи
Сачувај