4 ms·
> Also, can we please, please, please keep source code files as pure ascii How do you propose that we write programs that interact with non-ASCII compatible la
by wodenokoto 9y ago
> Also, can we please, please, please keep source code files as pure ascii
How do you propose that we write programs that interact with non-ASCII compatible language users? All string literals are to be saved in external, somehow non-source code files?
How would you go about writing a Chinese "Hello World"?
In Python 3, I would write
print("你好,世界!")
I have no idea how you propose this should be done in pure ascii.
- masklinn 9y agoprint("\u4f60\u597d\uff0c\u4e16\u754c\uff01") I'd guess?
- matthewrudy 9y agoin which case you'll need to add a comment to remember what it says: print("\u4f60\u597d\uff0c\u4e16\u754c\uff01") # "你好,世界!"
- masklinn 9y agoThat makes the source file not-ascii again.
- matthewrudy 9y agoSure. That's my joke. You'd obfuscate the content, but to be practical you'd still have to know what it said. Hence my comment.
- smcl 9y agoI 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.
- icebraining 9y agoI'm not opposed to unicode in source code, but we do put all string literals in external files, by using gettext. Your example would be: print(_("Hello World!")) And then a zh.po file with: #: file.py:1 msgid "Hello World!" msgstr "你好,世界!"
- saurik 9y agoThis assumes then programmer speaks English and Chinese is a "translation".
- masklinn 9y agoOr even just the second part. One could imagine software with chinese as the reference and english as the translation. I guess that's one good thing about Java's resource bundles, though they don't help source readability.
- icebraining 9y agoIt's just a placeholder, you can use anything. The company I work for, and its clients, are not in English-speaking countries either.