-
Notifications
You must be signed in to change notification settings - Fork 2
Adds English support #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Adding English will boost the repo contributions since all users who cannot speak Ukranian will be able to find more bugs as well as ebnhance the game
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! I don't think that this is a good implementation of the translation because it requires a lot of code duplication. I am sure that there is a good package for this purpose. Or if you want to stay simple you could just create a dictionary. For example:
class Lang(Enum):
en = 0
ua = 1
trans = {
'exit': ['Exit', 'Вихід']
...
}
I've been thinking of a simplified way, this is much better, I'll do it, Thanks for the valuable advice :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abdallah1097 Hi! I have looked at your commit as soon as you pushed, but it still has few problems. I was planning to correct these problems by myself and then write here what I changed, but unfortunately, I don’t have time for this right now 🤷🏻♂️
So I have just written them in the comments. If you will be able to apply my suggestion I would really appreciate it 🤘🏻
@@ -11,6 +12,7 @@ def __init__(self): | |||
self.current_user = None | |||
self.users = [] | |||
|
|||
self.text_messages = text_messages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating this variable inside each class is useless if you can use it directly from import.
@@ -0,0 +1,48 @@ | |||
ur = { | |||
'update_time': { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t think that these "levels" are useful. Maybe, if sometime in the future, I would like to use the 'Час' outside the update_time widget and this groping would confuse me.
I would do everything in a flat structure without any groups.
@@ -33,7 +35,7 @@ def sign_in(self, login, password): | |||
if password == 'admin': | |||
return 'admin' | |||
else: | |||
return 'Невірний пароль admin-а' | |||
return self.text_messages[settings.language.lower()].auth.sign_in.invalid_admin_password |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taking strings directly from the array could be tricky because every time you need to write [setting...]
. First of all, this makes a lot of useless code, secondly, it leaves a place for errors.
The better way is to create a class, that will automatically provide the string with the right language. But I think that this implementation would require more work and maybe additional libraries.
If you want to do it simpler, you can do it this way: assign the text_messages
variable needed translation at the start of the game.
Adding English Language Support will boost the repo contributions since all users who cannot speak Ukranian will be able to find more bugs as well as enhance the game. Simple change the setting.py to either english or russian