검사 및 수정

사용자 정의 자동 수정

표준 수정 외에 자체 자동 수정을 구현하여 AUTOFIX_LIST 에 포함할 수 있습니다.

자동 수정은 강력하지만 손상을 일으킬 수도 있으므로 작성 시 주의하세요.

예를 들어, 다음 자동 수정은 번역에서 foo 문자열의 모든 항목을 bar 로 변경함:

from __future__ import annotations

from typing import TYPE_CHECKING

from weblate.trans.autofixes.base import AutoFix

if TYPE_CHECKING:
    from weblate.trans.models import Unit


class ReplaceFooWithBar(AutoFix):
    """Replace foo with bar."""

    # Might be localized using gettext_lazy
    name = "Foobar"

    def fix_single_target(
        self, target: str, source: str, unit: Unit
    ) -> tuple[str, bool]:
        if "foo" in target:
            return target.replace("foo", "bar"), True
        return target, False

사용자 정의 검사를 설치하려면 AUTOFIX_LIST 에 Python 클래스의 전체 경로를 제공하세요 ( Custom quality checks, add-ons, translation services and auto-fixes 참조).

플래그를 사용한 동작 사용자 지정

플래그를 사용하여 Weblate의 동작을 미세 조정할 수 있습니다. 플래그는 번역자에게 시각적 피드백을 제공하고 번역을 개선하는 데 도움을 줍니다. 플래그는 다음 소스에서 병합됨:

플래그는 쉼표로 구분되며, 매개변수가 있는 경우 콜론으로 구분됩니다. 따옴표를 사용하여 문자열에 공백이나 특수 문자를 포함할 수 있습니다. 예:

placeholders:"special:value":"other value", regex:.*

작은따옴표와 큰따옴표 모두 허용되며, 특수 문자는 백슬래시로 이스케이프됨:

placeholders:"quoted \"string\"":'single \'quoted\''
placeholders:r"^#*"

번역자가 Markdown 문서의 제목을 변경하지 않도록 확인합니다. ### Index 문자열이 # Indice 로 번역되면 검사가 실패합니다.

placeholders:r"\]\([^h].*?\)"

내부 링크가 번역되지 않도록 확인합니다 (예: [test](../checks) 가 [test](../chequeos) 가 되지 않도록).

The flags defined on a higher level can be discarded using the discard:NAME syntax. For example, if a component is configured to safe-html, you can add discard:safe-html to the string flags to skip it for this particular string. Translation flags cannot discard an explicit read-only flag set on the source string.

현재 허용되는 플래그 목록:

read-only

문자열은 읽기 전용이며 Weblate에서 편집해서는 안 됩니다. 읽기 전용 문자열 를 참조하세요.

terminology

용어집 에서 사용됩니다. 문자열을 모든 용어집 언어로 복사하여 모든 번역에서 일관되게 사용할 수 있습니다. read-only 와 함께 사용하면 제품 이름 등에 유용합니다.

priority:N

문자열의 우선순위입니다. 우선순위가 높은 문자열이 먼저 번역을 위해 제시됩니다. 기본 우선순위는 100이며, 우선순위가 높을수록 먼저 번역이 제공됩니다.

xml-text

텍스트를 XML 문서로 처리합니다. XML 구문 및 XML 마크업 에 영향을 줍니다.

font-family:NAME

렌더링 검사를 위한 글꼴 패밀리를 정의합니다. 글꼴 관리 를 참조하세요.

font-weight:WEIGHT

렌더링 검사를 위한 글꼴 두께를 정의합니다. 글꼴 관리 를 참조하세요.

font-size:SIZE

렌더링 검사를 위한 글꼴 크기를 정의합니다. 글꼴 관리 를 참조하세요.

font-spacing:SPACING

렌더링 검사를 위한 자간을 정의합니다. 글꼴 관리 를 참조하세요.

font-monospace

Display the string in the translation editor using a monospace font. Unlike the font-family/font-size/font-weight/font-spacing flags, this does not affect rendering checks and never loads an uploaded font; it only switches the editor to the browser’s built-in monospace font stack.

icu-flags:FLAGS

ICU MessageFormat 품질 검사의 동작을 사용자 정의하기 위한 플래그를 정의합니다.

icu-tag-prefix:PREFIX

ICU MessageFormat 품질 검사에 필요한 XML 태그 접두사를 설정합니다.

placeholders:NAME:NAME2:...

번역에서 예상되는 자리 표시자 문자열입니다. 자리 표시자 를 참조하세요.

replacements:FROM:TO:FROM2:TO2...

결과 텍스트 매개변수를 확인할 때 수행할 치환입니다(예: 번역 최대 크기 또는 번역 최대 길이). 일반적인 사용 사례는 배치 가능 항목을 확장하여 긴 값에서도 텍스트가 맞도록 하는 것입니다. 예: replacements:%s:"John Doe".

variants:SOURCE

이 문자열을 원문이 일치하는 문자열의 변형으로 표시합니다. 문자열 변형 를 참조하세요.

regex:REGEX

번역과 일치하는 정규 표현식입니다. 정규 표현식 를 참조하세요.

discard:NAME

상위 수준에서 정의된 플래그를 무시합니다.

forbidden

용어집에서 금지된 번역을 나타냅니다. 금지된 번역 를 참조하세요.

strict-same

변경되지 않은 번역 이 내장 단어 예외를 사용하지 않도록 합니다.

strict-format

형식 검사가 단일 값의 복수형에서도 형식 사용을 강제하도록 합니다. 형식 문자열 를 참조하세요.

case-insensitive

검사 동작을 대소문자 구분 없이 조정합니다. 현재 자리 표시자 품질 검사에만 영향을 줍니다.

accelerator

Specify the single punctuation accelerator marker, for example accelerator:&, accelerator:_, or accelerator:~. Enables the Accelerator key quality check.

asciidoc-text

Treat a text as an AsciiDoc document, affects 변경되지 않은 번역. Enables the AsciiDoc markup quality check.

bbcode-text

텍스트를 BBCode(게시판 코드) 문서로 처리합니다. 변경되지 않은 번역 에 영향을 줍니다. BBCode 마크업 품질 검사를 활성화합니다.

check-glossary

용어집 미준수 품질 검사를 활성화합니다.

fluent-parts

Fluent 파츠 품질 검사를 활성화합니다.

fluent-references

Fluent 참조 품질 검사를 활성화합니다.

fluent-target-inner-html

Fluent 번역 내부 HTML 품질 검사를 활성화합니다.

fluent-target-syntax

Fluent 번역 구문 품질 검사를 활성화합니다.

angularjs-format

AngularJS 보간 문자열 품질 검사를 활성화합니다.

automattic-components-format

Automattic 구성요소 형식 품질 검사를 활성화합니다.

c-format

C 형식 품질 검사를 활성화합니다.

c-sharp-format

C# 형식 품질 검사를 활성화합니다.

csharp-format

C# 형식 품질 검사를 활성화합니다.

es-format

ECMAScript 템플릿 리터럴 품질 검사를 활성화합니다.

i18next-interpolation

i18next 인터폴레이션 품질 검사를 활성화합니다.

icu-message-format

ICU MessageFormat 및 ICU MessageFormat 구문 품질 검사를 활성화합니다.

java-printf-format

Java 형식 품질 검사를 활성화합니다.

java-format

Java MessageFormat 품질 검사를 활성화합니다.

auto-java-messageformat

텍스트를 조건부 Java MessageFormat으로 처리하며, 원문에 Java MessageFormat 자리표시자가 포함된 경우에만 Java MessageFormat 을 활성화합니다. Java MessageFormat 품질 검사를 활성화합니다.

javascript-format

JavaScript 형식 품질 검사를 활성화합니다.

laravel-format

Laravel 형식 품질 검사를 활성화합니다.

lua-format

Lua 형식 품질 검사를 활성화합니다.

object-pascal-format

Object Pascal 형식 품질 검사를 활성화합니다.

objc-format

Objective-C 형식 품질 검사를 활성화합니다.

percent-placeholders

퍼센트 자리 표시자 품질 검사를 활성화합니다.

perl-brace-format

Perl 중괄호 형식 품질 검사를 활성화합니다.

perl-format

Perl 형식 품질 검사를 활성화합니다.

php-format

PHP 형식 품질 검사를 활성화합니다.

python-brace-format

Python 중괄호 형식 품질 검사를 활성화합니다.

python-format

Python 형식 품질 검사를 활성화합니다.

qt-format

Qt 형식 품질 검사를 활성화합니다.

qt-plural-format

Qt 복수형 품질 검사를 활성화합니다.

ruby-format

Ruby 형식 품질 검사를 활성화합니다.

scheme-format

Scheme 형식 품질 검사를 활성화합니다.

vue-format

Vue I18n 형식 품질 검사를 활성화합니다.

rst-text

텍스트를 reStructuredText 문서로 처리합니다. 변경되지 않은 번역 에 영향을 줍니다. 일관성 없는 reStructuredText 및 reStructuredText 구문 오류 품질 검사를 활성화합니다.

md-text

텍스트를 Markdown 문서로 처리하고 번역 텍스트 영역에서 Markdown 구문 강조를 제공합니다. 마크다운 링크, 마크다운 참조 및 마크다운 구문 품질 검사를 활성화합니다.

max-length

번역 최대 길이 품질 검사를 활성화합니다.

max-lines

Enables the Maximum number of lines quality check.

max-size

번역 최대 크기 품질 검사를 활성화합니다.

placeholders

자리 표시자 품질 검사를 활성화합니다.

regex

정규 표현식 품질 검사를 활성화합니다.

safe-mdx

Enables the Safe MDX quality check.

safe-html

안전하지 않은 HTML 품질 검사를 활성화합니다.

auto-safe-html

텍스트를 조건부 HTML로 처리하며, 일반 텍스트 또는 표준 HTML 마크업이나 유효한 사용자 정의 요소가 포함된 원문 문자열에 대해서만 안전하지 않은 HTML 을 활성화합니다. 이는 꺾쇠괄호 구문이 HTML이 아닐 수 있는 MDX와 같은 확장 Markdown 변형에 유용합니다. 안전하지 않은 HTML 품질 검사를 활성화합니다.

url

문자열은 URL만으로 구성되어야 합니다. URL 품질 검사를 활성화합니다.

fluent-source-inner-html

Fluent 원문 내부 HTML 품질 검사를 활성화합니다.

fluent-source-syntax

Fluent 원문 구문 품질 검사를 활성화합니다.

ignore-all-checks

모든 품질 검사를 무시합니다.

ignore-accelerator

Skip the Accelerator key quality check.

ignore-ai-accuracy

Skip the AI: Accuracy quality check.

ignore-ai-fluency

Skip the AI: Fluency quality check.

ignore-ai-formatting

Skip the AI: Formatting quality check.

ignore-ai-style

Skip the AI: Style quality check.

ignore-ai-terminology

Skip the AI: Terminology quality check.

ignore-asciidoc-markup

Skip the AsciiDoc markup quality check.

ignore-bbcode

BBCode 마크업 품질 검사를 건너뜁니다.

ignore-xml-chars-around-tags

XML 태그 주변 문자 품질 검사를 건너뜁니다.

ignore-duplicate

연속 중복 단어 품질 검사를 건너뜁니다.

ignore-check-glossary

용어집 미준수 품질 검사를 건너뜁니다.

ignore-double-space

이중 공백 품질 검사를 건너뜁니다.

ignore-fluent-parts

Fluent 파츠 품질 검사를 건너뜁니다.

ignore-fluent-references

Fluent 참조 품질 검사를 건너뜁니다.

ignore-fluent-target-inner-html

Fluent 번역 내부 HTML 품질 검사를 건너뜁니다.

ignore-fluent-target-syntax

Fluent 번역 구문 품질 검사를 건너뜁니다.

ignore-angularjs-format

AngularJS 보간 문자열 품질 검사를 건너뜁니다.

ignore-automattic-components-format

Automattic 구성요소 형식 품질 검사를 건너뜁니다.

ignore-c-format

C 형식 품질 검사를 건너뜁니다.

ignore-c-sharp-format

C# 형식 품질 검사를 건너뜁니다.

ignore-es-format

ECMAScript 템플릿 리터럴 품질 검사를 건너뜁니다.

ignore-i18next-interpolation

i18next 인터폴레이션 품질 검사를 건너뜁니다.

ignore-icu-message-format

ICU MessageFormat 품질 검사를 건너뜁니다.

ignore-java-printf-format

Java 형식 품질 검사를 건너뜁니다.

ignore-java-format

Java MessageFormat 품질 검사를 건너뜁니다.

ignore-javascript-format

JavaScript 형식 품질 검사를 건너뜁니다.

ignore-laravel-format

Laravel 형식 품질 검사를 건너뜁니다.

ignore-lua-format

Lua 형식 품질 검사를 건너뜁니다.

ignore-object-pascal-format

Object Pascal 형식 품질 검사를 건너뜁니다.

ignore-objc-format

Objective-C 형식 품질 검사를 건너뜁니다.

ignore-percent-placeholders

퍼센트 자리 표시자 품질 검사를 건너뜁니다.

ignore-perl-brace-format

Perl 중괄호 형식 품질 검사를 건너뜁니다.

ignore-perl-format

Perl 형식 품질 검사를 건너뜁니다.

ignore-php-format

PHP 형식 품질 검사를 건너뜁니다.

ignore-python-brace-format

Python 중괄호 형식 품질 검사를 건너뜁니다.

ignore-python-format

Python 형식 품질 검사를 건너뜁니다.

ignore-qt-format

Qt 형식 품질 검사를 건너뜁니다.

ignore-qt-plural-format

Qt 복수형 품질 검사를 건너뜁니다.

ignore-ruby-format

Ruby 형식 품질 검사를 건너뜁니다.

ignore-scheme-format

Scheme 형식 품질 검사를 건너뜁니다.

ignore-vue-format

Vue I18n 형식 품질 검사를 건너뜁니다.

ignore-translated

번역 완료됨 품질 검사를 건너뜁니다.

ignore-inconsistent

일관성 없음 품질 검사를 건너뜁니다.

ignore-rst-references

일관성 없는 reStructuredText 품질 검사를 건너뜁니다.

ignore-kashida

카시다 문자 사용됨 품질 검사를 건너뜁니다.

ignore-md-link

마크다운 링크 품질 검사를 건너뜁니다.

ignore-md-reflink

마크다운 참조 품질 검사를 건너뜁니다.

ignore-md-syntax

마크다운 구문 품질 검사를 건너뜁니다.

ignore-max-length

번역 최대 길이 품질 검사를 건너뜁니다.

ignore-max-lines

Skip the Maximum number of lines quality check.

ignore-max-size

번역 최대 크기 품질 검사를 건너뜁니다.

ignore-escaped-newline

\n 불일치 품질 검사를 건너뜁니다.

ignore-end-colon

콜론 불일치 품질 검사를 건너뜁니다.

ignore-end-ellipsis

줄임표 불일치 품질 검사를 건너뜁니다.

ignore-end-exclamation

느낌표 불일치 품질 검사를 건너뜁니다.

ignore-end-stop

마침표 불일치 품질 검사를 건너뜁니다.

ignore-end-interrobang

인터로뱅 불일치 품질 검사를 건너뜁니다.

ignore-end-question

물음표 불일치 품질 검사를 건너뜁니다.

ignore-end-semicolon

세미콜론 불일치 품질 검사를 건너뜁니다.

ignore-newline-count

줄바꿈 불일치 품질 검사를 건너뜁니다.

ignore-plurals

복수형 누락 품질 검사를 건너뜁니다.

ignore-multiple-capital

연속 대문자 품질 검사를 건너뜁니다.

ignore-kabyle-characters

카빌어 비표준 문자 품질 검사를 건너뜁니다.

ignore-placeholders

자리 표시자 품질 검사를 건너뜁니다.

ignore-prohibited-initial-character

금지된 첫 문자 품질 검사를 건너뜁니다.

ignore-punctuation-spacing

구두점 간격 품질 검사를 건너뜁니다.

ignore-regex

정규 표현식 품질 검사를 건너뜁니다.

ignore-rst-syntax

reStructuredText 구문 오류 품질 검사를 건너뜁니다.

ignore-reused

재사용된 번역 품질 검사를 건너뜁니다.

ignore-safe-mdx

Skip the Safe MDX quality check.

ignore-same-plurals

동일 복수형 품질 검사를 건너뜁니다.

ignore-begin-newline

시작 줄바꿈 품질 검사를 건너뜁니다.

ignore-begin-space

시작 공백 품질 검사를 건너뜁니다.

ignore-end-newline

末尾 줄바꿈 품질 검사를 건너뜁니다.

ignore-end-space

후행 공백 품질 검사를 건너뜁니다.

ignore-same

변경되지 않은 번역 품질 검사를 건너뜁니다.

ignore-safe-html

안전하지 않은 HTML 품질 검사를 건너뜁니다.

ignore-url

URL 품질 검사를 건너뜁니다.

ignore-xml-tags

XML 마크업 품질 검사를 건너뜁니다.

ignore-xml-invalid

XML 구문 품질 검사를 건너뜁니다.

ignore-zero-width-space

폭 없는 공백 품질 검사를 건너뜁니다.

ignore-ellipsis

줄임표 품질 검사를 건너뜁니다.

ignore-fluent-source-inner-html

Fluent 원문 내부 HTML 품질 검사를 건너뜁니다.

ignore-fluent-source-syntax

Fluent 원문 구문 품질 검사를 건너뜁니다.

ignore-icu-message-format

ICU MessageFormat 구문 품질 검사를 건너뜁니다.

ignore-long-untranslated

장기 미번역 품질 검사를 건너뜁니다.

ignore-multiple-failures

복수 검사 실패 품질 검사를 건너뜁니다.

ignore-unnamed-format

명명되지 않은 복수 변수 품질 검사를 건너뜁니다.

ignore-source-max-length

Skip the 원문 문자열 길이 quality check.

ignore-optional-plural

복수형 미사용 품질 검사를 건너뜁니다.

참고

일반적으로 규칙은 식별자를 사용하여 ignore-* 로 명명되므로 사용자 정의 검사에도 사용할 수 있습니다.

이 플래그는 구성요소 설정 설정, 원문 문자열별 설정, 번역 파일 자체 (예: GNU gettext)에서 모두 인식됩니다.

위치 기반 플래그

일부 플래그는 위치에 따라 기본적으로 문자열에 추가됩니다. 이는 문자열이 사용되는 위치에 따라 특정 검사가 자동으로 활성화됨을 의미합니다.

  • rst-text: 위치 확장자가 .rst 인 경우, reStructuredText 파일의 문자열에 자동으로 추가되는 플래그입니다.

  • md-text: 파일 확장자가 .md, .markdown 또는 .mdx 인 경우, 이 플래그가 마크다운 및 MDX 파일 내의 문자열에 자동으로 추가됩니다.

검사 강제

강제 검사는 해제할 수 없으며 문자열을 편집 필요 로 표시합니다 ( 번역 상태 참조). 이를 통해 번역자가 해당 검사를 숨기는 것을 방지합니다.

힌트

검사 강제를 켜도 자동으로 활성화되지 않습니다. 일부 검사는 문자열 또는 구성요소 플래그에 해당 플래그를 추가하여 활성화해야 합니다.

이는 형식 문자열 와 같이 사용 시 심각한 문제를 일으킬 수 있는 검사에 가장 적합합니다. 변경되지 않은 번역 과 같은 스타일 검사에는 권장되지 않습니다. 해제가 때떄로 합리적인 접근 방식이기 때문입니다.

그런 다음 번역 품질 필터 를 사용하여 편집이 필요한 문자열이 버전 관리에 커밋되지 않도록 제외할 수 있습니다.

글꼴 관리

힌트

Weblate에 업로드된 글꼴은 번역 최대 크기 검사 목적으로만 사용되며 Weblate 사용자 인터페이스에는 영향을 미치지 않습니다.

렌더링된 텍스트의 치수를 계산하는 데 사용되는 번역 최대 크기 검사는 글꼴이 Weblate에 로드되어 번역 플래그로 선택되어야 합니다 ( 플래그를 사용한 동작 사용자 지정 참조).

번역 프로젝트의 작업 메뉴 아래 글꼴 에 있는 Weblate 글꼴 관리 도구는 글꼴을 업로드하고 관리하는 인터페이스를 제공합니다. TrueType 또는 OpenType 글꼴을 업로드하고, 글꼴 그룹을 설정하여 검사에서 사용할 수 있습니다.

Uploads must contain a single TrueType or OpenType font with a .ttf or .otf extension. WOFF, WOFF2, font collections, and legacy font formats are not supported, even when renamed to use one of these extensions.

글꼴 그룹을 사용하면 비라틴 언어에 일반적으로 필요한, 언어별로 다른 글꼴을 정의할 수 있음:

../_images/font-group-edit.webp

글꼴 그룹은 이름으로 식별되며, 공백이나 특수 문자를 포함할 수 없어 검사 정의에서 쉽게 사용할 수 있음:

../_images/font-group-list.webp

글꼴 계열과 스타일은 업로드 후 자동으로 인식됩니다:

../_images/font-edit.webp

Weblate에 여러 글꼴을 로드할 수 있음:

../_images/font-list.webp

글꼴을 문자열 길이 검사에 사용하려면 적절한 플래그를 전달하세요 ( 플래그를 사용한 동작 사용자 지정 참조). 다음 플래그가 필요할 수 있음:

max-size:500 / max-size:300:5

Defines maximal width in pixels and, optionally, the maximum number of lines. Word wrapping is applied when more than one line is configured.

font-family:ubuntu

식별자를 지정하여 사용할 글꼴 그룹을 정의합니다.

font-size:22

글꼴 크기(픽셀)를 정의합니다.

자체 검사 작성

다양한 품질 검사가 내장되어 있습니다 ( 품질 검사 참조). 하지만 확인하려는 모든 항목을 다루지는 않을 수 있습니다. 수행되는 검사 목록은 CHECK_LIST 를 사용하여 조정할 수 있으며, 사용자 정의 검사를 추가할 수도 있습니다.

  1. weblate.checks.Check 의 하위 클래스를 만듭니다

  2. 몇 가지 속성을 설정합니다.

  3. check (코드에서 복수형을 처리하려는 경우) 또는 check_single 메서드 (복수형을 자동으로 처리)를 구현합니다.

일부 예시:

사용자 정의 검사를 설치하려면 CHECK_LIST 에 Python 클래스의 전체 경로를 제공하세요 ( Custom quality checks, add-ons, translation services and auto-fixes 참조).

Checks declaring propagates = "source" or propagates = "target" update related strings in the background after a save. They can override evaluate_propagated(units) to evaluate a matching group in bulk. Yield a (unit, failed) pair for every string, including passing strings so stale warnings can be removed. Without this override, Weblate evaluates the check on each matching string in chunks.

번역 텍스트에 “foo”가 포함되지 않았는지 확인

이것은 번역에 “foo” 문자열이 누락되었는지 확인하는 매우 간단한 검사입니다.

"""Simple quality check example."""

from __future__ import annotations

from typing import TYPE_CHECKING

from django.utils.translation import gettext_lazy

from weblate.checks.base import TargetCheck

if TYPE_CHECKING:
    from weblate.trans.models import Unit


class FooCheck(TargetCheck):
    # Used as identifier for check, should be unique
    # Has to be shorter than 50 characters
    check_id = "foo"

    # Short name used to display failing check
    # Might be localized using gettext_lazy
    name = "Foo check"

    # Description for failing check
    description = gettext_lazy("Your translation is foo")

    # Real check code
    def check_single(self, source: str, target: str, unit: Unit) -> bool:
        return "foo" in target

체코어 번역 텍스트의 복수형이 서로 다른지 확인

언어 정보를 사용하여 체코어의 두 복수형이 동일하지 않은지 확인합니다.

"""Quality check example for Czech plurals."""

from __future__ import annotations

from django.utils.translation import gettext_lazy

from weblate.checks.base import TargetCheck


class PluralCzechCheck(TargetCheck):
    # Used as identifier for check, should be unique
    # Has to be shorter than 50 characters
    check_id = "foo"

    # Short name used to display failing check
    # Might be localized using gettext_lazy
    name = "Foo check"

    # Description for failing check
    description = gettext_lazy("Your translation is foo")

    # Real check code
    def check_target_unit(self, sources, targets, unit) -> bool:
        if unit.translation.language.is_base({"cs"}):
            return targets[1] == targets[2]
        return False

    def check_single(self, source, target, unit) -> bool:
        """We don't check target strings here."""
        return False