Open campey opened 2 years ago
@james-smith-za mentioned the inheritance approach in https://github.com/coderlevelup/turtle-translated/issues/1#issuecomment-1310163337 it removes a lot of duplication, it is what first occurred to me too.
I would be perfectly happy with this.
I worry a little that it will impact the native-language parseability of error messages, but that is a minor point, also if we don't implement a method it will now no longer be accessible (currently you can still call the english version), but none of these are show-stoppers.
As an alternative approach, when I recently spoke to @asweigart about his work on https://github.com/asweigart/tortuga, he said he'd gone for a single, multi-linguial turtle, but I think we can happily continue exploring the current "multiple turtles each with a single language" approach, and then compare notes.
if we don't implement a method it will now no longer be accessible (currently you can still call the english version),
I don't think so - if we use inheritance, then the parent class's methods aren't suppressed. You can still do something like
import fudo
thabo = fudo.Fudo
thabo.forward(50)
I mean it would be bad form, but you could do it.
I worry a little that it will impact the native-language parseability of error messages, but that is a minor point
Hmmm, this is a good point. I'd need to sit and think about how this could be addressed.
if we use inheritance, then the parent class's methods aren't suppressed
Great! I was clearly suffering from another language hangover.
To break up into chunks, we might also consider moving out e.g. the 500 lines of code
### From here up to line : Tkinter - Interface for turtle.py ###
### May be replaced by an interface to some different graphics toolkit ###
Into a separate file, using an interface, and then we could handle common exceptions in the chosen language.
Most template i18n seems to be wanting to do something django styled, a simple placeholder replacement might be the way to refactor into one template file, and then generate the language files (not lovingly hand-craft them).
Something simple like this: https://stackoverflow.com/questions/63102375/python-placeholder-variables-in-text-file
Then there is removed duplication of effort, but still the joy of being able to have a fully translated turtle file for learners to read easily, and errors are more likely to make sense.
The current approach "commits all the sins necessary" with each language being a copy paste of the original turtle.py with strings hand-replaced.
The current approach was pragmatic to see if/how it was possible, but now is a good time to think about how to refactor / restructure, maintaining the same or similar user-facing commands.
Probably as simple as changing to inheritance, although I don't quite understand how those long lists of function names are used, so that needs comprehending.