Translating Regular Expression Errors
Translating Regular Expression Errors
Is it possible to make an external file for a list of regular expression errors to be able to translate into languages other than English? There are specific programs that will only be used in their own country.
Re: Translating Regular Expression Errors
I *assume* it's based on PCRE like PB. http://www.pcre.org/pcre.txt
Regular Expression you won't master in a single sitting; too much variation and syntax. They just allow you to one-line pattern matching instead of scanning for matching in a simple binary or unicode character loop...
Only solution I see for your problem is using a translation service, likely over HTTP, in your code... I don't see any language mappings for it in the files...
Regular Expression you won't master in a single sitting; too much variation and syntax. They just allow you to one-line pattern matching instead of scanning for matching in a simple binary or unicode character loop...
Only solution I see for your problem is using a translation service, likely over HTTP, in your code... I don't see any language mappings for it in the files...
Re: Translating Regular Expression Errors
PCRE uses an error code
I wonder how many phrases there are. I can simulate standard errors (no opening or closing brackets, etc.) and make an array to replace strings.
I spied a function in one of the scripts
Considering that it is possible to get the browser language
On Windows I get the error text in Russian.
It can be assumed that the error text can be assignedError return values from pcre_exec()
If pcre_exec() fails, it returns a negative number. The following are
defined in the header file:
PCRE_ERROR_NOMATCH (-1)
The subject string did not match the pattern.
PCRE_ERROR_NULL (-2)
Either code or subject was passed as NULL, or ovector was NULL and
ovecsize was not zero.
PCRE_ERROR_BADOPTION (-3)
An unrecognized bit was set in the options argument.
PCRE_ERROR_BADMAGIC (-4)
Code: Select all
new SyntaxError(message)
Code: Select all
var e = new Error("Malformed input") // e.name = "Error"
e.name = "ParseError" // e.toString() will return "ParseError: Malformed input"
throw e;
Code: Select all
var e = new Error("A problem has occurred");
// e.message = A problem has occurred
throw e;
So the internal javascript text is used.I don't see any language mappings for it in the files...
I wonder how many phrases there are. I can simulate standard errors (no opening or closing brackets, etc.) and make an array to replace strings.
I spied a function in one of the scripts
Code: Select all
WScript.Echo(_localize("Save file first!"));
function _localize(s) {
var strings = {
"Save file first!": {
ru: "Сначала сохраните файл!"
},
"Name of backup file:": {
ru: "Имя файла резервной копии:"
}
};
var lng = "en";
// switch(AkelPad.GetLangId(1 /*LANGID_PRIMARY*/)) {
// case 0x19: lng = "ru";
// }
lng = "ru";
_localize = function(s) {
return strings[s] && strings[s][lng] || s;
};
return _localize(s);
}
Code: Select all
!var v_lang0$ = navigator.language;