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

[WIP] Stop unpacking .po files from content packs #5524

Conversation

mrpau-eugene
Copy link
Contributor

@mrpau-eugene mrpau-eugene commented Oct 2, 2017

TODO

If not all TODOs are marked, this PR is considered WIP (work in progress)

  • Remove old functionality: Stop unpacking .po files from content packs
  • Remove old functionality: Remove ~/.kalite/locale from LOCALE_PATHS, it shouldn't be necessary anymore
  • Ensure that new path kalite/project/locale works

Issues addressed

#5518

@mrpau-eugene mrpau-eugene self-assigned this Oct 2, 2017
@codecov
Copy link

codecov bot commented Oct 2, 2017

Codecov Report

Merging #5524 into 0.17.x will increase coverage by 0.02%.
The diff coverage is 15.15%.

Impacted file tree graph

@@            Coverage Diff            @@
##           0.17.x   #5524      +/-   ##
=========================================
+ Coverage   62.77%   62.8%   +0.02%     
=========================================
  Files         117     117              
  Lines        6555    6549       -6     
=========================================
- Hits         4115    4113       -2     
+ Misses       2440    2436       -4
Impacted Files Coverage Δ
kalite/i18n/management/commands/makemessages.py 95.83% <ø> (ø) ⬆️
...nagement/commands/setup_in_context_translations.py 0% <0%> (ø) ⬆️
...tributed/management/commands/contentpackchecker.py 0% <0%> (ø) ⬆️
kalite/i18n/base.py 55.15% <10.52%> (-0.7%) ⬇️
kalite/legacy/i18n_settings.py 86.36% <100%> (ø) ⬆️
...ributed/management/commands/retrievecontentpack.py 51.48% <11.11%> (+3.3%) ⬆️
kalite/coachreports/models.py 84.95% <0%> (-0.89%) ⬇️
kalite/project/settings/base.py 87.38% <0%> (-0.69%) ⬇️

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 f862026...35a4315. Read the comment docs.

if not os.path.exists(DEFAULT_DATABASE_DIR):
os.mkdir(DEFAULT_DATABASE_DIR)

ensure_dir(USER_WRITABLE_LOCALE_DIR)

This comment was marked as spam.

Copy link
Contributor

@benjaoming benjaoming left a comment

Choose a reason for hiding this comment

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

Small changes :)

DEFAULT_DATABASE_DIR = os.path.join(USER_DATA_ROOT, "database",)
if not os.path.exists(DEFAULT_DATABASE_DIR):
os.mkdir(DEFAULT_DATABASE_DIR)

This comment was marked as spam.

@@ -188,16 +188,15 @@
# the user running kalite and should be in a user-data
# storage place.

USER_WRITABLE_LOCALE_DIR = os.path.join(USER_DATA_ROOT, 'locale')
KALITE_APP_LOCALE_DIR = os.path.join(USER_DATA_ROOT, 'locale')
from fle_utils.general import ensure_dir

This comment was marked as spam.

This comment was marked as spam.

@benjaoming
Copy link
Contributor

Great that coverage will improve because affected (removed!) code has no coverage :D

lang = lcode_to_django_lang(lang)
modir = get_po_filepath(lang)
if not os.path.exists(modir):
os.makedirs(modir)

This comment was marked as spam.

@@ -188,14 +188,12 @@
# the user running kalite and should be in a user-data
# storage place.

USER_WRITABLE_LOCALE_DIR = os.path.join(USER_DATA_ROOT, 'locale')
KALITE_APP_LOCALE_DIR = os.path.join(USER_DATA_ROOT, 'locale')
USER_WRITABLE_LOCALE_DIR = os.path.join(USER_DATA_ROOT, 'project', 'locale')

This comment was marked as spam.

This comment was marked as spam.

@mrpau-eugene mrpau-eugene changed the title Stop unpacking .po files from content packs [WIP] Stop unpacking .po files from content packs Oct 23, 2017
@mrpau-eugene
Copy link
Contributor Author

@benjaoming I just went back again on this PR, while reading the original issue again, I just wanted to know if the makemessages command should point to kalite/project/locale and not kalite/locale anymore?

@mrpau-eugene
Copy link
Contributor Author

Originally, the instructions are:

  • Remove old functionality: Stop unpacking .po files from content packs
  • Remove old functionality: Remove ~/.kalite/locale from LOCALE_PATHS, it shouldn’t be necessary anymore
  • Ensure that new path kalite/project/locale works

But there were other factors that affects the old process and I cannot just simply remove the ~/.kalite/locale because there are some files being stored in there such as the {lang}_metadata.json, so I was reading the codebase and initially came up with these new procedures:

  • Remove old functionality: Stop unpacking .po files from content packs
  • Remove old functionality: Remove ~/.kalite/locale from LOCALE_PATHS, it shouldn’t be necessary anymore
  • The above contains {lang}_metadata.json so we should move the {lang}_metadata.json to a new folder, maybe ~/.kalite/language-metadata/
  • Change update_jsi18n_file output path to somewhere inside kalite/project
  • Change the makemessages command output path to kalite/project/locale
  • For existing upgrades, copy the {lang}_metadata.json to the new metadata folder and delete the old one.
  • Ensure that new path kalite/project/locale works

I’m not quite sure if it is correct and it still might be missing something. Mind checking these procedures @benjaoming ?

@benjaoming
Copy link
Contributor

Hi @mrpau-eugene

But there were other factors that affects the old process and I cannot just simply remove the ~/.kalite/locale because there are some files being stored in there such as the {lang}_metadata.json

Ah no, the description doesn't say to remove the directory, just to remove it from the settings so we are sure translations still living there (from old content pack installations) are ignored:

Remove old functionality: Remove ~/.kalite/locale from LOCALE_PATHS, it shouldn’t be necessary anymore

@benjaoming
Copy link
Contributor

Hi @mrpau-eugene - I'll try to continue work over in #5537, will perhaps pass it back to you later -- the communication regarding how to understand the issue that I posted was a bit heavy for me to keep up with, but the task is also very much entangled in our old understanding of how KA Lite works -- so hopefully this will be the last headache about translations stuff, before we can move on to a more modern CrowdIn-based approach.

@benjaoming benjaoming closed this Nov 13, 2017
@mrpau-eugene
Copy link
Contributor Author

@benjaoming sure! just ping me anytime :)

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