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

Add localization activation ability #275

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

derfenix
Copy link

Add ability to use default localization in tasks without manual activation for each task.

@codecov
Copy link

codecov bot commented Feb 20, 2018

Codecov Report

Merging #275 into master will increase coverage by 0.01%.
The diff coverage is 85.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #275      +/-   ##
==========================================
+ Coverage   82.06%   82.08%   +0.01%     
==========================================
  Files          24       24              
  Lines        1344     1351       +7     
==========================================
+ Hits         1103     1109       +6     
- Misses        241      242       +1
Impacted Files Coverage Δ
django_rq/settings.py 94.73% <100%> (+0.61%) ⬆️
django_rq/workers.py 97.77% <80%> (-2.23%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 31d44d0...0d20f34. Read the comment docs.

@@ -38,6 +39,11 @@ def get_worker_class(worker_class=None):
return worker_class


def activate_localization():
if getattr(settings, 'RQ_USE_LOCALIZATION', False):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you please move this variable to DjangoRQ's settings.py?

Copy link
Author

Choose a reason for hiding this comment

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

Done

@@ -38,6 +39,11 @@ def get_worker_class(worker_class=None):
return worker_class


def activate_localization():
if getattr(settings, 'RQ_USE_LOCALIZATION', False):
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can simplify this to if settings.RQ_USE_LOCALIZATION:

@@ -25,3 +25,8 @@

# Token for querying statistics
API_TOKEN = getattr(settings, 'RQ_API_TOKEN', '')

# Activate locale for each task
RQ_USE_LOCALIZATION = getattr(settings, 'RQ_USE_LOCALIZATION', False)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we rename this to RQ_USE_L10N to keep it consistent with Django's naming scheme? RQ_LANGUAGE_CODE defaults to Django's LANGUAGE_CODE setting, should we also change this to default to Django's USE_L10N setting?

@@ -49,6 +55,7 @@ def get_worker(*queue_names, **kwargs):
# normalize queue_class to what get_queues returns
queue_class = queues[0].__class__
worker_class = get_worker_class(kwargs.pop('worker_class', None))
activate_localization()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can simply do this (and delete activate_localization()):

if settings.RQ_USE_LOCALIZATION:
    activate(settings. RQ_LANGUAGE_CODE)

@selwin
Copy link
Collaborator

selwin commented Mar 30, 2018

@derfenix reminder to update this PR

@selwin
Copy link
Collaborator

selwin commented Mar 30, 2019

If you're still interested in getting this in, please fix the failing tests and document this feature in README

@derfenix
Copy link
Author

derfenix commented Apr 5, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants