Everyone here’s joking but now I’m curious: why isn’t there a compiler flag to set the language that will swap out keywords to localized variants? It seems silly that someone that speaks French can’t swap out if/for/char/etc to something that makes more sense to them.
Because there's a risk of keywords clashing with identifiers (i.e. function/variable names etc.). That, and portability.
Imagine handing your source code to a friend and your program fails to compile on their machine. Or, worse, it compiles but behaves differently when run.
Compiler flags (and a project file or Makefile or something that you ship with your source code) can solve this to some degree, but in general features like these are considered a net negative.
Just look at Excel. As someone else pointed out in a sibling comment, it has the feature you want. Yet, everyone hates it. Like, why does it say this function doesn't exist? Oh, it wants me to translate the function name to my native language in my head...
Excel is also awful for even more reasons, for example if I open a csv file that contains fields that look like dates it coerces them all into the format defined by the system date format (which is awkward to change on windows) and then saves it like that
At least in C and it's ilk, you could build out an abomination of a translation header file to have translated keywords. The real ones would still work too of course.
Preprocessor macros effictively just act as a find/replace just before actually compiling, so it would functionally become a bilingual C language in the underlying source file.
And this is so annoying when I look up some functionality in English and then need to translate it to German again because I can't just copy paste it because I need to share the files with my coworkers that have their excel in German. They could've at least kept the English ones active regardless of the language you're using.
And people are absolutely suffering because of it. Stuff like this should never be localised. You can translate the documentation and the tool tips but the functions themselves should stay completely consistent
This further convinces me that it's a legacy mistake for source code to just be raw text. If it were saved to some binary format, the representation for "function" could be displayed in whatever way you want on your machine, and a totally different way on a friend's machine. Let the file contain only the language semantics (no formatting) and let each developer format it however they want.
View all comments
15
u/LEPT0N 20d ago
Everyone here’s joking but now I’m curious: why isn’t there a compiler flag to set the language that will swap out keywords to localized variants? It seems silly that someone that speaks French can’t swap out if/for/char/etc to something that makes more sense to them.