I have created a contract using solidity which has a comment field. I want to provide multi language support so that user can insert and retrieve comment in any language.
Please suggest how we can achieve this feature?
I have created a contract using solidity which has a comment field. I want to provide multi language support so that user can insert and retrieve comment in any language.
Please suggest how we can achieve this feature?
Instead of using just a single string to store the comment, you will have to use an array, struct or mapping to store all the translations. For example, you could create a mapping of two-letter language codes to the versions of the comment in that language:
mapping (bytes2 => string) languageCodeToComment;
Now, you can add a comment in multiple langauges:
languageCodeToComment["EN"] = "This is the English comment!";
languageCodeToComment["NL"] = "Dit is het Nederlandse bericht!";
languageCodeToComment["FY"] = "Dit is yn it Frysk!";
languageCodeToComment["ZH"] = "漢字";
– Jesbus
Oct 25 '17 at 08:55