Hi Team,
1)We have language coming as 'People's Republic of China', we need to remove the special character ''.
Is there any way we can do without regular expression?
2)How to sort the list of translation language?
Regards,
BhanuPrakash
Hi Team,
1)We have language coming as 'People's Republic of China', we need to remove the special character ''.
Is there any way we can do without regular expression?
2)How to sort the list of translation language?
Regards,
BhanuPrakash
Hello,
Can we clarify before answering your questions, why you don't want to filter Javascript string with regular expression or with another way?
Thanks, Alex
SurveyJS Team
Hi Alex
Yes, we can do using regular expression, asked to get to know for better approach.
Need help with sorting, We are able to sort with language code. But user expectation is based on language name.
So is there any way, we can get sorted language dropdown in translation?
Regards,
BhanuPrakash
Hello,
I have fixed the second issue. Here is the related issue on GitHub. I committed the fix into ms branch as well.
Thank you,
Andrew
SurveyJS Team
Hi Andrew,
The fix you have made for sorting, is not working as expected in other languages. Its working only for English.
How can we use this feature for other languages?
Thanks,
BhanuPrakash
Hello,
You can override the function that returns the locales array, string array. Here is the example of code:
Survey.Serializer.findProperty("survey", "locale").setChoices(undefined, (obj) => { var res = Survey.surveyLocalization.getLocales(true); var locName = (loc) => { if (!loc) return ""; var res = Survey.surveyLocalization.localeNames[loc]; if (!res) res = loc; return res.toLowerCase(); }; res.sort((a, b) => { var str1 = locName(a); var str2 = locName(b); if (str1 === str2) return 0; return str1 < str2 ? -1 : 1; }); return res; });
Actually this is the code we have now. Probably we do not sort correctly Chinese characters. It is hard for us to test it.
Probably you are overriding locale display name differently. In this case you have to change the internal "locName" function.
If you can create a better code that works with Chinese characters as well, we could replace it with our current code, in case it works with other languages correctly.
Right now, I just don't know how to test it properly and what code should I change, so it works out of the box for you.
Thank you,
Andrew
SurveyJS Team