Closed zingix closed 6 years ago
Looks good. How about a couple of optimizations?
Firstly, to avoid double lookup when not necessary:
if (text == null && msgkey.Contains("\\u")) { ... }
Secondly, how about creating the RegEx as a static member object of that TextLocalizer class, just in case it is re-created each time? Probably doesn't and in fact get's cached, but it would be in keeping with all other regex usage in the lib.
Cheers.
Suppose the Regex object could then also be used for test for a match, in preference to using Contains
Correct, that is a good point. Added a compiled regex and the required test.
Nice PR, thanks for contributing.
The following modification allows also JSON encoded responses to be translated correctly.