Skip to content

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

abdallah1097
Copy link
Contributor

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

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
Copy link
Owner

@SashaKryzh SashaKryzh left a 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', 'Вихід']
    ...
}

@SashaKryzh SashaKryzh added the enhancement New feature or request label Dec 18, 2020
@abdallah1097
Copy link
Contributor Author

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 :)

Copy link
Owner

@SashaKryzh SashaKryzh left a 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
Copy link
Owner

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': {
Copy link
Owner

@SashaKryzh SashaKryzh Dec 21, 2020

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
Copy link
Owner

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.

@SashaKryzh SashaKryzh linked an issue Dec 26, 2020 that may be closed by this pull request
@SashaKryzh SashaKryzh added the good first issue Good for newcomers label Dec 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

English support
2 participants