10

I recently bumped into this question and I saw that the user has Spanish names for variables and etc. like that:

var textbuscar = document.getElementById("buscar");

Being non-English speaker I still believe that using native (non-English) language (where not necessary) is hurting readability and understanding of code.

Thus I am concerned - should I provide (if I can) an edit where I will replace all local-language variables and stuff with English ones if I find the usage of those excessive?

var textSearch = document.getElementById("search");
7
  • 3
  • 3
    It's the id of an element. If you wouldn't rename a variable named x, why rename an element named buscar (or variable named textbuscar)? You don't need to know the meaning of the word to see whether it matches usage elsewhere in the code. Also, language has nothing to do with race, so you might consider rephrasing that middle paragraph.
    – Paul Roub
    Commented Jun 28, 2016 at 16:10
  • 2
    @paul in that case I am not, but what about this code static bool FraNuklEkorAffDeeta(Ramulk r, Date jobingaTor, Granu g) { return (r.Protpork + jobingaTor) > g.KnabMoDeeta; } ? I don`t think thats readable
    – Zanshin13
    Commented Jun 28, 2016 at 16:30
  • 1
    I think this answers your question: meta.stackoverflow.com/a/297680/1767412, unless someone wants to argue the code is not "content" - which I think it is. Commented Jun 28, 2016 at 17:47
  • 1
    @billynoah see this highly upvoted comment.
    – Glorfindel
    Commented Jun 28, 2016 at 18:09
  • @Glorfindel - thanks for pointing that out. The policy seems to be "don't edit" either way, but for different reasons. Anyway, I believe we're in agreeance - don't edit Commented Jun 28, 2016 at 18:12
  • and for what it's worth, there's no way I'm voting to close or flagging a question because of non-english variable names. most variable names hardly resemble english anyway Commented Jun 28, 2016 at 18:14

2 Answers 2

20

No, in general: don't edit code, neither in questions nor in answers. Proper formatting is probably the only exception (and Python code is an exception to that exception). By editing code snippets, especially when it comes to renaming variables, the resulting code is almost guaranteed not to work in the context of the OP's project.

If someone doesn't understand why a variable is named like it is, and it is necessary for creating a good answer, he/she can always leave a comment.

But you are right, naming variables in English is 100% better. To me (native Dutch speaker) it even looks silly, English reserved words of the programming language intermingled with Dutch variable names.

2
  • 1
    var worterSuchen = document.getElementById("suchen") being a russian-speaking that reads even funnier than you may think
    – Zanshin13
    Commented Jun 28, 2016 at 16:23
  • 12
    I almost can't stress this enough. Often times, when editing code, the little small fixes you do almost instinctively as a programmer might end up completly invalidating the question or cancelling out some small but significant detail that the entire problem case hinges upon.
    – Magisch
    Commented Jun 28, 2016 at 16:43
7

You should edit your code samples to either use sensible English words in variable/method names or (if not important to question) use generic one-two letter names.

You should not edit code in other posts - edits without full edit privileges will likely be rejected, edits with full edit privileges likely be frowned upon. Comment on the post instead if you find that names distracting from the question.

Note: If you know that names are offensive - edit is ok - make sure to have good edit summary. If OP rolls back such edit (edit war starts) - flag such post.

Not the answer you're looking for? Browse other questions tagged .