Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
x/tools/cmd/godoc: specifying a file's language #6893
Go source files are UTF-8 so there is, in principle, no need to specify its encoding or language. However, I think there is one case when it would be very convenient to specify in which language are the comments written. When using CJK (Chinese, Japanese and Korean), there are different variations of some ideograms that are written with different glyphs (sometimes differences are minor, sometimes not so minor). However, in Unicode, some of these varied glyphs share the same codepoint, so it is not possible to choose the right glyph if the language is unknown. This is called the Han Unification: https://en.wikipedia.org/wiki/Han_unification HTML code can include the <lang> label to inform the browser which font should it use to render a text. If it is not included, the browser usually will use a default font. For example, Google Chrome on a non-CJK system will usually choose a Chinese font, and Japanese ideograms will be rendered with Chinese glyphs. So my suggestion would be to include some kind of label for godoc to include the right <lang> label in the HTML generated, so it will be rendered correctly in most systems. Ideally, it should be possible to modify it inside a file, so you could write Chinese and Japanese in the same file. What do you think?
I've searched in godoc for repositories with Japanese documentation for a real case. For example http://godoc.org/github.com/yokano/escape3ds/server/view contains Japanese comments that are rendered in Chinese in my computer. There is no <lang> label so it is up to the browser. Honestly, with my limited Japanese I only found one ideogram rendered incorrectly in that package (終), but the issue is present.