返回提示词目录第 1459 页

转换多语言文件格式并校验占位符

将翻译目录在不同格式间转换,保留复数、上下文和状态等元数据,并输出损失报告与往返检查结果。

完整提示词

<context>
Formats look interchangeable until plurals and placeholders meet. gettext stores plurals as `msgstr[0..n]` driven by a `Plural-Forms` header, i18next v4 uses `_one`/`_few`/`_other` key suffixes, Android uses `<plurals>` with CLDR quantities, ARB and xcstrings carry ICU or their own variation blocks, and XLIFF holds plurals however the tool that wrote it chose. Placeholders differ too: `%s` and `%d` are positional and break when a translation reorders them, `%1$s` is not, and a double-brace placeholder in one library is literal text in another. Converters that move only key and text drop translator comments, fuzzy or review status, max-length notes and context (`msgctxt`), and silently merge two entries that only differed by context.
</context>

<task>
Convert this catalog to {{target_format}}:

{{source_files}}

{{#placeholder_style}}Target placeholder syntax: {{placeholder_style}}.{{/placeholder_style}}

1. Identify the source format and version, locale, plural model, placeholder syntax, escaping rules, and which metadata it carries (comments, context, status, max length, source references).
2. Write a field mapping from source to target, including where each kind of metadata goes in the target or that it has no home there.
3. Convert keys. When the source keys are the English text (gettext `msgid`), choose: keep text as keys, or generate stable keys and record the mapping. Keep `msgctxt` or equivalent context as part of the key or as a separate field so entries never merge.
4. Convert placeholders: map every placeholder to the target syntax, turn positional `%s` into numbered or named arguments when the target allows reordering, and keep the same set of placeholders in every string.
5. Convert plurals to the target's model using the locale's CLDR categories. When going from gettext indexes to named categories, derive the mapping from the `Plural-Forms` expression and say which index became which category.
6. Escape for the target: XML entities and apostrophes for Android, apostrophe rules for ICU, quotes and backslashes for JSON and `.strings`.
7. Produce the converted files and a round-trip check: the count of entries, plurals and placeholders before and after.
</task>

<constraints>
- Never translate, correct or reword string text during conversion.
- Never drop an entry; if something cannot be represented, keep it with a comment and list it in the loss report.
- Do not guess a gettext plural mapping without the `Plural-Forms` header; ask for it or name the locale's standard header and mark it as assumed.
- Keep fuzzy, needs-review or untranslated status as status, not as translated text.
{{> output/uncertainty}}
</constraints>

<output_format>
## Mapping
| Source construct | Target construct | Notes |

## Converted files
One code block per output file.

## Loss report
Metadata or constructs with no equivalent in the target, entry by entry.

## Checks
Entry, plural and placeholder counts before and after, and anything to verify with the target tool's own validator.
</output_format>

可替换内容

  • {{target_format}}
  • {{source_files}}
  • {{#placeholder_style}}
  • {{placeholder_style}}
  • {{/placeholder_style}}
  • {{> output/uncertainty}}
  • [0..n]

分类与标签

编程开发、国际化开发、翻译文件、占位符校验、格式转换

前往 AI 图片创作