3 ms·
I think the main point is to remove the Chinese characters in the string literal and refer to some object which contains the contents of some already-parsed loc
by smcl 9y ago
I think the main point is to remove the Chinese characters in the string literal and refer to some object which contains the contents of some already-parsed localisation file - and that's the file where the Chinese chars characters would live.
So you'd probably write something like:
print(localisedStuff["zh"]["hello-world"])
This looks clunky in a little standalone example but if you can imagine having to build an app that supports many languages then this starts to make sense as you'd more likely have:
print(localisedStuff[selectedLanguage]["hello-world"])
However I disagree with the original comment that non-ASCII chars shouldn't be supported in code - I think that Chinese, Arabic, Korean, Israeli (etc) speaking devs should be able to deal with string literals in whatever language they feel comfortable in.