def delete_language(lang_code): langpack_resource_paths = [ get_localized_exercise_dirpath(lang_code), get_srt_path(lang_code), get_locale_path(lang_code), ] for langpack_resource_path in langpack_resource_paths: try: shutil.rmtree(langpack_resource_path) logging.info("Deleted language pack resource path: %s" % langpack_resource_path) except OSError as e: if e.errno != 2: # Only ignore error: No Such File or Directory raise else: logging.debug("Not deleting missing language pack resource path: %s" % langpack_resource_path) invalidate_web_cache()
def delete_language(lang_code): langpack_resource_paths = [ get_localized_exercise_dirpath(lang_code), get_srt_path(lang_code), get_locale_path(lang_code) ] for langpack_resource_path in langpack_resource_paths: try: shutil.rmtree(langpack_resource_path) logging.info("Deleted language pack resource path: %s" % langpack_resource_path) except OSError as e: if e.errno != 2: # Only ignore error: No Such File or Directory raise else: logging.debug( "Not deleting missing language pack resource path: %s" % langpack_resource_path) invalidate_web_cache()
import tempfile import zipfile from cStringIO import StringIO from django.conf import settings from django.core.management.base import NoArgsCommand from fle_utils.general import ensure_dir from kalite.i18n import get_language_pack_url, get_locale_path, update_jsi18n_file from kalite.version import VERSION logging = settings.LOG BASE_LANGUAGE_PACK = "de" # language where we base the dummy langpack from TARGET_LANGUAGE_PACK = "eo" # what the "dummy" language's language code. Will be. Sorry, Esperantists. TARGET_LANGUAGE_DIR = get_locale_path(TARGET_LANGUAGE_PACK) MO_FILE_LOCATION = os.path.join(TARGET_LANGUAGE_DIR, "LC_MESSAGES") TARGET_LANGUAGE_METADATA_PATH = os.path.join( TARGET_LANGUAGE_DIR, "%s_metadata.json" % TARGET_LANGUAGE_PACK, ) class Command(NoArgsCommand): def handle_noargs(self, **options): logging.info("Creating a debugging language pack, with %s language code." % TARGET_LANGUAGE_PACK) langpack_zip = download_language_pack(BASE_LANGUAGE_PACK) django_mo_contents, djangojs_mo_contents = retrieve_mo_files(langpack_zip) dummy_django_mo, dummy_djangojs_mo = (create_mofile_with_dummy_strings(django_mo_contents, filename="django.mo"), create_mofile_with_dummy_strings(djangojs_mo_contents, filename="djangojs.mo"))