Browse Source

Expose QCoreApplication::translate() to host environment

Neal Wilson 8 years ago
parent
commit
3cf4444fce
1 changed files with 12 additions and 0 deletions
  1. 12
    0
      src/typica.w

+ 12
- 0
src/typica.w View File

4149
                                   QScriptEngine *engine);
4149
                                   QScriptEngine *engine);
4150
 QScriptValue setTabOrder(QScriptContext *context, QScriptEngine *engine);
4150
 QScriptValue setTabOrder(QScriptContext *context, QScriptEngine *engine);
4151
 QScriptValue saveFileFromDatabase(QScriptContext *context, QScriptEngine *engine);
4151
 QScriptValue saveFileFromDatabase(QScriptContext *context, QScriptEngine *engine);
4152
+QScriptValue scriptTr(QScriptContext *context, QScriptEngine *engine);
4152
 
4153
 
4153
 @ These functions are passed to the scripting engine.
4154
 @ These functions are passed to the scripting engine.
4154
 
4155
 
4164
                                    engine->newFunction(setTabOrder));
4165
                                    engine->newFunction(setTabOrder));
4165
 engine->globalObject().setProperty("saveFileFromDatabase",
4166
 engine->globalObject().setProperty("saveFileFromDatabase",
4166
                                    engine->newFunction(saveFileFromDatabase));
4167
                                    engine->newFunction(saveFileFromDatabase));
4168
+engine->globalObject().setProperty("TTR", engine->newFunction(scriptTr));
4167
 
4169
 
4168
 @ These functions are not part of an object. They expect a string specifying
4170
 @ These functions are not part of an object. They expect a string specifying
4169
 the path to a file and return a string with either the name of the file without
4171
 the path to a file and return a string with either the name of the file without
4290
     return QScriptValue();
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
 @** Application Configuration.
4306
 @** Application Configuration.
4295
 
4307
 

Loading…
Cancel
Save