Closed bigBear713 closed 1 year ago
It seems unnecessary to use uuid lib or Symbol. I put the data in params into the trans string before, so had to replce the param key with an unique value in trans string first, to prevent some param values are duplicated with some param keys. You know it will cause some error. So I import the uuid lib. Now I am going to change the way of handling. Before, the trans string is always a string, now, I am going to split it as a string array based on param keys. So can use the param keys in trans string array to get param values from params directly.
Will use regexp to split the transled string, so in order to keep the content safe, we should limit the value of param key. It's a good idea to keep the naming rules consistent with JS variable names:
letters, numbers, _, and $
number
can't be the first characterIt is better if here can print the warning info when a param key is invalid. It can help the developers to fix the error.
Also, developers can turn off the print of the warning info.
It is better the print of the warning info will auto be turned off in prod env
The uuid
lib has been removed in v16.0.0
version:
v15.1.0
We know in translated statement, if a prev param value contains the next param key, there is a problem when using the prev param value to replace the corresponding param key.
So now using uuid to replace all param key in translated statement firstly, then using param values to replace the param keys corresponding uuid value in statement. But so we have to import
uuid
lib. I think it is better if here can use Symbol to replaceuuid
, because theuuid
lib can give us unique values, and the Symbol also can be unique