-
Notifications
You must be signed in to change notification settings - Fork 64
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
i18n #77
Merged
i18n #77
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
3b702ba
Create i18n module, en.json, start replacing strings
eibex 0009d72
Add fallback
eibex 392d64a
track new files
eibex 1b13e48
add fallback
eibex 3100cca
moar strings + black formatting
eibex 719413b
Update __init__.py
eibex bf3fe67
fix response
eibex eb1f8f6
fix activity delete
eibex 8cc08d5
fix empty activities errors
eibex 706e156
fix empty activities errors
eibex 24a95ad
fix empty activities errors
eibex 7a2e94c
Add language command + part of new language
eibex 498e787
Merge branch 'master' into i18n
eibex cdc874f
Feedback on language update, update responses, formatting
eibex abc3801
finishing up translation + some fixes
eibex eecfd3a
change json filename format
eibex 0d63172
rework formatting with kwargs (#79)
Edwinexd 963efde
update it-it with readable args
eibex 27a3a94
en -> en-gb
eibex 8f6ad3a
kwargs in english.json (#80)
Edwinexd f181e03
consistency
eibex 6fe906f
update changelog, help command, version
eibex a546bb2
minor fixes
eibex 28fcf59
Merge branch 'master' into i18n
eibex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.4.3 | ||
2.5.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
from .database import * | ||
from .github import * | ||
from .schema import * | ||
from .i18n import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import os | ||
import json | ||
|
||
|
||
class Response: | ||
def __init__(self, directory, language, prefix): | ||
self.directory = directory | ||
self.language = language | ||
self.prefix = prefix | ||
self.responses = self.load() | ||
|
||
def load(self): | ||
data = {} | ||
for file in os.listdir(self.directory): | ||
if file.endswith(".json"): | ||
with open(f"{self.directory}/{file}", encoding="utf-8") as f: | ||
data[file.replace(".json", "")] = json.load(f) | ||
return data | ||
|
||
def get(self, item): | ||
try: | ||
response = self.responses[self.language][item] | ||
except KeyError: | ||
response = self.responses["en-gb"][item] | ||
print( | ||
f"Could not find a translation ({self.language}) for the requested i18n item: {item}. Please file an issue on GitHub." | ||
) | ||
response = response.replace("{prefix}", self.prefix) | ||
return response |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Feels like this should be handled in the
.format
elsewhere, seems odd to only handle this replacement here.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 did it like this because it's the only var that is fixed and present across several strings.
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.
Wouldn't it feel redundant to .format(prefix) everywhere?
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.
True, although I don't like the concept of one variable being handled differently from the others, might get confusing down the line
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.
Yeah, I can see your point too.
I will leave this unresolved for now while I think about it.