Kontrole i korekty¶
Niestandardowe automatyczne korekty¶
You can also implement your own automatic fixup in addition to the standard ones and
include them in AUTOFIX_LIST.
The automatic fixes are powerful, but can also cause damage; be careful when writing one.
For example, the following automatic fixup would replace every occurrence of the string
foo in a translation with bar:
from django.utils.translation import gettext_lazy
from weblate.trans.autofixes.base import AutoFix
class ReplaceFooWithBar(AutoFix):
"""Replace foo with bar."""
name = gettext_lazy("Foobar")
def fix_single_target(self, target, source, unit):
if "foo" in target:
return target.replace("foo", "bar"), True
return target, False
To install custom checks, provide a fully-qualified path to the Python class
in the AUTOFIX_LIST, see Custom quality checks, add-ons, automatic suggestions and auto-fixes.
Dostosowywanie zachowania za pomocą flag¶
You can fine-tune Weblate’s behavior by using flags. The flags provide visual feedback to the translators and help them to improve their translation. The flags are merged from following sources:
Source string additional flags:
Dodatkowe informacje o ciągach źródłowych describes manual editing.
Edycja zbiorcza can be used to apply flags in batch.
Edycja zbiorcza add-on can apply flags automatically.
Per-string flags extracted from the file format, see Localization file formats.
Translation flags (currently only
read-onlyflag for bilingual source string).File-format specific flags.
The flags are comma-separated; if they have parameters, they are separated with colon. You can use quotes to include whitespaces or special characters in the string. For example:
placeholders:"special:value":"other value", regex:.*
Both single and double quotes are accepted, special characters are being escaped using backslash:
placeholders:"quoted \"string\"":'single \'quoted\''
placeholders:r"^#*"
To verify that translators do not change the heading of a Markdown document.
A failing check will be triggered if the string ### Index is translated as # Indice.
placeholders:r"\]\([^h].*?\)"
To ensure that internal links are not being translated (i.e. [test](../checks) does not become [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.
Here is a list of flags currently accepted:
rst-textTreat a text as an reStructuredText document, affects Niezmienione tłumaczenie. Turns on Błąd składniowy reStructuredText and Niespójny reStructuredText.
bbcode-textTreat a text as an Bulletin Board Code (BBCode) document, affects Niezmienione tłumaczenie.
dos-eolUses DOS end-of-line markers instead of Unix ones (
\r\ninstead of\n).read-onlyThe string is read-only and should not be edited in Weblate, see Ciągi tylko do odczytu.
terminologyUsed in Słownik. Copies the string into all glossary languages so it can be used consistently in all translations. Also useful in combination with
read-only, for example in product names.priority:NPriority of the string. Higher priority strings are presented first for translation. The default priority is 100, the higher priority a string has, the earlier it is offered for translation.
max-length:NLimit the maximal length for a string to N characters, see Maksymalna długość tłumaczenia.
xml-textTreat text as XML document, affects Składnia XML and Znaczniki XML.
font-family:NAMEDefine font-family for rendering checks, see Zarządzanie czcionkami.
font-weight:WEIGHTDefine font-weight for rendering checks, see Zarządzanie czcionkami.
font-size:SIZEDefine font-size for rendering checks, see Zarządzanie czcionkami.
font-spacing:SPACINGDefine letter spacing for rendering checks, see Zarządzanie czcionkami.
icu-flags:FLAGSZdefiniuj flagi do dostosowywania zachowania kontroli jakości ICU MessageFormat.
icu-tag-prefix:PREFIXUstaw wymagany prefiks dla tagów XML dla kontroli jakości ICU MessageFormat.
placeholders:NAME:NAME2:...Placeholder strings expected in translation, see Symbole zastępcze.
replacements:FROM:TO:FROM2:TO2...Replacements to perform when checking resulting text parameters (for example in Maksymalny rozmiar tłumaczenia or Maksymalna długość tłumaczenia). The typical use case for this is to expand placeables to ensure that the text fits even with long values, for example:
replacements:%s:"John Doe".variants:SOURCEMark this string as a variant of string with matching source. See Warianty ciągów.
regex:REGEXWyrażenie regularne pasujące do tłumaczenia, zobacz Wyrażenie regularne.
discard:NAMEDiscards flag defined on a higher level.
forbiddenIndicates forbidden translation in a glossary, see Zabronione tłumaczenia.
strict-sameMake the Niezmienione tłumaczenie avoid using the built-in words exceptions.
strict-formatMake format checks enforce using format even for plural forms with a single value, see Formatowanie ciągów.
check-glossaryWłącz kontrolę jakości Nie jest zgodny z słownikiem.
angularjs-formatWłącz kontrolę jakości Ciąg znaków interpolacji AngularJS.
c-formatWłącz kontrolę jakości Format C.
c-sharp-formatWłącz kontrolę jakości Format C#.
es-formatWłącz kontrolę jakości Literały szablonu ECMAScript.
i18next-interpolationEnable the interpolacja i18next quality check.
icu-message-formatWłącz kontrolę jakości ICU MessageFormat.
java-printf-formatEnable the Format Java quality check.
java-formatWłącz kontrolę jakości Format Java Message.
javascript-formatWłącz kontrolę jakości Format JavaScript.
lua-formatWłącz kontrolę jakości Format Lua.
object-pascal-formatWłącz kontrolę jakości Format Object Pascal.
percent-placeholdersWłącz kontrolę jakości Procent symboli zastępczych.
perl-brace-formatEnable the Format nawiasów klamrowych Perla quality check.
perl-formatWłącz kontrolę jakości Format języka Perl.
php-formatWłącz kontrolę jakości Format PHP.
python-brace-formatEnable the Format klamrowy Python quality check.
python-formatEnable the Format Python quality check.
qt-formatWłącz kontrolę jakości Format Qt.
qt-plural-formatWłącz kontrolę jakości Forma liczby mnogiej Qt.
ruby-formatWłącz kontrolę jakości Format Ruby.
scheme-formatWłącz kontrolę jakości Format Scheme.
vue-formatWłącz kontrolę jakości Formatowanie Vue I18n.
md-textTreat text as a Markdown document, and provide Markdown syntax highlighting on the translation text area. Enables Łącza Markdown, Odniesienia do Markdown, and Składnia Markdown quality checks.
case-insensitiveAdjust checks behavior to be case-insensitive. Currently affects only Symbole zastępcze quality check.
safe-htmlWłącz kontrolę jakości Niebezpieczny HTML.
urlThe string should consist of only a URL. Enable the URL quality check.
ignore-all-checksIgnoruj wszystkie kontrole jakości.
fluent-source-inner-htmlEnable the Wewnętrzny HTML źródła Fluent quality check.
fluent-source-syntaxEnable the Składnia źródła Fluent quality check.
icu-message-formatEnable the Składnia ICU MessageFormat quality check.
ignore-bbcodePomiń kontrolę jakości Znaczniki BBCode.
ignore-duplicatePomiń kontrolę jakości Kolejne zduplikowane wyrazy.
ignore-check-glossaryPomiń kontrolę jakości Nie jest zgodny z słownikiem.
ignore-double-spacePomiń kontrolę jakości Podwójna spacja.
ignore-fluent-partsSkip the Części Fluent quality check.
ignore-fluent-referencesSkip the Odnośniki Fluent quality check.
ignore-fluent-target-inner-htmlSkip the Wewnętrzny HTML tłumaczenia Fluent quality check.
ignore-fluent-target-syntaxSkip the Składnia tłumaczenia Fluent quality check.
ignore-angularjs-formatPomiń kontrolę jakości Ciąg znaków interpolacji AngularJS.
ignore-automattic-components-formatSkip the Automatyczne formatowanie komponentów quality check.
ignore-c-formatPomiń kontrolę jakości Format C.
ignore-c-sharp-formatPomiń kontrolę jakości Format C#.
ignore-es-formatPomiń kontrolę jakości Literały szablonu ECMAScript.
ignore-i18next-interpolationPomiń kontrolę jakości interpolacja i18next.
ignore-icu-message-formatPomiń kontrolę jakości ICU MessageFormat.
ignore-java-printf-formatSkip the Format Java quality check.
ignore-java-formatPomiń kontrolę jakości Format Java Message.
ignore-javascript-formatPomiń kontrolę jakości Format JavaScript.
ignore-lua-formatPomiń kontrolę jakości Format Lua.
ignore-object-pascal-formatPomiń kontrolę jakości Format Object Pascal.
ignore-percent-placeholdersPomiń kontrolę jakości Procent symboli zastępczych.
ignore-perl-brace-formatSkip the Format nawiasów klamrowych Perla quality check.
ignore-perl-formatPomiń kontrolę jakości Format języka Perl.
ignore-php-formatPomiń kontrolę jakości Format PHP.
ignore-python-brace-formatPomiń kontrolę jakości Format klamrowy Python.
ignore-python-formatPomiń kontrolę jakości Format Python.
ignore-qt-formatPomiń kontrolę jakości Format Qt.
ignore-qt-plural-formatPomiń kontrolę jakości Forma liczby mnogiej Qt.
ignore-ruby-formatPomiń kontrolę jakości Format Ruby.
ignore-scheme-formatPomiń kontrolę jakości Format Scheme.
ignore-vue-formatPomiń kontrolę jakości Formatowanie Vue I18n.
ignore-translatedPomiń kontrolę jakości Zostało przetłumaczone.
ignore-inconsistentPomiń kontrolę jakości Niespójność.
ignore-rst-referencesSkip the Niespójny reStructuredText quality check.
ignore-kashidaPomiń kontrolę jakości Użyto litery Kashida.
ignore-md-linkPomiń kontrolę jakości Łącza Markdown.
ignore-md-reflinkPomiń kontrolę jakości Odniesienia do Markdown.
ignore-md-syntaxPomiń kontrolę jakości Składnia Markdown.
ignore-max-lengthPomiń kontrolę jakości Maksymalna długość tłumaczenia.
ignore-max-sizePomiń kontrolę jakości Maksymalny rozmiar tłumaczenia.
ignore-escaped-newlinePomiń kontrolę jakości Niedopasowane \n.
ignore-end-colonPomiń kontrolę jakości Niedopasowany dwukropek.
ignore-end-ellipsisPomiń kontrolę jakości Niedopasowane wielokropki.
ignore-end-exclamationPomiń kontrolę jakości Niedopasowany wykrzyknik.
ignore-end-stopPomiń kontrolę jakości Niedopasowana kropka.
ignore-end-interrobangSkip the Niedopasowany interrobang quality check.
ignore-end-questionPomiń kontrolę jakości Niedopasowany znak zapytania.
ignore-end-semicolonPomiń kontrolę jakości Niedopasowany średnik.
ignore-newline-countPomiń kontrolę jakości Niedopasowanie podziałów wierszy.
ignore-pluralsPomiń kontrolę jakości Brakująca forma liczby mnogiej.
ignore-kabyle-charactersSkip the Niestandardowe znaki w języku kabylskim quality check.
ignore-placeholdersPomiń kontrolę jakości Symbole zastępcze.
ignore-prohibited-initial-characterSkip the Zabroniony znak początkowy quality check.
ignore-punctuation-spacingPomiń kontrolę jakości Odstępy między czcionkami.
ignore-regexPomiń kontrolę jakości Wyrażenie regularne.
ignore-rst-syntaxSkip the Błąd składniowy reStructuredText quality check.
ignore-reusedSkip the Ponownie użyte tłumaczenie quality check.
ignore-same-pluralsPomiń kontrolę jakości Te same liczby mnogie.
ignore-begin-newlinePomiń kontrolę jakości Początek od nowej linii.
ignore-begin-spacePomiń kontrolę jakości Spacje początkowe.
ignore-end-newlinePomiń kontrolę jakości Zakończenie nową linią.
ignore-end-spacePomiń kontrolę jakości Końcowa spacja.
ignore-samePomiń kontrolę jakości Niezmienione tłumaczenie.
ignore-safe-htmlPomiń kontrolę jakości Niebezpieczny HTML.
ignore-urlPomiń kontrolę jakości URL.
ignore-xml-tagsPomiń kontrolę jakości Znaczniki XML.
ignore-xml-invalidPomiń kontrolę jakości Składnia XML.
ignore-zero-width-spacePomiń kontrolę jakości Znak spacji o zerowej szerokości.
ignore-ellipsisPomiń kontrolę jakości Wielokropek.
ignore-fluent-source-inner-htmlSkip the Wewnętrzny HTML źródła Fluent quality check.
ignore-fluent-source-syntaxSkip the Składnia źródła Fluent quality check.
ignore-icu-message-formatPomiń kontrolę jakości Składnia ICU MessageFormat.
ignore-long-untranslatedPomiń kontrolę jakości Długo nieprzetłumaczone.
ignore-multiple-failuresPomiń kontrolę jakości Wiele nieudanych kontroli.
ignore-unnamed-formatPomiń kontrolę jakości Wiele nienazwanych zmiennych.
ignore-optional-pluralPomiń kontrolę jakości Niespluralizowane.
Informacja
Generally the rule is named ignore-* for any check, using its
identifier, so you can use this even for your custom checks.
These flags are understood both in Konfiguracja komponentu settings, per source string settings and in the translation file itself (for example in GNU gettext).
Location-based flags¶
Some flags are added to strings by default, based on their locations. This means that certain checks will be automatically enabled depending on where the string is used.
rst-text: This flag is automatically added to strings in reStructuredText files, if location extension is.rst.md-text: This flag is automatically added to strings in Markdown files, if location extension is.mdor.markdown.
Wymuszanie kontroli¶
The enforced checks cannot be dismissed and mark string as Needs editing (see Stan tłumaczenia). This prevents translators from hiding such checks.
Podpowiedź
Turning on check enforcing doesn’t enable it automatically. Some checks have to be turned on by adding the corresponding flag to the string or component flags.
This is best used with checks that can cause serious issues when used like checks for Formatowanie ciągów. Using for style checks like Niezmienione tłumaczenie is not recommended because dismissal is sometimes a reasonable approach in these.
The Filtr jakości tłumaczeń can then be used to exclude strings needing editing from being committed to the version control.
Zarządzanie czcionkami¶
Podpowiedź
Fonts uploaded into Weblate are used purely for purposes of the Maksymalny rozmiar tłumaczenia check, they do not have an effect in Weblate user interface.
The Maksymalny rozmiar tłumaczenia check used to calculate dimensions of the rendered text needs font to be loaded into Weblate and selected using a translation flag (see Dostosowywanie zachowania za pomocą flag).
Weblate font management tool in Fonts under the Operations menu of your translation project provides interface to upload and manage fonts. TrueType or OpenType fonts can be uploaded, set up font-groups and use those in the check.
The font-groups allow you to define different fonts for different languages, which is typically needed for non-latin languages:
The font-groups are identified by name, which can not contain whitespace or special characters, so that it can be easily used in the check definition:
Font-family and style is automatically recognized after uploading them:
You can have a number of fonts loaded into Weblate:
To use the fonts for checking the string length, pass it the appropriate flags (see Dostosowywanie zachowania za pomocą flag). You will probably need the following ones:
max-size:500/max-size:300:5Defines maximal width in pixels and, optionally, the maximum number of lines (word wrapping is applied).
font-family:ubuntuDefines font group to use by specifying its identifier.
font-size:22Określa rozmiar czcionki w pikselach.
Pisanie własnych kontroli¶
A wide range of quality checks are built-in, (see Kontrole jakości), though
they might not cover everything you want to check. The list of performed checks
can be adjusted using CHECK_LIST, and you can also add custom checks.
Podklasa weblate.checks.Check
Ustaw kilka atrybutów.
Implement either the
check(if you want to deal with plurals in your code) or thecheck_singlemethod (which does it for you).
Kilka przykładów:
To install custom checks, provide a fully-qualified path to the Python class
in the CHECK_LIST, see Custom quality checks, add-ons, automatic suggestions and auto-fixes.
Checking translation text does not contain „foo”¶
This is a pretty simple check which just checks whether the translation is missing the string „foo”.
"""Simple quality check example."""
from django.utils.translation import gettext_lazy
from weblate.checks.base import TargetCheck
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
name = gettext_lazy("Foo check")
# Description for failing check
description = gettext_lazy("Your translation is foo")
# Real check code
def check_single(self, source, target, unit):
return "foo" in target
Checking that Czech translation text plurals differ¶
Check using language info to verify the two plural forms in Czech language are not same.
"""Quality check example for Czech plurals."""
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
name = gettext_lazy("Foo check")
# Description for failing check
description = gettext_lazy("Your translation is foo")
# Real check code
def check_target_unit(self, sources, targets, unit):
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