Skip to content

Add direct text migration mode#32

Merged
dbendilas merged 1 commit intodevelfrom
migrate-text-mode
Jun 29, 2020
Merged

Add direct text migration mode#32
dbendilas merged 1 commit intodevelfrom
migrate-text-mode

Conversation

@dbendilas
Copy link
Copy Markdown
Contributor

@dbendilas dbendilas commented Jun 29, 2020

Add mode to the migrate Django command that converts code to Transifex Native syntax.

Introduced a new parameter to the ./manage.py transifex migrate command, --text or -t (this command needs to be run from inside a Django app's venv that has transifex-python installed).

HTML Django templates

./manage.py transifex migrate --text='{% blocktrans %}This string will have {{ value }} inside.{% endblocktrans %}'
./manage.py transifex migrate -t='{% t amount=article.price %}
                                 That will cost $ {amount}.
                                 {% endt %}

                                 {% t myvar=value|filter %}
                                 This will have {myvar} inside.
                                 {% endt %}'

Screenshot 2020-06-29 at 09 20 29

Python/gettext code

./manage.py transifex migrate --text='from django.utils.translation import gettext as _

                                 a = _("This is translatable")'

The import statements need to be present, otherwise the function calls cannot be detected (just like when migrating Python code with the "file" mode).
Screenshot 2020-06-29 at 09 24 47

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 29, 2020

Codecov Report

Merging #32 into devel will increase coverage by 0.30%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##            devel      #32      +/-   ##
==========================================
+ Coverage   76.72%   77.03%   +0.30%     
==========================================
  Files          33       33              
  Lines        2647     2660      +13     
==========================================
+ Hits         2031     2049      +18     
+ Misses        616      611       -5     
Impacted Files Coverage Δ
...ransifex/native/django/management/utils/migrate.py 95.23% <100.00%> (+0.79%) ⬆️
transifex/native/tools/migrations/execution.py 75.17% <100.00%> (+0.72%) ⬆️
transifex/_version.py 44.76% <0.00%> (+1.80%) ⬆️

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 053e036...f008c95. Read the comment docs.

Add mode to the migrate Django command that converts code
to Transifex Native syntax.
@dbendilas dbendilas force-pushed the migrate-text-mode branch from 1d5a29c to f008c95 Compare June 29, 2020 07:10
@dbendilas dbendilas merged commit d5a4a1a into devel Jun 29, 2020
@dbendilas dbendilas deleted the migrate-text-mode branch June 29, 2020 11:36
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