Files
superset2/tests/unit_tests/scripts/translations/__init__.py
Superset Dev 795d6e67df test(i18n): cover backfill_po + address review feedback
Addresses sadpandajoe's review on #39448:

1. Adds tests/unit_tests/scripts/translations/backfill_po_test.py with
   19 cases covering parse_response (singular/plural/markdown-fence
   stripping/non-ASCII/non-numeric keys/list-and-scalar rejection/JSON
   errors) and _apply_translation (singular path, plural-dict path,
   plural-scalar fallback, plural invalid-JSON fallback, fuzzy flag,
   attribution append/dedup, end-to-end round-trip from parse_response
   into _apply_translation). The script is loaded via importlib since
   it lives outside the package tree.

2. translate_batch now pipes the prompt over stdin instead of passing
   it as argv. With --batch-size 50 and many reference languages a
   single batch can grow into the tens of KB and approach ARG_MAX on
   some platforms; stdin removes that ceiling.

3. _process_batches now saves the catalog after each batch that wrote
   at least one translation (when not in --dry-run). For sparse
   languages with thousands of missing strings, a crash mid-run now
   only loses the in-flight batch rather than every batch translated
   so far. The full save at end of backfill() is removed since the
   per-batch save covers it.

4. Module docstring referenced --fuzzy/--no-fuzzy but argparse only
   registers --no-fuzzy; doc updated to match the actual flag.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-11 16:59:40 -07:00

17 lines
785 B
Python

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.