Exemple #1
0
def download_bulk_app_translations(request, domain, app_id):
    lang = request.GET.get('lang')
    skip_blacklisted = request.GET.get('skipbl', 'false') == 'true'
    app = get_app(domain, app_id)
    # if there is a lang selected, assume that user wants a single sheet
    is_single_sheet = bool(lang)
    headers = get_bulk_app_sheet_headers(
        app,
        single_sheet=is_single_sheet,
        lang=lang,
        eligible_for_transifex_only=skip_blacklisted)
    if is_single_sheet:
        sheets = get_bulk_app_single_sheet_by_name(app, lang, skip_blacklisted)
    else:
        sheets = get_bulk_app_sheets_by_name(
            app, eligible_for_transifex_only=skip_blacklisted)

    temp = io.BytesIO()
    data = [(k, v) for k, v in sheets.items()]
    export_raw(headers, data, temp)
    filename = '{app_name} v.{app_version} - App Translations{lang}{transifex_only}'.format(
        app_name=app.name,
        app_version=app.version,
        lang=' ' + lang if is_single_sheet else '',
        transifex_only=' (Transifex only)' if skip_blacklisted else '',
    )
    return export_response(temp, Format.XLS_2007, filename)
Exemple #2
0
 def _generate_expected_headers_and_rows(self):
     self.headers = {
         h[0]: h[1]
         for h in get_bulk_app_sheet_headers(self.app)
     }
     self.expected_rows = get_bulk_app_sheets_by_name(
         self.app,
         exclude_module=lambda module: SKIP_TRANSFEX_STRING in module.
         comment,
         exclude_form=lambda form: SKIP_TRANSFEX_STRING in form.comment)
Exemple #3
0
def download_bulk_app_translations(request, domain, app_id):
    lang = request.GET.get('lang')
    app = get_app(domain, app_id)
    headers = get_bulk_app_sheet_headers(app, lang=lang)
    sheets = get_bulk_app_single_sheet_by_name(app, lang) if lang else get_bulk_app_sheets_by_name(app)

    temp = io.BytesIO()
    data = [(k, v) for k, v in six.iteritems(sheets)]
    export_raw(headers, data, temp)
    filename = '{app_name} v.{app_version} - App Translations{lang}'.format(
        app_name=app.name,
        app_version=app.version,
        lang=' ' + lang if lang else '')
    return export_response(temp, Format.XLS_2007, filename)
Exemple #4
0
    def _translation_data(self):
        # get the translations data
        from corehq.apps.translations.app_translations.download import get_bulk_app_sheets_by_name
        # simply the rows of data per sheet name
        rows = get_bulk_app_sheets_by_name(self.app, eligible_for_transifex_only=True)

        # get the translation data headers
        from corehq.apps.translations.app_translations.utils import get_bulk_app_sheet_headers
        headers = get_bulk_app_sheet_headers(
            self.app,
            eligible_for_transifex_only=True,
        )
        for header_row in headers:
            self.headers[header_row[0]] = header_row[1]
        self._set_sheet_name_to_module_or_form_mapping(rows[MODULES_AND_FORMS_SHEET_NAME])
        return rows
Exemple #5
0
 def _generate_current_headers_and_rows(self):
     self.current_headers = {
         mod_or_form_id: headers
         for mod_or_form_id, headers in get_bulk_app_sheet_headers(
             self.app,
             lang=self.lang_to_compare,
             eligible_for_transifex_only=True,
             single_sheet=self.single_sheet,
         )
     }
     if self.single_sheet:
         self.current_rows = get_bulk_app_single_sheet_by_name(
             self.app,
             self.lang_to_compare,
             eligible_for_transifex_only=True)
     else:
         self.current_rows = get_bulk_app_sheets_by_name(
             self.app, eligible_for_transifex_only=True)
         self._set_current_sheet_name_to_module_or_form_mapping()
         self._map_ids_to_headers()
         self._map_ids_to_translations()
Exemple #6
0
    def _translation_data(self, app):
        # get the translations data
        from corehq.apps.translations.app_translations.download import get_bulk_app_sheets_by_name
        # simply the rows of data per sheet name
        rows = get_bulk_app_sheets_by_name(
            app,
            exclude_module=lambda module: SKIP_TRANSFEX_STRING in module.
            comment,
            exclude_form=lambda form: SKIP_TRANSFEX_STRING in form.comment)

        # get the translation data headers
        from corehq.apps.translations.app_translations.utils import get_bulk_app_sheet_headers
        headers = get_bulk_app_sheet_headers(
            app,
            exclude_module=lambda module: SKIP_TRANSFEX_STRING in module.
            comment,
            exclude_form=lambda form: SKIP_TRANSFEX_STRING in form.comment)
        for header_row in headers:
            self.headers[header_row[0]] = header_row[1]
        self._set_sheet_name_to_module_or_form_mapping(
            rows[MODULES_AND_FORMS_SHEET_NAME])
        return rows