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?
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.Sign up to join this community
Instead of using just a single
string to store the comment, you will have to use an
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!";