Skip to content
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

feat: Initialize Internationalization #18

Merged
merged 20 commits into from
Aug 26, 2022
Merged

Conversation

sumit-158
Copy link
Member

What

  • Initializing Internationalization

@teolemon
Copy link
Member

@sumit-158 I've added tooling for Crowdin

@teolemon teolemon changed the title Initialize Internationalization feat: Initialize Internationalization Aug 15, 2022
app/main.py Outdated Show resolved Hide resolved
app/i18n.py Outdated Show resolved Hide resolved
@sumit-158 sumit-158 marked this pull request as ready for review August 23, 2022 11:32
@sumit-158 sumit-158 added the ✨ enhancement New feature or request label Aug 23, 2022
"Looking up a translation while language was not set. "
"Use active_translation context manager",
stack_info=True,
)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexgarel Just a question what does stack_info=True do?

Copy link
Member

@alexgarel alexgarel Aug 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it prints the stack trace along with the log message (like for exceptions).
Here I added it, because if I just log the developer won't see where the translation function was called, whereas here he sees the lines.

Eg:

knowledge-panel | Looking up a translation while language was not set. Use active_translation context manager
knowledge-panel | Stack (most recent call last):
knowledge-panel |   File "/usr/local/lib/python3.9/threading.py", line 937, in _bootstrap
knowledge-panel |     self._bootstrap_inner()
knowledge-panel |   File "/usr/local/lib/python3.9/threading.py", line 980, in _bootstrap_inner
knowledge-panel |     self.run()
knowledge-panel |   File "/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 867, in run
knowledge-panel |     result = context.run(func, *args)
knowledge-panel |   File "/code/./app/main.py", line 45, in knowledge_panel
knowledge-panel |     panels.append(last_edits_kp(facet=facet_tag, value=value_tag, country=country))
knowledge-panel |   File "/code/./app/knowledge_panels.py", line 121, in last_edits_kp
knowledge-panel |     expected_html, t_description, t_title = last_edit(url=url, query=query)
knowledge-panel |   File "/code/./app/off.py", line 80, in last_edit
knowledge-panel |     description = _("last-edits issues related to")
knowledge-panel |   File "/code/./app/i18n.py", line 66, in translate
knowledge-panel |     return get_current_translation().gettext(message)
knowledge-panel |   File "/code/./app/i18n.py", line 55, in get_current_translation
knowledge-panel |     log.warning(

So you see the problem is in off.py line 80

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh cool! sorry but can I know how to get that log message?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the activate_translation line in main.py :-)

@alexgarel alexgarel added the i18n label Aug 26, 2022
@sumit-158
Copy link
Member Author

sumit-158 commented Aug 26, 2022

Another question , Do I have to make lan_code/LC_MESSAGES/knowledge-panel.po for every supported lang or does the crowdin will do that for me?
another : Is .mo file suppose to be in gitignore ?

@alexgarel
Copy link
Member

Another question , Do I have to make lan_code/LC_MESSAGES/knowledge-panel.po for every supported lang or does the crowdin will do that for me?

I don't know but @teolemon may now

another : Is .mo file suppose to be in gitignore ?
It's a choice, we could also put them in the git repo, but as we tend to have many languages in off, I would not, until we find a good reason to add them :-)

@sumit-158
Copy link
Member Author

It because gettext takes .mo file to read the translation , if we don't remove it from gitignore during deployment how it goona fetch the translation ?

@teolemon
Copy link
Member

crowdin will do that for you,
yes, mo should be gitignored, and rebuilt during deployment if needed

@sumit-158
Copy link
Member Author

@alexgarel should we merge it now!

Copy link
Member

@alexgarel alexgarel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's merge !

@alexgarel alexgarel merged commit bc6085a into main Aug 26, 2022
@alexgarel alexgarel deleted the Setup-internationalization branch August 26, 2022 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request i18n
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants